<!--
Author 		  : Wahyu
Last update   : 10/09/2014
Desc          : view for import price list
-->

<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="padding:2px;">
        <?php
			//---------Untuk privellege jika dia ada tombol save----------
			if($group_user->AddPrivillage == 1){
				$cek_autority = "";
			}
			else{
				$cek_autority = "disabled";
			}
			//-------------end----------------------------
		 ?>	
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-import'" onClick="modal_open('Import Price HO','dialog-import-price');" <?php echo $cek_autority;?>>Import Harga Jual</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick=" $('#grid').datagrid('reload');">Refresh</a>
    </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"  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_ItemName" name="txt_ItemName" placeholder="< Description >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;">
                </td>
            </tr>
            <tr>
                <td align="left">
                	<input id="txt_BranchName" name="txt_BranchName" placeholder="< Branch 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 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>
            
<!--            
            copy dari sini untuk by status-------------------------------------------
            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="1" style="margin-left:0px;" checked /> Active
                </td>
            </tr>

            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="3" style="margin-left:0px;" /> Suspended
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                  <input type="checkbox" name="chk_TransStatus" value="4" style="margin-left:0px;"  /> Need App. Mgr.
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                  <input type="checkbox" name="chk_TransStatus" value="5" style="margin-left:0px;"  /> Need App. Dir.
                </td>
            </tr>
            <tr>
                <td width="283" align="left" colspan="2">
                    <input type="checkbox" name="chk_TransStatus" value="6" style="margin-left:0px;" /> App. Dir & Mgr
                </td>
            </tr>
            end------------------------------------------------------
            ----ini separator-
            <tr><td colspan="2"><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>
        </div>
    </div>
    
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
    	<table id="grid" class="easyui-datagrid" 
        	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:'ItemCode',width:150,halign:'center',align:'left'" sortable="true">Item Code</th>
                <th data-options="field:'ItemDesc',width:350,halign:'center',align:'left'" sortable="true">Description</th>
                <th data-options="field:'ItemUnit',width:80,halign:'center',align:'left'" sortable="true">Unit</th>
                <th data-options="field:'BranchName',width:170,halign:'center',align:'left'" sortable="true">Branch</th>
                <th data-options="field:'CurrencyCode',width:80,halign:'center',align:'left'" sortable="true">Currency</th>
                <th data-options="field:'ItemPrice',width:180,halign:'center',align:'right'" formatter="formatRp" sortable="true">Price</th>
               </tr>
            </thead>
        </table>
    </div>
</div>

<!-- Dialog import price HO -->
<div id="dialog-import-price" class="easyui-dialog" style="width:370px;height:150px;padding:10px 20px;" closed="true" buttons="#dialog-buttons-group" data-options="modal:true">
	<form id="form_import_price" method="post" enctype="multipart/form-data">
		<div class="fitem">
			<fieldset style="border:1px solid #CCC;">
				<legend>File Location</legend>
					<input type="file" name="uploadfile" id="uploadfile" style="width:100%">                    		
			</fieldset>	
		</div>
	</form>
        <center><img src='<?php echo base_url();?>assets/custom/img/c_loader.gif' id='loading_img' alt='loadingImg' style='display:none;' /></center>
        <center><span id='id_span'  style='display:none;'>Do not close the pop-up</span></center>
</div>

<!-- Dialog Button -->
<div id="dialog-buttons-group" style="border:none;">
	<?php
		//---------Untuk privellege jika dia ada tombol save----------
		if($group_user->SavePrivillage == 1){
			$cek_autority = "";
		}
		else{
			$cek_autority = "disabled";
		}
		//-------------end----------------------------
	?>	
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="save_import()" <?php echo $cek_autority;?>>Save</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:jQuery('#dialog-import-price').dialog('close')">Cancel</a>
</div>

<!-- Dialog import price Depo -->
<div id="dialog-import-price-depo" class="easyui-dialog" style="width:370px;height:150px;padding:10px 20px;" closed="true" buttons="#dialog-buttons-group-depo" data-options="modal:true">
	<form id="form_import_price-depo" method="post" enctype="multipart/form-data">
		<div class="fitem">
			<fieldset style="border:1px solid #CCC;">
				<legend>File Location</legend>
					<input type="file" name="uploadfile" id="uploadfile" style="width:100%">                    		
			</fieldset>	
		</div>
	</form>
</div>

<!-- Dialog Button -->
<div id="dialog-buttons-group-depo" style="border:none;">
	<a href="javascript:void(0)" class="easyui-linkbutton" id="ok_button" iconCls="icon-ok" onclick="import_data('<?php echo $menu_link ?>/import_depo','#form_import_price-depo','dialog-import-price-depo');">Save</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:jQuery('#dialog-import-price-depo').dialog('close');">Cancel</a>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$('#grid').datagrid({
		onDblClickRow:function(){
			parent.tab_edit('Edit Item Price', '<?=$menu_link?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').ItemCode);	
		}
	})
});
    	
function save_import() {
	$('#loading_img').show();
	$('#id_span').show();
	//$('#close_button').linkbutton('disable', true);
	$('#ok_button').linkbutton('disable', true);
	import_data('<?php echo $menu_link ?>/import_price_data','#form_import_price','dialog-import-price');
} 

function searching_data(){
		var txt_no 		= $('#txt_ItemName').val();
		var txt_desc 	= $('#txt_BranchName').val();
		
		
		
		$('#grid').datagrid('load',{
			ItemDesc 	: txt_no,
			BranchName 	: txt_desc
		});	
}
</script>