<!---- 
    Author 	: Wahyu
    Tanggal : 06-08-2014	
    Revisi 	:
-->

<?php
$disable_add	= '';
$disable_edit	= '';
$disable_delete	= '';
// -Later use
//if(strpos($available_action, 'A') === false)
//	$disable_add	= 'disabled';
//if(strpos($available_action, 'E') === false)
//	$disable_edit	= 'disabled';
//if(strpos($available_action, 'D') === false)
//	$disable_delete	= 'disabled';
?>

<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="height:30px">
        <div style="padding:2px">
			<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="$('#grid').datagrid('reload',{})">Refresh</a>
			<!--<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'" onClick="parent.tab_add('Print Account History', '<?php echo $menu_link; ?>', 'icon-print', 'to_preview')">Print Preview</a>-->
        </div>
    </div>
    
    <div id="west-panel" data-options="region:'west',split:true,border:true" title="Filter" style="width:190px;background-color:#CCCCFF;">
        <div style="padding:5px">
        <form class="form-filter">
        	<table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td width="190" align="left" style="padding-bottom:8px;">
                    <b>by Account No.</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_IDNumber" name="txt_IDNumber"  placeholder="< Account No. >" style="margin:2px 0px 3px;width:172px;height:18px;border:1px solid #CCC;" >
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_Description" name="txt_Description"  placeholder="< Account Name. >" style="margin:2px 0px 3px;width:172px;height:18px;border:1px solid #CCC;">
                </td>
            </tr>
            <tr><td><div class="tr-divider"></div></td></tr>
            <tr>
                <td style="padding-bottom:8px;">
                    <b>by Account Type</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<select name="cmb_AccountType" id="cmb_AccountType" 
                        class="easyui-combobox" 
                        data-options="
                            valueField:'AccountTypeID',
                            textField:'AccountTypeName',
                            url:'<?php echo base_url(); ?>custom/get_data/accounttype'
                        " style="width:172px;" 
                        editable="false"
                    >
                    </select>
                </td>
            </tr>
            <tr>
                <td style="padding-bottom:8px;">
                    <b>by Customer</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<select name="cmb_Customer" id="cmb_Customer" 
                        class="easyui-combobox" 
                        data-options="
                            valueField:'CustomerCode',
                            textField:'CustomerName',
                            url:'<?php echo base_url(); ?>custom/get_data/customer_with_rate'
                        " style="width:172px;" 
                        editable="false" 
                    >
                    </select>
                </td>
            </tr>
            <tr>
                <td style="padding-bottom:8px;">
                    <b>by Vendor</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<select name="cmb_Vendor" id="cmb_Vendor" 
                        class="easyui-combobox" 
                        data-options="
                            valueField:'VendorCode',
                            textField:'VendorName',
                            url:'<?php echo base_url(); ?>custom/get_data/vendor'
                        " style="width:172px;"
                        editable="false" 
                    >
                    </select>
                </td>
            </tr>
            <tr>
                <td style="padding-bottom:8px;">
                    <b>by Department</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<select name="cmb_Department" id="cmb_Department" 
                        class="easyui-combobox" 
                        data-options="
                            valueField:'DepartmentCode',
                            textField:'DepartmentName',
                            url:'<?php echo base_url(); ?>custom/get_data/department'
                        " style="width:172px;" 
                        editable="false" 
                    >
                    </select>
                </td>
            </tr>
            
            <tr>
                <td align="left" style="padding-bottom:8px;">
                    <b>by Type</b>
                </td>
            </tr>
           <!-------copy company dari sini------------------------------------------------------------------------->
          
            <tr>
                <td align="left">
                  <select name="cmb_menu" id="cmb_menu" 
                    class="easyui-combobox" 
                    style="width:174px;"
                    data-options="
                        value:'All',
                       
                        valueField:'Source',
                        textField:'Source',
                        url:'<?php echo base_url(); ?>list/account_history/cmb_menu'
                    "editable="false"
                >
                
                </select>
                </td>
            </tr>
            <!--ini separator--------------------------------------------->
			<tr><td colspan="2"><div class="tr-divider"></div></td></tr>
			<!--end-------------------------------------------------------->
			
			<!-----------------find by date------------------------------------------------------------------------->
			<tr>
				<td style="padding-bottom:8px;">
					<b>by Date</b>
					<input type="checkbox" name="chk_ByDateNew" value="1" id="chk_ByDateNew" style="float:right;" />
				</td>
			</tr>
			<tr>
				<td>
					From
					<span style="float:right;">
						<input name="txt_DateFrom" id="txt_DateFrom" type="text" class="easyui-datebox " style="width:100px;height:22px;" editable="false" disabled />
					</span>
				</td>
			</tr>
			<tr>
				<td>
					To
					<span style="float:right;">
						<input name="txt_DateTo" id="txt_DateTo" type="text" class="easyui-datebox " style="width:100px;height:22px;" editable="false" disabled />
					</span>
				</td>
			</tr>
			<!----------------------------------------------end-------------------------------------------------------------->
			
			<!---------------ini separator------------------------>
			<tr><td><div class="tr-divider"></div></td></tr>
			<!----------------end--------------------------------->
            
            <!--copy dari sini untuk button reset dan search-->
            <tr>
                <td height="38"><div style="float:right;"><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onClick="location.reload();" >Reset</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onClick="searching_data();" >Search</a></div></td>
            </tr>
            <!--end-------------------------->
            <!------------end-------------------------------------------------------------------------------->
            </table>
            </form>
        </div>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
    	<table id="grid" title="" iconCls="icon-save" rownumbers="true" pageSize="150" fitColumns="true" singleSelect="true" 
            data-options = "border:false,view:scrollview,autoRowheight:false" fit="true"
             url="<?php echo base_url(); ?><?php echo $menu_link; ?>/ajax" 
        >  
			<thead>
				<tr>
                	<th halign="center" data-options="align:'right', field:'TransLink',width:100" hidden>Trans Link</th>
					<th halign="center" data-options="field:'Date',width:100" formatter="formatDate" sortable="true">Date</th>
					<th halign="center" data-options="field:'Source',width:100" sortable="true">Source</th>
					<th halign="center" data-options="field:'SourceNo',width:150" sortable="true">Source No.</th>
					<th halign="center" data-options="field:'AccountNo',width:120" sortable="true">Account No.</th>
					<th halign="center" data-options="field:'AccountName',width:150" sortable="true">Account Name</th>
					<th halign="center" data-options="field:'Description',width:150">Description</th>
					<th halign="center" formatter="formatRp" data-options="align:'right', field:'Debet',width:100">Debet</th>
					<th halign="center" formatter="formatRp" data-options="align:'right', field:'Credit',width:100">Credit</th>
                    
				</tr>
			</thead>
		</table>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
   
	
	 $('#grid').datagrid({
		onDblClickRow:function(rowIndex, rowData){
			parent.tab_edit('Edit ' + rowData.Source, rowData.TransLink, 'icon-edit', 'edit', rowData.SourceNo);
		}
	});
	
	
	
   /*===chk_ByDateNew jangan lupa ganti ============*/
	$('#chk_ByDateNew').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', '');
		}
		
	});
	/*==================end=========================*/
	
  grid_navigation('History','<?php echo $menu_link; ?>');
});
	
