<!---- 
    Author 	: Wahyu
    Tanggal : 12-08-2014	
    Revisi 	:
-->
<?php
//---------Untuk privellege jika dia ada tombol save----------
	if($group_user->SavePrivillage == 1){
		$cek_autority_save  = "";
	}
	else{
		$cek_autority_save 	= "disabled";
	}
//-------------end----------------------------
?>
<div class="easyui-layout" data-options="fit:true,border:false">
	<!-- top view-->
	<div id="form-header" data-options="region:'north',border:false" >
		 <div id="form-header-wrapper">
				<table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
					<tr>
						<td align="left" valign="middle">
							<a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="location.reload()">New</a>
							<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="location.reload()">Refresh</a>
							<!-- <a href="#" class="easyui-linkbutton" iconCls="icon-journal" plain="true" onclick="" disabled>Journal</a> -->
						</td>							
						<td height="25" align="right" valign="middle">								
							<span class="form-title">
								<?= $menu_label; ?>
							</span>
						</td>
					</tr>
				</table>		     	
		 </div>			
	</div>
	<!-- end top view -->	
	<!-- center view -->
	<div id="form-body" data-options="region:'center',border:false" class="form-body-combo">
		<div id="form-wrapper" class="easyui-panel"  style="width:1180%;height:548px;padding:5px;" fit='true'>
			<form id="fm_payment_karyawan" name="fm_payment_karyawan" method="post" action="">
            <!-- Form Header -->
                <table width="100%" height="141" cellpadding="0" cellspacing="0">
	                <tr>
	                    <td width="50%" valign="top">   
			                <table cellpadding="0" cellspacing="3" width="100%" height="100%" border="0">
								<tr>
								    <input name="txt_piutang_no" id="txt_piutang_no" type="hidden" style="width:100px" />
								    <input name="txt_total_piutang" id="txt_total_piutang" type="hidden" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.'" style="width:100px" />
			                        <input type="hidden" id="hide_new_index" name="hide_new_index" />
			                        <input type="hidden" id="payment_balance" name="payment_balance" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.'"/>
			                        <input type="hidden" id="txt_new_status" name="txt_new_status" />
			                        
			                        <input type="hidden" id="detail" name="detail" />
			                        <input type="hidden" id="total_balance" name="total_balance" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.'"/>
			                        
									<td width="150"><b><label>Payment For</label></b></td>
								  	<td width="10"><b>:</b></td>
									<td valign="top" align="left"  width="768">
										 <input name="txt_payment_for" id="txt_payment_for" type="text" style="width:200px" class="disabled" readonly/>	
										 <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-sales" onclick="modal_open('Payment List','dialog-payment-list')" style="width:110px;" plain="true">List Payment</a>
									</td>
									
								</tr>
								<tr>
									<td width="150"><b><label>Transfer To</label></b></td>
								  	<td width="10"><b>:</b></td>
									<td valign="top" align="left"  width="768">
										<select name="cmb_to_company" editable='false' class="combo-grid" id="cmb_to_company" required="required" style="width:202px;height:20px" data-options="
											panelWidth: 210,
											idField: 'BranchCode',
											textField: 'BranchName',
											url: '<?= base_url().$menu_link; ?>/get_company',            
											columns: [[
											{field:'BranchName',title:'Company Name',width:140}
											]],
											fitColumns: true
											">
										</select>
										<select name="cmb_to_bank" id="cmb_to_bank" editable='true' class="combo-grid" required="required" style="width:200px;height:20px;">
											
										</select>							
									</td>
									
								</tr>
								<tr>
									<td width="150"><b><label>From</label></b></td>
								  	<td width="10"><b>:</b></td>
									<td >
										<input name="txt_karyawan" id="txt_karyawan" type="hidden" style="width:200px" />
										<input name="txt_karyawan_name" id="txt_karyawan_name" type="text" style="width:200px" disabled="true" />						
										<input name="txt_cheque_date" id="txt_cheque_date" type="hidden"  style="width:100px;height:20px;" />
										<input type="hidden" name="txt_new_no" id="txt_new_no" value="">
										<input name="txt_cheque_no" id="txt_cheque_no" class="easyui-validatebox" type="text" style="width:198px" placeholder="<?php echo label_grid('check_no');?>" autocomplete="off" />
									</td>
									
								</tr>
								<tr>
									<td width="150" valign="top"><b><label>Description</label></b></td>
								  	<td width="10" valign="top"><b>:</b></td>
									<td><textarea class="textbox" style="resize:none;" name="txa_description" id="txa_description" cols="55" rows="3"></textarea></td>
									
								</tr>
								<tr>
								  <td width="150"><b><label>Amount</label></b></td>
								  <td width="10"><b>:</b></td>
								  <td>
									<input name="txt_amount_rp" id="txt_amount_rp" type="text" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.',disabled:true" autoComplete="off" style="width:405px;" required="required" />
									<input name="txt_amount" id="txt_amount" type="hidden" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.'"/>
									<!-- <a href="#" class="easyui-linkbutton" id="idchoose_cicilan" data-options="iconCls:'icon-calculator',size:'small'" onClick="choose_cicilan()"></a> -->
								  </td>
								  
							    </tr>
							    				
							</table>
						</td>
						<td width="50%" valign="top">
	                        <table width="100%" cellpadding="0" cellspacing="1" style="margin-top:4px;">
	                        <tr height="20">
	                            <td rowspan="7" valign="top">&nbsp;</td>
	                            <td width="122">&nbsp;</td>
	                            <td width="150" style="background:#333399;text-align:center;color:#FFF;"><b>Available Balance (<span class='bank_balance_currency'></span>)</b></td>
	                            <td width="122" style="background:#333399;text-align:center;color:#FFF;">Payment Date</td>
	                        </tr>
	                        <tr height="20">
	                        	<td>&nbsp;</td>
	                            <td><input name="txt_bank_balance" id="txt_bank_balance" type="text" class="easyui-numberbox" data-options="precision:2,decimalSeparator:',',groupSeparator:'.',prefix:''" style="text-align:right;width:180px;height:22px" readonly /></td>
	                            <input type="hidden" name="txt_payment_no" id="txt_payment_no" class="easyui-validatebox disabled" style="width:200px;" readonly  required="required" />
	                            <td><input type="text" name="txt_payment_date" id="txt_payment_date" class="easyui-datebox validBackward" style="width:122px;height:22px" required editable="false" value="<?= $date_now;?>"/></td>
	                        </tr>
	                        </table>
                    	</td>
					</tr>
				</table>
				<table id="dtg_payment_history" class="easyui-edatagrid"
					title="Payment History" idField="id"
					rownumbers="true" fitColumns="true" singleSelect="true" style="height:290px;" toolbar="#tb_dtg_pay_piutang" 
						data-options="
							onClickRow:function(){
					             var selected_data=$('#dtg_payment_history').datagrid('getSelected');
					             var no_paymen = $('#txt_payment_no').val();
					             if(selected_data.EInsNumber != no_paymen){
					                 $.messager.alert('Unseccessfull','Data tidak sama dengan Nomor payment afiliasi','error',function(){	
					                $('#dtg_payment_history').datagrid('reload');
					                $('#txt_new_status').val(0);
					                });
					             }
					        },
					        onBeginEdit:function(rowIndex){
								save_button_begendedit('<?=$group_user->SavePrivillage;?>');
							},
					        onEndEdit:function(){
								save_button_endedit('<?=$group_user->SavePrivillage;?>');
							}
						"
					>
					<thead>
						<tr>
							<th formatter="formatRp" data-options="field:'LoanPayment',width:75,halign:'center',align:'right', editor:{type:'numberbox',options:{precision:2,decimalSeparator:',', disabled:true}}">Loan Payment</th>
							<th data-options="field:'PaymentPeriod',width:15,halign:'center',align:'center', editor:{type:'numberbox',options:{disabled:true}}" hidden="true">Period</th>
							<th formatter="formatRp" data-options="field:'PaymentPerPeriod',width:75,halign:'center',align:'right', editor:{type:'numberbox',options:{precision:2,decimalSeparator:',',required:true}}">Payment Per Period</th>
							<th formatter="formatRp" data-options="field:'PaymentBalance',width:75,halign:'center',align:'right', editor:{type:'numberbox',options:{precision:2,decimalSeparator:',', disabled:true}}">Payment Balance</th>
                            <th data-options="field:'EInsNumber',width:75,halign:'center',align:'right', editor:{type:'textbox'}" hidden="true">Eins Number</th>
						</tr>
					</thead>
				</table>
			</form>
		</div>
        <div id="tb_dtg_pay_piutang">
            <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addNewRow(false)">New</a>
        </div>
	</div>
    <div id="form-footer" data-options="region:'south',border:false">
			<table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
				 <tr>
				   <td align="left">
						
				   </td>
					<td align="right">                              
						 <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>
                         <a href="javascript:void(0)" class="easyui-linkbutton form-button save-button" iconCls="icon-save" onclick="save_data();" <?php echo $cek_autority_save;?>>Save</a> 								
                         <!-- <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-print" onclick="" disabled>Preview & Print</a>    -->
                         <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="parent.tab_close('tt')">Cancel</a>
					</td>
				 </tr>
			</table>				
		</div>
