<!--
Author      : Herpan / 22/7/2014 / view for list approval
Revisi      : Ferry
Revisi      : Fachri
-->

<div class="easyui-layout" data-options="fit:true">
	 <div data-options="region:'north',border:false" style="height:30px">
        <div style="padding:2px">
            <a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="$('#grid').datagrid('reload',{});">Refresh</a>
        </div>
    </div>
     <div id="west-panel" data-options="region:'west',split:true,border:true" title="Filter" style="width:190px;background-color:#CCCCFF;">
        
       <br />

        <div 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 style="padding-bottom:8px;">
                    <b>Find</b>
                </td>
            </tr>
            <tr>
                <td>
                    <input id="txt_IDNumber" name="txt_IDNumber"  placeholder="< Transaction. No. >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC">
                </td>
            </tr>
            <tr>
                <td>
                    <input id="txt_Description" name="txt_Description"  placeholder="< Description >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC">
                </td>
            </tr>
            <tr><td><div class="tr-divider"></div></td></tr>
            <!-------copy company dari sini------------------------------------------------------------------------->
            <tr>
                <td align="left" style="padding-bottom:8px;">
                    <b>by Menu Transaction</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                  <select name="cmb_menu" id="cmb_menu" 
                    class="easyui-combobox" 
                    style="width:174px;"
                    data-options="
                        value:'All',
                       
                        valueField:'TransType',
                        textField:'TransMenu',
                        url:'<?php echo base_url(); ?>list/approval/cmb_approval',
                        onSelect: function(rec){
                       		if((rec.TransType == 'Items')){
                            	$.messager.alert('Informasi','Maaf untuk transaksi Items silahkan approve di List->Items->Items Product','info');
                            }
                            else if(rec.TransType == 'Fixed Assets'){
                            	$.messager.alert('Informasi','Maaf untuk transaksi Fixed Assets silahkan approve di List->Fixed Assets->Fixed Assets Type','info');
                            }
                        }
                    "editable="false"
                >
                
                </select>
                </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-------------------------->
            </table>
            </form>
        </div>
    </div>
    </div>
    

     <div data-options="region:'center',border:false,iconCls:'icon-ok'">	
        <table id="grid"
        	title="" iconCls="icon-edit" 
            singleSelect="true" rowNumbers="true" 
            pageSize="150" 
            fitColumns="true" remoteSort="false" 
            url="<?=base_url('list/approval/ajax')?>" 
            style="width:auto;height:560px" 
            data-options = "border:false,view:scrollview,autoRowheight:false"
        > 
            <thead>
                <tr>
                	
                    <th field="BranchName" width="180" halign="center" sortable="true">Branch Name</th>
                    
                    <th field="TransNo" width="200" halign="center" sortable="true">Trans. No</th>
                    <th field="TransDate" width="100" halign="center" align='center' formatter="formatDate" sortable="true">Trans. Date</th>
                    <th field="Description" width="265" halign="center">Description</th>
                    <th field="CreatedBy" width="200" halign="center" sortable="true">Created By</th>
                    <th field="CreatedAt" width="200" halign="center" formatter="formatDate" sortable="true">Created At</th>
                    <th field="TransType" width="200" halign="center" sortable="true">Transaction Type</th>
                    <th field="TransStatus" width="200" halign="center" sortable="true">Status</th>
                </tr>
            </thead>
        </table>
    </div>				
</div>

<script type="text/javascript">    
$(document).ready(function(){
	/*Fungsi filtering*/
	$('#chk_filter_by_created_date').click(function(){
		if($(this).is(':checked')){
			$('#filter_by_created').show();
		}	
		else{
			$('#filter_by_created').hide(); 	
		}

		load_option($("input:radio[name=rdo_transaction_type]:checked").val());
	});

	$('#grid').datagrid({
		onDblClickRow:function(index,value){
			parent.tab_edit('Edit '+value.TransType+'', value.TransLink, 'icon-edit', 'edit', $('#grid').datagrid('getSelected').TransNo);	
		}
	});
});	
	
	/*
	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
	*/
	searchParameter['cmb_menu'] = $('#cmb_menu').combobox('getValue');
	
	$('#grid').datagrid('load',{
		param: searchParameter
	});
			
}
//------------------end--------------------------------------
</script>