<!--
Author 		  	: Fachri
Last update   	: 08/12/2014
Desc          	: view for export import transaction
Revision		: 1) Hasan | 03/02/2015 | Design UI
-->
<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" data-options="plain:true,iconCls:'icon-preference'" onclick="">Preferences</a>-->
            <?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="openDialogImportFile()" <?php echo $cek_autority;?>>Import</a>						
            <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onClick="$('#tt').datagrid('reload')">Refresh</a>
        </div>
    </div>
    	
    <div id="west-panel" data-options="region:'west',split:true" style="width:190px;;background-color:#CCCCFF;padding:2px;" title="Filter">
        <!-- Filter by transaction type -->
        <div class="easyui-panel" data-options="fit:true">
            <ul id="tree_data_source" class="easyui-tree">
                <li>
                    <span>&nbsp;Transaction Type</span>
                    <ul>									
                        <li>
                            <span>Group Of Sales</span>
                            <ul>	
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="sq"   onclick="search_import_type()"/>Sales Quotation</span></li>										
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="so"   onclick="search_import_type()"/>Sales Order</span></li>
                                <!--<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="do"   onclick="search_import_type()"/>Delivery Order</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="si"   onclick="search_import_type()"/>Sales Invoice</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="sr"   onclick="search_import_type()"/>Sales Return</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="srec" onclick="search_import_type()"/>Sales Receipt</span></li>-->
                            </ul>
                        </li>
                        <li>
                            <span>Group Of Purchases</span>
                            <ul>	
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="preq" onclick="search_import_type()"/>Purchase Requisition</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="po"   onclick="search_import_type()"/>Purchase Order</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="ri"   onclick="search_import_type()"/>Receive Item Outstanding</span></li>	
                                <!--<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="ri"   onclick="search_import_type()"/>Receive Item</span></li>												
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="pi"   onclick="search_import_type()"/>Purchase Invoice</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="pr"   onclick="search_import_type()"/>Purchase Return</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="ppay" onclick="search_import_type()"/>Purchase Payment</span></li>-->
                            </ul>
                        </li> 
                        <li>
                            <span>Group Of Items</span>
                            <ul>	
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Item_no"   onclick="search_import_type()"/>Item Master</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Item_noninventories"    onclick="search_import_type()"/>Item Expense</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Item_inventories"   onclick="search_import_type()"/>Item Inventories</span></li>
                                
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Fix_asset" onclick="search_import_type()"/>Fixed Asset</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Cust"      onclick="search_import_type()"/>Customer</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Vendor"    onclick="search_import_type()"/>Vendor</span></li>
                            </ul>
                        </li> 
                        <li>
                            <span>Group Of AR & AP</span>
                            <ul>	
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Ar_transaction"   onclick="search_import_type()"/>AR Transaction</span></li>
                                <li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="Ap_transaction"   onclick="search_import_type()"/>AP Transaction</span></li>
                            </ul>
                        </li> 
                    </ul>
                </li>
            </ul>
        </div>
        <!--//End Filter by transaction type //-->
    </div>
        
    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
        <table id="tt" class="easyui-datagrid" 
            url="<?=base_url()?>file/import_transaction/ajax" title="" 
            iconCls="icon-save" rowNumbers="true" 
            pageSize="50" 
            singleSelect="true" 
            style="width:auto;height:560%;" 
        >
            <thead>
            <tr>
                <!--<th width="170" halign="center" align="left" field="SourceNumber">Source No</th>-->
                <th width="90" halign="center" align="center" field="LastEdited" formatter="formatDate">Import Date</th>
                <th width="378" halign="center" align="left" field="TransType">Transaction Type</th>
                <th width="150" halign="center" align="center" field="DataType">Data Type</th>
                <th width="150" halign="center" align="center" field="ImportStatus">Status</th>
                <th width="150" halign="center" align="center" field="EmployeeName">Employee Name</th>
                <th width="180" halign="center" align="center" field="DepartmentName">Department Name</th>
                
                <th width="150" halign="center" align="left" field="ImportNumber" hidden='true'>Import Id</th>
                <th width="150" halign="center" align="left" field="ImportTransID" hidden='true'>ImportTransID</th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<!-- Dialog Import-->
<div id="dialog-import" class="easyui-dialog" style="width:370px;height:140;padding:10px 20px" closed="true" buttons="#dialog-buttons-group" data-options="modal:true">
	<form id="form_import_transaction" action="<?=base_url()?>file/import_transaction/insert" method="POST" enctype="multipart/form-data">
		<div class="fitem">
			<fieldset style="border:1px solid #CCC;">
				<legend>File Location</legend>
				    <input type="hidden" id="transaction_type" name="transaction_type"  />
					<input type="file" class="easyui-filebox" id="uploadfile" name="uploadfile" style="width:100%" />
                    <input name="txt_databaselocation" type="text" id="txt_databaselocation" size="20" style="display:none"/>
			</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" id="ok_button" onclick="save_import();" <?php echo $cek_autority;?>>Simpan</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" id="close_button" onClick="close_dialog();">Batal</a>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$('#tt').datagrid({
        onDblClickRow:function(){	
		var selected = $('#tt').datagrid('getSelected');
			
			parent.tab_edit('Detail Import Transaction', 'file/import_transaction/', 'icon-edit', 'edit', selected.ImportTransID);
			
			//if(selected.TransType == "Item"){
//				parent.tab_edit('Edit Item', 'list/items/', 'icon-edit', 'edit', selected.SourceNumber);
//			}
//			else if(selected.TransType == "Customer"){
//				parent.tab_edit('Edit Customer', 'list/customers/', 'icon-edit', 'edit', selected.SourceNumber);
//			}
//			else if(selected.TransType == "Vendors"){
//				parent.tab_edit('Edit Vendor', 'list/vendors/', 'icon-edit', 'edit', selected.SourceNumber);
//			}
		
		}
    });
});

	
function save_import() {
	var type_transaction = $('#rdo_transaction_type:checked').val();
	$('#transaction_type').val(type_transaction); 
	$('#loading_img').toggle();
	$('#id_span').toggle();
	//$('#close_button').linkbutton('disable', true);
	$('#ok_button').linkbutton('disable', true);
	import_data('<?php echo $menu_link ?>/insert','#form_import_transaction','dialog-import');
} 

function close_dialog(){
	location.reload();
	modal_close('dialog-import');
}

function modal_open_imp(title, divid){
	 $('#'+divid).dialog('open').dialog('setTitle',title);
}

function openDialogImportFile(){
    modal_open_imp('Import Transaction','dialog-import');    
    $('#loading_img').css({display:"none"});
    $('#id_span').css({display:"none"});
    $('#ok_button').linkbutton('enable', true);
}
</script>