<!---- 
Author 	: Tagor \ 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">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="parent.tab_add('New Piutang Afiliasi','<?=$menu_link?>','icon-add','add')">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" style="margin-left:7px;">
                        <?=$menu_label?>
                    </span>
                </td>
            </tr>
            </table>		     	
        </div>			
    </div>
    <!-- End of top view -->
    
    <div id="form-body" data-options="region:'center',border:false">
		<div id="form-wrapper" class="easyui-panel" style="width:1180%;height:526px;padding:5px;" fit='true'>
        	<form id="fm_piutang_afiliasi" name="fm_piutang_afiliasi" method="post">
            	<!-- Form Header -->
                <table width="100%" height="141" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="50%" valign="top">
                    	<table width="100%" cellpadding="0" cellspacing="1" style="margin-top:4px;">
                        <tr height="20">
                        	<td width="150"><b>Transfer From</b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<select name="cmb_fromcompany" id="cmb_fromcompany"  editable='false' class="combo-grid"
                                    style="width:199px;" 
                                    data-options="
                                        value:'<?= $detail->CompanyCode; ?>',
                                        panelWidth:199,
                                        idField:'CompanyCode',
                                        textField:'CompanyName',
                                        url:'<?= base_url().$menu_link; ?>/company_by_login/<?= $this->session->userdata('company');?>',
                                        columns: [[
                                            {field:'CompanyCode',title:'Company Code',width:110,halign:'center'}, 
                                            {field:'CompanyName',title:'Company Name',width:190,halign:'center'}
                                        ]]

                                    " required 
                                >
                                </select>
                                <select name="cmb_bankfrom" id="cmb_bankfrom" editable='true' class="combo-grid"
                                    style="width:199px;"  
                                    data-options="
                                    	panelWidth:199,
                                        idField: 'AccountNumber',
                                        textField: 'AccountName',
                                        url:'<?= base_url().$menu_link; ?>/get_bank_bycompany/<?= $this->session->userdata('company');?>',
                                        columns: [[
                                            {field:'AccountNumber',title:'Account Number',width:110,halign:'center',hidden:true}, 
                                            {field:'AccountName',title:'Bank Name',width:190,halign:'center'}, 
                                            {field:'CurrencyCode',title:'Bank Currency',width:80,halign:'center',align:'center'}
                                        ]],
                                        fitColumns: true,
                                        onSelect:function(rowIndex, rowData){
                                            
                                            get_bank_balance(rowData.AccountNumber,rowData.CurrencyCode);
                                        }
                                    " required editable="false"
                                >
                                </select>
                            </td>
                        </tr>
                        <tr height="20">
                        	<td width="150"><b>Transfer To</b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<select name="cmb_tocompany" id="cmb_tocompany" editable='true' class="combo-grid"
                                    style="width:199px;"
                                    data-options="
                                        panelWidth:199,
                                        idField:'CompanyCode',
                                        textField:'CompanyName',
                                        url:'<?= base_url(); ?>list/piutang_afiliasi/company_not_by_login/<?= $this->session->userdata('company');?>',
                                        columns: [[
                                            {field:'CompanyCode',title:'Company Code',width:110,halign:'center',hidden:true}, 
                                            {field:'CompanyName',title:'Company Name',width:190,halign:'center'}
                                        ]],
                                        onSelect: function(indexRow,dataRow){
                                            var url = '<?= base_url(); ?>list/piutang_afiliasi/get_bank_bycompany/'+dataRow.CompanyCode;
                                            $('#cmb_bankto').combogrid('grid').datagrid({
                                                url:url
                                            });
                                            $('#cmb_bankto').combogrid('setValue', '');
                                        }
                                    " required
                                >
                                </select>
                                <select name="cmb_bankto" id="cmb_bankto"  editable='true' class="combo-grid"
                                    style="width:199px;" 
                                    data-options="
                                    	panelWidth:199,
                                        idField: 'AccountNumber',
                                        textField: 'AccountName',
                                        columns: [[
                                            {field:'AccountNumber',title:'Account Number',width:110,halign:'center',hidden:true}, 
                                            {field:'AccountName',title:'Bank Name',width:190,halign:'center'}, 
                                            {field:'CurrencyCode',title:'Bank Currency',width:80,halign:'center',align:'center'}
                                        ]],
                                        fitColumns: true
                                    " required
                                >
                                </select>
                            </td>
                        </tr>
                        <tr height="20">
                        	<td width="150"><b><?php echo label_grid('check_no');?></b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<input name="txt_chequeno" id="txt_chequeno" type="text" style="width:197px" />
                                <!--input type="checkbox" name="chk_giromundur" id="chk_giromundur" value="1">
                                <span style>Giro Mundur<span-->
                            </td>
                        </tr>
                        
                        <tr height="20">
                        	<td width="150"><b>Memo</b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<textarea class="textbox" name="txa_memo" id="txa_memo" rows="4" style="width:400px;resize:none;white-space:normal;"></textarea>
                            </td>
                        </tr>
                        <tr height="20">
                        	<td width="150"><b>Amount (IDR)</b></td>
                            <td width="10"><b>:</b></td>
                            <td>
                            	<input name="txt_amount" id="txt_amount" type="text" class="easyui-numberbox"  data-options="min:0.01,precision:2,decimalSeparator:',',groupSeparator:'.',prefix:''" onkeyup="duplicate_amount()" autoComplete="off" style="width:400px;text-align:right" required="required" />
                                <input type="hidden" id="txt_amount_hidden" name="txt_amount_hidden" />
                                <!--a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-calculator',size:'small'" onClick=""-->
                            </td>
                        </tr>
                        <tr height="20" style="display:none">
                            <td width="150" align="left"><b>Bank Balance (<span class='bank_balance_currency'></span>)</b></td>
                            <td width="10"><b>:</b></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:400px" readonly />
                            </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>&nbsp;</td>
                            <!-- <td width="190" style="background:#333399;text-align:center;color:#FFF;">Piutang Afiliasi No.</td> -->
                            <td width="122" style="background:#333399;text-align:center;color:#FFF;">Piutang Afiliasi Date</td>
                        </tr>
                        <tr height="20">
                        	<td>&nbsp;</td>
                            <!-- <td><input type="text" name="afiliasi_no" id="afiliasi_no" class="easyui-validatebox" style="width:190px;background-color:#E3E2E2;" required readonly /></td> -->
                            <td><input name="txt_afiliasi_date" id="txt_afiliasi_date" type="text" class="easyui-datebox validBackward" style="width:122px;height:22px" required editable="false" value="<?php echo $date_now;?>"/></td>
                        </tr>
                        </table>
                    </td>
                </tr>
                </table>
                <!-- End of form header -->
            </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();" <?php echo $cek_autority_save;?>>Save</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>

<script type="text/javascript">

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

function save(){
	if($('#cmb_bankto').combogrid('getValue') == $('#cmb_bankfrom').combogrid('getValue')){
		$.messager.alert('Warning','BANK Transfer From tidak boleh sama dengan BANK Transfer To atau tidak boleh kosong');
		return false;
	}
	else{
		save_transaction('<?=$menu_link?>','#fm_piutang_afiliasi');
	}
}

function duplicate_amount(){
	var pay_amount		= $('#txt_amount').val();
	var pay_to_angka	= toAngka(pay_amount);
	$('#txt_amount_hidden').val(pay_to_angka);
}
</script>