/*
	jangan lupa ini ditaro dibawah di setaip list untuk search
	taro di luar documen ready jangan didalam doc ready
	jangan lupa hapus fungsi on key up di setiap find
	jangan lupa cek id gridnya
	ini contoh untuk master by company
	created by : fachri 
*/
function searching_data(){
	searchParameter = {};
	/*
		disini masing masing form list berbeda cek find diatas bisa by name by code
	*/
	searchParameter['txt_IDNumber'] = $('#txt_IDNumber').val();
	searchParameter['txt_Description'] = $('#txt_Description').val();
	//-----------------end--------------------------------------------------------
	
	/*
		disini hanya ada dua search, pakai company atau branch
	*/
	
	if($('#txt_DateFrom').length > 0){
		searchParameter['txt_DateFrom'] = $('#txt_DateFrom').datebox('getValue');
		searchParameter['txt_DateTo']	= $('#txt_DateTo').datebox('getValue');
	}
			
	searchParameter['cmb_AccountType'] 	= $('#cmb_AccountType').combobox('getValue');
	searchParameter['cmb_Customer'] 	= $('#cmb_Customer').combobox('getValue');
	searchParameter['cmb_Vendor'] 		= $('#cmb_Vendor').combobox('getValue');
	searchParameter['cmb_Department'] 	= $('#cmb_Department').combobox('getValue');
	searchParameter['cmb_menu'] 		= $('#cmb_menu').combobox('getValue');
	
	$('#grid').datagrid('load',{
		param: searchParameter
	});
			
}
//------------------end--------------------------------------
</script>