<!---- 
    Author 	: Wahyu
    Tanggal : 23-10-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>					
							
						</td>							
						<td height="25" align="right" valign="middle">								
							<span class="form-title">
								<?php echo $menu_label; ?>
							</span>
						</td>
					</tr>
				</table>		     	
		 </div>			
	</div>
	<!-- end top view -->	
	<!-- center view -->
	<div id="form-body-grey" data-options="region:'center',border:false">
		<div id="form-wrapper" class="easyui-panel"  style="width:1180%;padding:5px;" fit="true">
			<form id="fm_piutang_karyawan" name="fm_piutang_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>
								<td width="150">
									 <b><label>Transfer From</label></td>
								<td width="10">:</td>
								<td>
									<select editable='false' class="combo-grid" name="cmb_from_company"  id="cmb_from_company" required="required" style="width:200px;height:20px" data-options="
										panelWidth: 200,
										idField: 'BranchCode',
										textField: 'BranchName',
										url: '<?= base_url().$menu_link; ?>/get_company',            
										columns: [[
										{field:'BranchName',title:'Company Name',width:140}
										]],
										fitColumns: true,
										onSelect: function(rowIndex, rowData){	
											var ComCode = rowData.BranchCode;
											$('#cmb_from_bank').combogrid({
												delay: 300,
												url: '<?= base_url().$menu_link; ?>/get_akun_bank/'+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); 
												}
											});
											
											$('#cmb_karyawan').combogrid({
												delay: 300,
												url: '<?= base_url().$menu_link; ?>/get_karyawan/'+ComCode,
												idField: 'EmployeeCode',
												textField: 'EmployeeName',
												columns: [[
												    {field:'EmployeeCode',title:'NIK',width:50,sortable:true},
													{field:'EmployeeName',title:'Karayawan',width:180,sortable:true}
												]],
												onSelect: function(){
													$('#txt_rekening_karyawan').val('');
												}
											});
										}
										">
									</select>
									<select name="cmb_from_bank" id="cmb_from_bank" editable='true' class="combo-grid" required="required" style="width:200px;height:20px;">
										
									</select>
								</td>
							</tr>
							<tr>
								<td width="150">
									 <b><label>Transfer To</label></td>
								<td width="10">:</td>
								<td valign="top" align="left">
									<select  name="cmb_karyawan" editable='true' class="combo-grid" required="required" id="cmb_karyawan" style="width:200px;height:20px">
									
									</select>
									<input name="txt_rekening_karyawan" id="txt_rekening_karyawan" class="easyui-validatebox" required="required" type="text" style="width:198px" placeholder="Rekening Karyawan" autocomplete="off" />
								</td>
								
							</tr>
							<tr>
								<td width="150">
									  <b><label><?php echo label_grid('check_no');?></label>
							    </td>
								<td width="10">:</td>
								<td>
									<input name="txt_cheque_no" id="txt_cheque_no" type="text" style="width:200px" />								
		                       </td>
								
							</tr>
							
							<tr>
								<td width="150">
									  <b><label>Description</label></td>
								<td width="10">:</td>
								<td>
									<textarea class="textbox" style="resize:none;" name="txa_description" id="txa_description" cols="55" rows="3"></textarea></td>
								<td valign="top" align="left">&nbsp;</td>
							</tr>
							<tr>
							  <td width="150"><b><label>Amount</label></b></td>
							  <td width="10">:</td>
							  <td>
								<input name="txt_amount_rp" id="txt_amount_rp" type="text" onkeyup="cek_amount(this.value)" class="easyui-validatebox currency" style="width:403px;height:18px;text-align:right" required="required" />
								<input name="txt_amount" id="txt_amount" type="hidden" />
								<!--<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-calculator',size:'small'" onClick="">-->
							  </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;">Piutang 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>
                            <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>
			</form>
		</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-cancel" onclick="location.reload()">Cancel</a>	
		
					</td>
				 </tr>
			</table>				
		</div>
</div>

<script type="text/javascript">	

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

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

function save_data(){
	var total = $("#txt_amount").val();	
	if(total < 1){
		$.messager.alert('Unseccessfull','Transaksi Belum Lengkap','error');
		return false;
	}
	else {
		save_transaction('<?=$menu_link;?>', '#fm_piutang_karyawan','1');
	}
} 
</script>