</div>


<!-- Dialog Payment List -->
<div id="dialog-payment-list" class="easyui-dialog" style="width:765px; left:150px; top:50px; background-color:#F8F8F8; height:500px; padding: 0 0px 0 0px" closed="true" data-options="modal:true" buttons="#dialog-buttons">
	<table id="dtg_payment_list" style="width:750px;" 
        url="<?php echo base_url(); ?><?php echo $menu_link; ?>/get_piutang"
        singleSelect="true"
        idField="" >
		<thead>
			<tr>
				<th colspan="2">Dari</th>
				<th rowspan="2" field="EDebtAmount" formatter="formatRp" width="135" align="right" halign="center">Amount</th>
                <th rowspan="2" field="EmployeeName" width="120" align="center">Kepada</th>
                <th rowspan="2" field="outstanding" width="130" formatter="formatRp" align="right" halign="center">OutStanding</th>	
                <th rowspan="2" field="EdebtIsLock" align="right" width="90"  halign="center" >Status</th>
                <th rowspan="2" field="EDebtDesc" align="right" width="90"  halign="center" hidden="true">Memo</th>				
			</tr>
			<tr>
				<th field="BranchName" width="120" align="center">Perusahaan</th>
				<th field="AccountName" width="120" align="center">Bank</th>
				<th field="EDebtNumber" hidden="true" width="50" align="center">No Piutang</th>
					
                <th field="BranchCode" hidden="true" width="120" align="center">Branch Code</th>			
			</tr>
		</thead>
	</table>
	<div id="dialog-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onClick="choose_piutang_karyawan(false)">OK</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onClick="modal_close('dialog-payment-list')">Cancel</a>
	</div>
