<!--
Author      : Ferry / Tanggal : 15-06-2015	
Revision    :
-->

	<?php
			//---------Untuk privellege jika dia ada tombol save----------
				if($group_user->AddPrivillage == 1){
					$cek_autority_add  = "";
				}
				else{
					$cek_autority_add 	= "disabled";
				}
				
				if($group_user->DeletePrivillage == 1){
					$cek_autority_delete  = "";
				}
				else{
					$cek_autority_delete 	= "disabled";
				}
				
				if($group_user->EditPrivillage == 1){
					$cek_autority_edit  = "";
				}
				else{
					$cek_autority_edit	= "disabled";
				}
				
				//-------------end----------------------------
	?>


<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="padding:2px;">
        <a href="#" class="easyui-linkbutton" id="new-linkbutton" data-options="plain:true,iconCls:'icon-add'" onclick="parent.tab_add('New Bank Reconcile', '<?=$menu_link?>', 'icon-add', 'add');" <?php echo $cek_autority_add;?>>New</a>
        <a href="#" class="easyui-linkbutton" id="edit-linkbutton" data-options="plain:true,iconCls:'icon-edit'" onclick="parent.tab_edit('Edit Bank Reconcile', '<?=$menu_link?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').PInvNumber);" <?php echo $cek_autority_edit;?>>Edit</a>
        <a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="refresh_datagrid('#grid');">Refresh</a>
        <a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true,iconCls:'icon-print'" onclick="clickPreview();">Print Preview</a>
    </div>

    <div id="west-panel" data-options="region:'west',split:true,border:true" title="Filter" style="width:190px;background-color:#CCCCFF;padding:5px;">
        <form class="form-filter">
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="padding-bottom:8px;"><b>by Bank</b></td>
                </tr>

                <tr>
                    <td>
                        <select name="cmb_Bank" id="cmb_Bank" class="easyui-combobox" style="width:175px;height:22px;border:1px solid #CCC;" editable="false"
                            data-options="
                                valueField:'AccountNumber',
                                textField:'AccountName',
                                url:'<?php echo base_url(); ?>list/bank_reconcile/ajax_bank_account/<?php echo $this->session->userdata('company');?>',
                                onSelect: function(rec){
                                    search_data();
                                }
                            ">
                        </select>
                    </td>
                </tr>

                <tr><td><div class="tr-divider"></div></td></tr>

                <tr>
                    <td style="padding-bottom:8px;">
                        <b>by Date</b>
                        <input type="checkbox" name="chk_ByDate" id="chk_ByDate" value="1" style="float:right;" />
                    </td>
                </tr>

                <tr>
                    <td width="" align="left">
                        From
                        <span style="float:right;">
                            <input name="txt_DateFrom" id="txt_DateFrom" type="text" class="easyui-datebox filter_date" style="width:100px;height:22px;" onSelect="search_data();" editable="false" disabled />
                        </span>
                    </td>
                </tr>

                <tr>
                    <td width="" align="left">
                        To
                        <span style="float:right;">
                            <input name="txt_DateTo" id="txt_DateTo" type="text" class="easyui-datebox filter_date" style="width:100px;height:22px;" onSelect="search_data();" editable="false" disabled />
                        </span>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">		
			<table id="grid" 
				title="" iconCls="icon-edit" 
				singleSelect="true" rowNumbers="true" 
				pageSize="50" 
				fitColumns="true" remoteSort="false" 
				url="<?=site_url('list/bank_reconcile/ajax')?>"
				style="width:auto;height:550px" 
				data-options = "border:false,view:scrollview,autoRowheight:false"
			>
		
            <thead>
                <tr>
                    <th field='BranchName'       width='170' data-options="halign:'center',align:'left'">Branch</th>
                    <th field='TransNumber'       width='160' data-options="halign:'center',align:'center'">Transaction No.</th>
                    <th field='ReconcileDate'         width='80'  data-options="halign:'center',align:'center'" formatter="formatDate">Date</th>
                    <th field='AccountName'    width='110' data-options="halign:'center',align:'center'">Bank Reconcile</th>
                    <th field='CurrencyName'     width='80'  data-options="halign:'center',align:'center'">Currency</th>
                    <th field='SaldoDebet'     width='110' data-options="halign:'center',align:'right'" formatter="formatRp">Deposit</th>
                    <th field='SaldoCredit'       width='110' data-options="halign:'center',align:'right'" formatter="formatRp">Withdrawal</th>
                    <th field='TransStatus'           width='120' data-options="halign:'center',align:'center'">Status</th>
                    <th field='CreatedBy'    width='60'  data-options="align:'center',halign:'center'" >CreatedBy</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

<script>
    $(document).ready(function(){
        $('.filter_date').datebox({
            onSelect: function(date){
                search_data();
            }
        });	

        $('#chk_ByDate').click(function(){
            if( $(this).is(':checked') ){
                $('#txt_DateFrom').datebox('enable', true);
                $('#txt_DateTo').datebox('enable', true);
                $('#txt_DateFrom').datebox('setValue', '<?=date('01-m-Y')?>');
                $('#txt_DateTo').datebox('setValue', 'today');
            }
            else {
                $('#txt_DateFrom').datebox('disable', true);
                $('#txt_DateTo').datebox('disable', true);
                $('#txt_DateFrom').datebox('setValue', '');
                $('#txt_DateTo').datebox('setValue', '');
            }
            search_data();
        });
		
		$('#grid').datagrid({
            onDblClickRow:function(){
                if(status_privelage_edit == 1){
					parent.tab_edit('Edit Bank Reconcile', '<?=$menu_link?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').BRenNumber);
				}
            }
        });
    });

    function clickPreview() {
        var arr_string = sendParamJson();
//        parent.tab_add('Print <?=$menu_label?>', '<?=$menu_link?>', 'icon-print', 'to_preview/' + arr_string);
        parent.tab_add('Print Bank Reconcile', 'list/bank_reconcile', 'icon-print', 'to_preview/' + arr_string);
    }

status_datagrid('grid');
</script>