<!--
Author		: Herpan / 15-08-2014
Revision	: Ferry / 12-01-2014
Revision	: Dhidhik / 30-01-2016
-->

	<?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:3px 3px 28px 3px;" id="button-top">
        
    </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" id="tab_transstatus">
                <tr>
                    <td style="padding-bottom:8px;"><b>Find</b></td>
                </tr>
                
                <tr>
                    <td>
                        <input id="txt_IDNumber" name="txt_IDNumber" placeholder="< PReq. No. >" style="margin:2px 0px 3px;width:100%;height:18px;border:1px solid #CCC;">
                    </td>
                </tr>
                
                <tr>
                    <td>
                        <input id="txt_Description" name="txt_Description" placeholder="< Description >" style="margin:2px 0px 3px;width:100%;height:18px;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 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>
				<!------------end-------------------------------------------------------------------------------->
				
				<!-------copy branch dari sini------------------------------------------------------------------------->
				<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>
				<!------------end-------------------------------------------------------------------------------->
				
				<tr><td colspan="2"><div class="tr-divider"></div></td></tr>
				
				
            </table>
        </form>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
       
		<!-- gaya table baru di grid -->
		
		<table id="grid"
        	title="" iconCls="icon-edit" 
            singleSelect="true" rowNumbers="true" 
            pageSize="150" 
            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 data-options="field:'BranchName',width:170,align:'left',halign:'center'" sortable="true" hidden>Branch</th>
                    <th data-options="field:'TransNumber',width:150,align:'left',halign:'center'" sortable="true"><?php echo label_grid('no_trans');?></th>
                    <th data-options="field:'DepartmentName',width:150,align:'left',halign:'center'" sortable="true" >Department</th>
                    
                    <th data-options="field:'PReqDate',width:80,align:'center',halign:'center'" formatter="formatDate" sortable="true"><?php echo label_grid('date');?></th>
                    <th data-options="field:'PReqDesc',width:245,align:'left',halign:'center'"><?php echo label_grid('desc');?></th>
                    <th data-options="field:'CreatedBy',width:245,align:'left',halign:'center'"><?php echo label_grid('created');?></th>
                    <th data-options="field:'TransStatus',width:120,align:'center',halign:'center'" sortable="true" hidden>Status</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

<script type="text/javascript">
    
//>>>>>>>>>>>>>>>>>>> TAMBAHAN DHIDHIK 30/01/2016 <<<<<<<<<<<<<<<<<<<<<<<<<<<//
    function setArrayPageStart(){ // nama function biar tetap seperti ini    , isi VALUE nya aja yang disesuaikan page masing-masing 
        //====== reset keytab ================//
        isArrayTabIndex     = -1;//default, jgn diganti valuenya
        isFormIdDatagrid    = ""; //nama id tag form yg ngapit grid yg mana grid-nya ada action editable
        isIdNameDatagrid    = "grid";//nama id grid
        isFirstFieldName    = "BranchName"; //nama field pertama yg ga hidden pada grid, atau saat editable yang akan di-focus-kan
        isArrayTab          = ["txt_IDNumber","btnSearch"]; // urutan destiny tab, isinya value menunjukkan [idAwal, idAkhir]
        //======END reset keytab ==============//
    }
//>>>>>>>>>>>>>>>>>>> TAMBAHAN DHIDHIK 30/01/2016 <<<<<<<<<<<<<<<<<<<<<<<<<<<//
    
    $(document).ready(function(){
        setArrayPageStart();//tambahan dhidhik 30/01/2016
		
		var status_privelage_delete = '<?= $group_user->DeletePrivillage;?>';
    	var status_privelage_edit   = '<?= $group_user->EditPrivillage;?>';
    	var status_privelage_add    = '<?= $group_user->AddPrivillage;?>';

    	/*========================== call function list view datagrid ==============================*/
    	list_datagrid('PReq','Need App. Mgr.','<?=$menu_link?>','Purchase Requisition',status_privelage_edit,status_privelage_delete,status_privelage_add);
    	/*=============================== end ======================================================*/
	
	});
	
        function editToNewTab(){
            if(mustBeChooseRowDatagrid('grid')){//<<<=== edit dhidhik 11 feb 2016
                parent.tab_edit('Edit Purchase Requisition', '<?=$menu_link?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').PReqNumber);
            }
        }
        
	function suspend(){
            if(mustBeChooseRowDatagrid('grid')){//<<<=== edit dhidhik 11 feb 2016
		var url             = '<?= base_url();?>custom/custom/checking_suspend';
		suspend_data_new_check('L',1,'<?=$menu_link?>',$('#grid').datagrid('getSelected').PReqNumber,'#grid', url);
            }
	}
</script>