</div>

<script type="text/javascript">

var SavePrivillage 	= '<?=$group_user->SavePrivillage;?>';

$(document).ready(function(){

    $('#txt_payment_no').val('<?php echo $payment_karyawan; ?>');
    $('#txt_payment_date').datebox({
        onChange:function(){
            url             = base_url + '<?php echo $menu_link;?>get_payment_karyawan_number';                
            var Payment_karyawan_date   = $('#txt_payment_date').datebox('getValue');
            
            $.post(url, {Payment_karyawan_date:Payment_karyawan_date}, function(result){
                if (result.status === true){
                    $('#txt_payment_no').val(result.number);
                } 
            },'json');
        }
    }); 

    $('#fm_payment_karyawan').click(function(){
		var txt_new_no 		= $('#txt_new_no').val();
		
		if(txt_new_no == 1){
			choose_cicilan();
			var rownumbers = $('.datagrid-cell-rownumber').length;
			for(var x = 0; x < rownumbers; x++){
				$('.datagrid-cell-rownumber').eq(x).html(x+1);
				
			}
		}
    });

    var no_piutang = '<?= $no_piutang;?>';

    $('#dtg_payment_list').datagrid({
    	rowStyler: function(index,row){
				if (row.EdebtIsLock=='Locked'){					
					return 'background-color:#FF6666;color:#fff;';
				}					
			},
			onLoadSuccess:function(data){
				if(no_piutang !=''){
				    var ind_piutang = findWithAttr(data.rows,'EDebtNumber',no_piutang);
				    $('#dtg_payment_list').datagrid('selectRow',ind_piutang);
				    if(data.rows[ind_piutang]['EdebtIsLock']!='Locked'){
				    	choose_piutang_karyawan(true);
				    }
				}
			}
    });

    $('#txt_payment_for').on('mouseover',function(){
    	$(this).css({'color':'blue','font-weight':'bold','cursor':'pointer'});
    }).on('mouseout',function(){
    	$(this).css({'color':'#545454','font-weight':'normal'});
    }).on('click',function(){
    	var TransNumber = $(this).val();
    	parent.tab_edit('Edit Piutang Karyawan','list/piutang_karyawan', 'icon-edit', 'edit',TransNumber) ;
    });

});


