<!--
Author 		  : Tagor
Last update   : 23/7/2014
Desc          : view for list - customers
-->
<?php
		//---------Untuk privellege jika dia ada tombol save----------
			if($group_user->AddPrivillage == 1){
				$cek_autority_add  = "";
			}
			else{
				$cek_autority_add 	= "disabled";
			}
			
			if($group_user->EditPrivillage == 1){
				$cek_autority_edit	 = "";
			}
			else{
				$cek_autority_edit 	= "disabled";
			}
			
			if($group_user->DeletePrivillage == 1){
				$cek_autority_delete  = "";
			}
			else{
				$cek_autority_delete 	= "disabled";
			}
			//-------------end----------------------------
?>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="height:30px" id="button-top">
        
    </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" id="tab_transstatus">
            <tr>
                <td width="190" align="left" style="padding-bottom:8px;">
                    <b>Find</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_CustomerCode" name="txt_CustomerCode" placeholder="< Customer No. >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;" >
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_CustomerName" name="txt_CustomerName" placeholder="< Customer Name >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;" >
                </td>
            </tr>
            <tr><td><div class="tr-divider"></div></td></tr>
           
            <tr>
                <td align="left" style="padding-bottom:8px;">
                    <b>by Company</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                  <select name="cmb_company" id="cmb_company" 
                    class="easyui-combobox" 
                    style="width:174px;"
                    data-options="
                        value:'<?php echo $this->session->userdata('company');?>',
                       
                        valueField:'CompanyCode',
                        textField:'CompanyName',
                        url:'<?php echo base_url(); ?>custom/get_data/company_find_master',
                        onSelect: function(rec){
                            var url = '<?php echo base_url(); ?>custom/get_data/branch_by_company_new/'+rec.CompanyCode;
                                $('#cmb_branch').combobox('reload', url);
                                $('#cmb_branch').combobox('setValue', '');
                            }
                    "editable="false"
                >
                
                </select>
                                
                  
                </td>
            </tr>
            
            <tr>
                <td align="left" style="padding-bottom:8px;">
                    <b>by Branch/Depo</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                   <select name="cmb_branch" id="cmb_branch" 
                        class="easyui-combobox" 
                        style="width:174px;"  
                        data-options="
                            value :'<?php echo $this->session->userdata('branch');?>',
                            valueField:'BranchCode', 
                            textField:'BranchName', 
                            url:'<?php echo base_url(); ?>custom/get_data/branch_by_company_new/<?php echo $this->session->userdata('company');?>'
                        " editable="false" 
                    >
                    
                    </select>
                </td>
            </tr>
            
            <tr>
                <td align="left" style="padding-bottom:8px;">
                    <b>by Currencies</b>
                </td>
            </tr>
            <tr>
                <td align="left">
                	<select name="cmb_CurrencyCode" id="cmb_CurrencyCode" 
                    class="easyui-combobox" 
                    style="width:174px;" 
                    data-options="
                        valueField:'CurrencyCode', 
                        textField:'CurrencyName', 
                        url:'<?php echo base_url(); ?>custom/get_data/currency', 
                        
                    " editable="false" 
                    >
					</select>
                </td>
            </tr>
            
            <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
            
            
            </table>
            </form>
        </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" mode="remote"
            fitColumns="true" remoteSort="false" 
            url="<?=base_url($menu_link.'/ajax')?>" 
            style="width:auto;height:560px" 
            data-options = "border:false,view:scrollview,autoRowheight:false"
        > 
        
            <thead>
            <tr>
                <th field="TransNumber" width="150" align="left" halign="center" sortable="true">Customer No.</th>
                <th field="CustomerName" width="220" align="left" halign="center" sortable="true">Customer Name</th>
                <th field="PhoneNumber" width="80" align="right" halign="center">Phone</th>
                <th field="ContactPerson" width="170" align="left" halign="center" hidden>Contact</th>
                <th field="CityName" width="170" align="left" halign="center" >City Name</th>
                <th field="TermDesc" width="170" align="left" halign="center" >Terms</th>
                <th field="OutStanding" width="120" align="right" halign="center" sortable="true" formatter="formatRp" hidden>Balance</th>
                <th field="CurrencyName" width="100" align="center" halign="center" sortable="true">Currency</th>
                <th field="TransStatus" width="100" align="center" halign="center" sortable="true" hidden>Status</th>
                <th field="BranchCode" width="100" align="center" halign="center" sortable="true" hidden>Branch Code</th>
            </tr>
            </thead>
        </table>
        <!--
        <form id="cust_print" name="cust_print" method="post">
			<input type="hidden" id="detail" name="detail" />
		</form>
        -->
    </div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	var status_privelage_delete = '<?php echo $group_user->DeletePrivillage;?>';
	var status_privelage_edit 	= '<?php echo $group_user->EditPrivillage;?>';
	var status_privelage_add    = '<?= $group_user->AddPrivillage;?>';

    list_master_datagrid('customer','<?=$menu_link;?>','Customers',status_privelage_edit,status_privelage_delete,status_privelage_add);
	
});
	
/*
	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
	created by : fachri 
*/
function searching_data(){
		if($('#cmb_branch').combobox('getValue') == ""){
			$.messager.alert('Info','Branch tidak boleh kosong, silahkan pilih');
		}
		else{
			var txt_CustomerCode 		= $('#txt_CustomerCode').val();
			var txt_CustomerName 		= $('#txt_CustomerName').val();
			
			var cmb_branch 			= $('#cmb_branch').combobox('getValue');
			var cmb_company 		= $('#cmb_company').combobox('getValue');
			var cmb_CurrencyCode 	= $('#cmb_CurrencyCode').combobox('getValue');
			
			var chk_status = new Array();
			$.each($('input[name="chk_TransStatus"]:checked'),function(){
				chk_status.push($(this).val());
			});
			
			$('#grid').datagrid('load',{
				CustomerCode 	: txt_CustomerCode,
				CustomerName 	: txt_CustomerName,
				TransStatus 	: chk_status,
				CompanyCode 	: cmb_company,
				BranchCode 		: cmb_branch,
				CurrencyCode	: cmb_CurrencyCode
			});	
		}
}
//------------------end--------------------------------------
</script>