<!--
Author 		  : Herpan
Last update   : 22/7/2014
Desc          : view for export import transaction
-->
<div id="tab_exim" class="easyui-tabs" data-options="tabHeight:20">
	<!-- // TAB EXPORT DATA // -->
	<div id="tab_exim_data" title="Export Data" style="height:1000px;">	
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'west',split:true" style="width:210px;background-color:#CCCCFF;"" title="Filter">
				<!--// Filter by created date //-->
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					    <td align="left" style="height:23px"><input type="checkbox" name="chk_filter_by_created_date" id="chk_filter_by_created_date"/></td>
					    <td colspan="2" align="left" style="height:23px">Filter by Created Date</td>
			      </tr>
				  <tr>
					<td width="20" style="height:23px">&nbsp;</td>
					<td colspan="2" rowspan="2" style="height:23px">
					   <div id="filter_by_created" style="display:none;">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
							  <tr>
								<td width="4%" style="height:23px">From </td>
								<td width="96%"><input name="txt_created_date_form" id="txt_created_date_form" class="easyui-datebox" size="15px" /></td>
							  </tr>
							  <tr>
								<td style="height:23px">To </td>
								<td><input name="txt_created_date_to" id="txt_created_date_to" class="easyui-datebox" size="15px" /></td>
							  </tr>
							</table>
					   </div>
					</td>
				  </tr>
				  <tr>
					<td style="height:23px">&nbsp;</td>
				  </tr>
				</table>								
				<!--// End Filter by created date //-->
				<!--// Filter by source date //-->
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					    <td align="left" style="height:23px"><input type="checkbox" name="chk_filter_by_source_date" id="chk_filter_by_source_date"/></td>
					    <td colspan="2" align="left" style="height:23px">Filter by Source Date</td>
			      </tr>
				  <tr>
					<td width="20" style="height:23px">&nbsp;</td>
					<td colspan="2" rowspan="2" style="height:23px">
					   <div id="filter_by_source" style="display:none;">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
							  <tr>
								<td width="4%" style="height:23px">From </td>
								<td width="96%"><input name="txt_source_date_form" id="txt_source_date_form" class="easyui-datebox" size="15px" /></td>
							  </tr>
							  <tr>
								<td style="height:23px">To </td>
								<td><input name="txt_source_date_to" id="txt_source_date_to" class="easyui-datebox" size="15px" /></td>
							  </tr>
							</table>
					   </div>
					</td>
				  </tr>
				  <tr>
					<td style="height:23px">&nbsp;</td>
				  </tr>
				</table>		
				
				<span>&nbsp;Transaction Type</span>
				<div class="easyui-panel" style="height:380px;width:200px;margin-left:5px">
					<ul id="tree_data_source" class="easyui-tree">
						<li>
							<span>&nbsp;</span>
							<ul>									
								<li>
									<span>Group Of Sales</span>
									<ul>	
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="sq" />Sales Quotations</span></li>										
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="so" />Sales Order</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="do" />Delivery Order</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="si" />Sales Invoice</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="sr" />Sales Return</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="srec" />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" />Purchase Requisition</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="po" />Purchase Order</span></li>	
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="ri" />Receive Item</span></li>												
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="pi" />Purchase Invoice</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="pr" />Purchase Return</span></li>
										<li><span><input type="radio" name="rdo_transaction_type" id="rdo_transaction_type" value="ppay" />Purchase Payment</span></li>
									</ul>
								</li> 
							</ul>
						</li>
					</ul>
				</div>
				<!--//End Filter by transaction type //-->
			</div>
			<div data-options="region:'center'">
				<div id="toolbar">
					<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onClick="$('#tt').datagrid('reload')">Refresh</a>
					<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-preference'" onclick="">Preferences</a>
					<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-export'" onClick="modal_open_imp('Export Transaction','dialog-export');">Export</a>						
				</div>	
				<table id="tt" class="easyui-datagrid" url="<?php //echo site_url('file/import_transaction/ajax'); ?>?grid=true" title="" iconCls="icon-save" rownumbers="true" pagination="true" fitColumns="true" singleSelect="true" style="width:965%;height:555%;">
					<thead>
						<tr>
							<th width="100" align="left" field="SourceNumber">Source No</th>
							<th width="100" align="center" field="SourceDate">Source Date</th>
							<th width="150" align="left" field="TransType">Transaction Type</th>
							<th width="100" align="center" field="DataType">Data Type</th>
							<th width="100" align="center" field="ImportStatus">Status</th>
							<th width="100" align="center" field="LastUser">User</th>
						</tr>
					</thead>
				</table>
			</div>				
		</div>
	</div>
	<!--// END TAB EXPORT DATA //-->				
</div>

<!-- Dialog Export-->
<div id="dialog-export" class="easyui-dialog" style="width:400px; height:130px; padding: 10px" closed="true" buttons="#dialog-buttons-group" data-options="modal:true">
	<form id="form_export_transaction" action="<?php echo base_url(); ?>file/export_transaction/export_data" method="POST" enctype="multipart/form-data">
		<div class="fitem">
				<b>You sure will export data !</b>
				<input type="hidden" id="transaction_type" name="transaction_type" />   		
		</div>
	</form>
</div>

<!-- Dialog Button -->
<div id="dialog-buttons-group">
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="save_imp()">Simpan</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#dialog-export').dialog('close')">Batal</a>
</div>
<script type="text/javascript">
 function save_imp(){
	     var type_transaction = $('#rdo_transaction_type:checked').val();
        $('#transaction_type').val(type_transaction);
        $('#form_export_transaction').submit();
    }	
	
 function save_export() {
    var type_transaction = $('#rdo_transaction_type:checked').val();
        $('#transaction_type').val(type_transaction); 
		
	$('#form_export_transaction').form('submit',{	    
		onSubmit: function(){
			return $(this).form('validate');
		},
		success: function(result){
			var result = eval('('+result+')');
			if (result.status==true){
			    $('#dialog-export').dialog('close');
				
				$.messager.show({
					title: 'Succesfull',
					msg: result.message,
					style:{
							right:'',
							bottom:''
					}
				});
			} 
			else {
			    $('#dialog-export').dialog('close');				 
				$.messager.show({
					title: 'Failed',
					msg: result.message,
					style:{
							right:'',
							bottom:''
					}
				});
			}
		}
	});
} 

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