function addNewRow(val){

	$('#txt_new_no').val(1);

	var loan_value 			= parseFloat($('#txt_total_piutang').numberbox('getValue'));
    if(loan_value == "" || isNaN(loan_value)){
		$.messager.alert('Info','Piutang belum dipilih','error',function(){
			return false;
		});
	}
    else if($('#txt_new_status').val() == 1){
    	$.messager.alert('Info','Tidak Boleh Memilih Lebih Dari Satu','error',function(){
			return false;
		});
    }
    else{
    	$('#txt_new_status').val(1);
    	var txt_payment_for		= $('#txt_payment_for').val();
		var period 				= 1;
		var payment_perperiod 	= 0;
		var payment_balance 	= 0;
		var nomer_eins = $('#txt_payment_no').val();
        
		var dg_rows = $('#dtg_payment_history').datagrid('getRows');

		for(var i=0; i<dg_rows.length; i++){
			if(isNaN(dg_rows[i].PaymentPeriod)){ dg_rows[i].PaymentPeriod = 1; }
			if(isNaN(dg_rows[i].PaymentBalance)){ dg_rows[i].PaymentBalance = 0; }
			if(isNaN(dg_rows[i].PaymentPerPeriod)){ dg_rows[i].PaymentPerPeriod = 0; }
			period = ++period;
			payment_perperiod += parseInt(dg_rows[i].PaymentPerPeriod);
			payment_balance += parseFloat(dg_rows[i].PaymentBalance);
			var newIndex = i+1;
			$('#hide_new_index').val(newIndex);
        }

        if(payment_balance != ""){
			if(loan_value == payment_perperiod){
				$.messager.alert('Info','Pembayaran piutang sudah balance');
				return false;
			}
			else{

				if(val == false){
					$('#dtg_payment_history').datagrid('appendRow',{
						LoanPayment: loan_value,
	                    EInsNumber: nomer_eins,
						PaymentPeriod: period,
						PaymentPerPeriod:0,
						PaymentBalance:0
					});
				}else{
					$('#dtg_payment_history').datagrid('appendRow',{
						LoanPayment: loan_value,
	                    EInsNumber: nomer_eins,
						PaymentPeriod: period,
						PaymentPerPeriod:val,
						PaymentBalance:0
					});
				}
			}
		}else{
			if(val == false){
				$('#dtg_payment_history').datagrid('appendRow',{
					LoanPayment: loan_value,
                    EInsNumber: nomer_eins,
					PaymentPeriod: period,
					PaymentPerPeriod:0,
					PaymentBalance:0
				});

			}else{
				$('#dtg_payment_history').datagrid('appendRow',{
					LoanPayment: loan_value,
                    EInsNumber: nomer_eins,
					PaymentPeriod: period,
					PaymentPerPeriod:val,
					PaymentBalance:0
				});
			}

			var dg_rows = $('#dtg_payment_history').datagrid('getRows');
			for(var i=0; i<dg_rows.length; i++){
				var newIndex = i;
			}
			$('#hide_new_index').val(newIndex);
		}

		if(val == false){
			var ed = $('#dtg_payment_history').datagrid('beginEdit', newIndex);
			var ed2 = $('#dtg_payment_history').edatagrid('getEditor',{index:newIndex,field:'PaymentPerPeriod'});
			$(ed2.target).focus();
		}

    }
}    

