<!--
Author 		  : Tagor
Last update   : 05/8/2014
Revision      : 1) Hasan | 11/02/2015 | Design UI
-->

<?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" id="new-linkbutton" data-options="plain:true,iconCls:'icon-add'" onclick="parent.tab_add('New Warehouse','<?php echo $menu_link?>', 'icon-add', 'add')">New</a>
			<a href="#" class="easyui-linkbutton" id="edit-linkbutton" data-options="plain:true,iconCls:'icon-edit'" onclick="parent.tab_edit('Edit Warehouse','<?php echo $menu_link?>', 'icon-edit','edit', $('#tt').datagrid('getSelected').WarehouseID)">Edit</a>
			<a href="#" class="easyui-linkbutton" id="suspend-linkbutton" data-options="plain:true,iconCls:'icon-remove'" onclick="suspend_data_new('L',1,'<?php echo $menu_link; ?>', $('#tt').datagrid('getSelected').WarehouseID,'#tt')">Suspend</a>
			<a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="tab_reload()">Refresh</a>
			<a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true,iconCls:'icon-print'" onclick="parent.tab_add('Print Warehouse','<?php echo $menu_link?>', 'preview', '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">
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td width="283" align="left" colspan="2" style="padding-bottom:8px;">
                    <b>Find</b>
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                	<input id="txt_warehouse_name" name="txt_warehouse_name"  placeholder="< Warehouse Name >" style="margin:2px 0px 3px;width:172px;height:20px;border:1px solid #CCC" onKeyup="search_warehouse()">
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                	<input id="txt_description" name="txt_description"  placeholder="< Description >" style="margin:2px 0px 3px;width:172px;height:20px;border:1px solid #CCC" onKeyup="search_warehouse()">
                </td>
            </tr>
            
            <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
            <tr>
                <td width="283" align="left" colspan="2" style="padding-bottom:8px;">
                    <b>Status</b>
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                	<input type="checkbox" name="TransStatus" value="0" onClick="search_warehouse()" checked/> Active
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                	<input type="checkbox" name="TransStatus" value="3" onClick="search_warehouse()" checked/> Suspended
                </td>
            </tr>
            </table>
        </div>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
        <table id="tt" class="easyui-datagrid" 
            title="" iconCls="icon-save" 
            rownumbers="true" pagination="true" 
            pageSize="20" singleSelect="true" 
            remoteSort="false" fitColumns="true"
            url="<?=base_url() . $menu_link?>/ajax" 
            style="width:auto;height:560%" 
        >
			<thead>
            <tr>
                <th data-options="field:'WarehouseID',width:10,halign:'center',align:'left'" hidden="true">Warehouse Code</th>
                <th data-options="field:'WarehouseName',width:250,halign:'center',align:'left'">Warehouse Name</th>
                <th data-options="field:'WarehouseDesc',width:400,halign:'center',align:'left'">Description</th>
                <th data-options="field:'ContactPerson',width:200,halign:'center',align:'left'">Contact Person</th>
                <th data-options="field:'SuspendStatus',width:130,halign:'center',align:'center'">Status</th>
            </tr>
			</thead>
		</table>
    </div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$('#tt').datagrid({
		onDblClickRow:function(){
			parent.tab_edit('Edit Warehouse', '<?=$menu_link?>', 'icon-edit', 'edit', $('#tt').datagrid('getSelected').WarehouseID);
		},
		onClickRow:function(index,value){
			if(value.SuspendStatus=='Suspended'){
				$('#suspend-linkbutton').linkbutton('disable');
				$('#edit-linkbutton').linkbutton('disable');
			}else{
				$('#suspend-linkbutton').linkbutton('enable');
				$('#edit-linkbutton').linkbutton('enable');
			}
		}
	});
});
</script>