function choose_piutang_karyawan(val){
	var selected_data=$('#dtg_payment_list').datagrid('getSelected');
	if(selected_data.EdebtIsLock=='Locked'){
		$.messager.alert('Info','Tidak bisa memilih Transaksi yang di-Lock');
	}
	else{
        $('#txt_new_status').val(0);
        $('#cmb_to_company').combogrid('setValue', selected_data.BranchCode);
        
        var ComCode = selected_data.BranchCode; 
        $('#cmb_to_bank').combogrid({
                delay: 300,
                url: '<?= base_url().$menu_link; ?>/get_akun_bank_edit/'+ComCode,
                idField: 'AccountNumber',
                textField: 'AccountName',
                columns: [[
                    {field:'AccountName',title:'AccountName',width:400,sortable:true}
                ]],
                onSelect:function(rowIndex,rowData){
                	
                    get_bank_balance(rowData.AccountNumber,rowData.CurrencyCode);
                },
                onLoadSuccess:function(data){
                	var total_data = data.rows.length;
                	if(total_data > 0){
                		$('#cmb_to_bank').combogrid('setValue',data.rows[0]['AccountNumber']);
                	}
                }
        });
    
        $('#cmb_to_bank').combogrid('setValue', selected_data.BankTransfer); 
        $('#txt_karyawan').val(selected_data.EmplRecpCode);
        $('#txt_karyawan_name').val(selected_data.EmployeeName);
        $('#txt_piutang_no').val(selected_data.EDebtNumber);
        $('#txt_total_piutang').numberbox('setValue',selected_data.EDebtAmount);
        $('#txa_description').html(selected_data.EDebtDesc);
        
        $('#txt_payment_for').val(selected_data.EDebtNumber);
        
        var piutang_no = selected_data.EDebtNumber;
        $('#dtg_payment_history').datagrid({
            url:'<?php echo base_url(); ?><?php echo $menu_link; ?>/get_history_payment/'+piutang_no,
            onLoadSuccess:function(data){
            	if(val!=false){
		        	addNewRow(selected_data.outstanding);
		        	$('#txt_amount_rp').numberbox('setValue', selected_data.outstanding);
					$('#txt_amount').numberbox('setValue',selected_data.outstanding);
					$('#total_balance').numberbox('setValue',0);
					$('#payment_balance').numberbox('setValue',0);
		        }
            }
        });
                
        modal_close('dialog-payment-list');
    }
}

function choose_cicilan(){
    var newIndex 		= $('#hide_new_index').val();
	var dg_rows 		= $('#dtg_payment_history').datagrid('getEditors', newIndex);
	
	var loanPayment		= $(dg_rows[0].target);
	var payPerPeriod	= $(dg_rows[2].target);
	var payBalance		= $(dg_rows[3].target);
	
	if(newIndex == 0){
		var balance = loanPayment.numberbox('getValue')-payPerPeriod.numberbox('getValue');
		payBalance.numberbox('setValue', balance);
	}

	$('#txt_amount_rp').numberbox('setValue', payPerPeriod.numberbox('getValue'));
	$('#txt_amount').numberbox('setValue',payPerPeriod.numberbox('getValue'));
	$('#total_balance').numberbox('setValue',balance);
	$('#payment_balance').numberbox('setValue',balance);
	
	var cek = $('#dtg_payment_history').datagrid('getRows');
	$('#dtg_payment_history').datagrid('endEdit', newIndex);

	var loan_payment 		= 0;
	var payment_perperiod 	= 0;

	for(var i=0; i<cek.length; i++){
		if(isNaN(cek[i].LoanPayment)){ cek[i].LoanPayment = 0; }
		loan_payment 	= parseFloat(cek[i].LoanPayment);
		if(isNaN(cek[i].PaymentPerPeriod)){ cek[i].PaymentPerPeriod = 0; }
		payment_perperiod += parseFloat(cek[i].PaymentPerPeriod);
		if(isNaN(cek[i].PaymentBalance)){ cek[i].PaymentBalance = 0; }
	}
	
	if(payment_perperiod > loan_payment){
		$.messager.alert('Unseccessfull','Pembayaran melebihi sisa nilai pinjaman','error',function(){
			$('#txt_amount_rp').numberbox('setValue','');
			$('#txt_amount').numberbox('setValue', 0);
            $('#dtg_payment_history').datagrid('reload');
            $('#txt_new_status').val(0);
			return false;
		});
	}
	else{
		var newIndex2 		= $('#hide_new_index').val();
		$('#dtg_payment_history').datagrid('beginEdit', newIndex2);
		var dg_rows2 		= $('#dtg_payment_history').datagrid('getEditors', newIndex2);
		var payBalance		= $(dg_rows2[3].target);
		var countBalance	= loan_payment-payment_perperiod;
		payBalance.numberbox('setValue', countBalance);
		$('#dtg_payment_history').datagrid('endEdit', newIndex2);
		var valAmount 	= $('#txt_amount_rp').numberbox('getValue');
		var convAmount 	= toAngka(valAmount);
		if(isNaN(convAmount) || convAmount == 0 || convAmount == ''){
			$('#calc_validate').linkbutton('enable');
			$('#txt_amount_rp').numberbox('setValue','');
			$('#txt_amount').val('');
		}
		else{
			$('#payment_balance').numberbox('setValue',countBalance);
			//$('#calc_validate').linkbutton('disable');
		}
	}
}

function cek_amount(value){
	var total = toAngka(value);
	$("#txt_amount").val(total);
}

function save_data(){
	$('#dtg_payment_history').edatagrid('saveRow');
	var cek = $('#dtg_payment_history').datagrid('getRows');
	var total = parseFloat($("#txt_amount").numberbox('getValue'));	
	var t_piutang = $('#txt_total_piutang').numberbox('getValue');
	var tt_piutang = parseFloat(t_piutang);
     var loan_payment 		= 0;
    var payment_perperiod 	= 0;
    var payment_period 		= 0;
	
    for(var i=0; i<cek.length; i++){
        if(isNaN(cek[i].LoanPayment)){ cek[i].LoanPayment = 0; }
        loan_payment 	= parseFloat(cek[i].LoanPayment);
        if(isNaN(cek[i].PaymentPerPeriod)){ cek[i].PaymentPerPeriod = 0; }
        if(i==(cek.length-1)) 
        	payment_perperiod += parseFloat(cek[i].PaymentPerPeriod);
        	payment_period 	  += 1;
    }
    
  
	if(total < 1){
		$.messager.alert('Unseccessfull','Transaksi Belum Lengkap','error');
		return false;
	}
    else if(total > tt_piutang){		
        $.messager.alert('Unseccessfull','Pembayaran melebihi sisa nilai pinjaman','error',function(){
        	$('#txt_amount_rp').numberbox('setValue','');
			$('#txt_amount').numberbox('setValue', 0);
        	$('#dtg_payment_history').datagrid('reload');
            $('#txt_new_status').val(0);
        return false;
        });
	}	
    else if(payment_perperiod != total){
        $.messager.alert('Unseccessfull','Payment Per Period Tidak Sama Dengan Amount.','error',function(){
            $('#dtg_payment_history').datagrid('reload');
            $('#txt_new_status').val(0);
            return false;
        });
    }
	else {
		
        $('#dtg_payment_history').edatagrid('saveRow');
        var i=$('#dtg_payment_history').datagrid('getRows');
        var detail = JSON.stringify(i);
        $("#detail").val(detail);

        var piutang_no   	= $('#txt_payment_for').val();

		checking_payment_save(piutang_no,payment_period,'EIns',function(check){
			
			if(check.status == false){
				save_transaction('<?php echo $menu_link; ?>', '#fm_payment_karyawan','1');
			}else{
				$.messager.alert('Unseccessfull',check.message,'error',function(){
					location.reload();
				});
			}
		});
		
	}

}
</script>