<!---- 
    Author 	: Ladur
    Tanggal : 12-08-2014	
    Revisi 	:
-->
<div class="easyui-layout" data-options="fit:true,border:false">
<form id="fm_sales_quotaion" name="fm_sales_quotaion" method="post">
	<input type="hidden" name="detail" id="detail"/>
	<!-- top view-->
	<div id="form-header" data-options="region:'north',border:false" >
		 <div id="form-header-wrapper">
				<table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
					<tr>
						<td align="left" valign="middle">
							<a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="">New</a>
							<input type="checkbox" name="chk_status" id="chk_status" />
							Pembatalan Transaksi
						</td>							
						<td height="25" align="right" valign="middle">								
							<span class="form-title"><?=$menu_label?></span>
						</td>
					</tr>
				</table>		     	
		 </div>			
	</div>
	<!-- end top view -->	
	<!-- center view -->
	<div id="form-body" data-options="region:'center',border:false">
		<div id="form-wrapper" class="easyui-panel"  style="width:1180%;height:548px;padding:5px;">			
			<table cellpadding="0" cellspacing="0" width="100%" border="0">
				<tr>
					<td width="50%" align="left" valign="top">
						<table cellpadding="0" cellspacing="1" width="100%" height="100%" border="0">
							<tr>
							  <td height="10" colspan="3" align="left" valign="middle">
								<span style="color:#000;font-weight:bold;margin-right:15px;">Customer</span>
								<select class="easyui-combogrid" id="cmb_customer" name="cmb_customer" required="required" style="width:200px; height:20px;" data-options="
								panelWidth: 300,
								idField: 'CustomerCode',
								textField: 'CustomerName',
								url: '<?php echo base_url(); ?>custom/get_data/customer',
								method: 'get',
								columns: [[
								{field:'CustomerCode',title:'Customer Code',width:110},
								{field:'CustomerName',title:'Customer Name',width:190}
								]],
								fitColumns: true
								">
								</select>									  
								<input type="checkbox" name="chk_taxtable" id="chk_taxtable" onclick="hideppn()">Taxtable 
							   </td>
							</tr>
							<tr>
								<td height="10" width="75" align="left" valign="top">
									<strong>Billing Address :</strong>
								</td>
								<td width="75" align="left" valign="top">
									<strong>Shipping Address :</strong>
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td height="50" align="left" valign="top">
									<textarea name="txa_address" id="txa_address" cols="30" rows="4" style="margin-left:-1px;resize:none;"></textarea>
								</td>
								<td align="left" valign="top">
									<textarea name="txa_ship_to" id="txa_ship_to" cols="30" rows="4" style="resize:none;"></textarea>
								</td>
								<td>&nbsp;</td>
							</tr>								
						</table>
					</td>
					<td align="right" valign="top">
						<table cellpadding="0" cellspacing="1" width="205" height="100%" border="0">
							<tr>
							  <td height="19" align="center" valign="middle" bgcolor="#333399"><span style="color:#fff;">Cust. PO No.</span></td>
							  <td align="center" valign="middle" bgcolor="#333399"><span style="color:#fff;">Cust. PO. Date</span></td>
							</tr>
							<tr>
								<td height="20" width="100" align="center" valign="middle"><input type="text" name="txt_po_no" id="txt_po_no" class="easyui-validatebox textbox" style="width:120px;height:18px" required="required"  /></td>
								<td width="100" align="center" valign="middle"><input name="txt_po_date" id="txt_po_date" type="text" class="easyui-datebox" style="width:122px;height:20px" required="required" /></td>
							</tr>
							<tr>
							  <td height="19" align="center" valign="middle" bgcolor="#333399"><span style="color:#fff;">SQ No.</span></td>
							  <td align="center" valign="middle" bgcolor="#333399"><span style="color:#fff;">SQ. Date</span></td>
							</tr>
							<tr>
								<td height="20" width="100" align="center" valign="middle"><input type="text" name="txt_sq_no" id="txt_sq_no" class="easyui-validatebox textbox" style="width:120px;height:18px" required="required" /></td>
								<td width="100" align="center" valign="middle"><input name="txt_sq_date" id="txt_sq_date" type="text" class="easyui-datebox" style="width:122px;height:20px" required="required" /></td>
							</tr>								
							<tr>
							  <td height="20" colspan="2" align="right" valign="top"><span style="font-size:12px; font-weight:normal;">Salesman</span>&nbsp;&nbsp;									    
								<select class="easyui-combogrid" id="cmb_salesman" name="cmb_salesman" required="required" style="width:172px; height:20px;" data-options="
								panelWidth: 300,
								idField: 'EmployeeCode',
								textField: 'EmployeeName',
								url: '<?php echo base_url(); ?>custom/get_data/sales',
								method: 'get',
								columns: [[
								{field:'EmployeeCode',title:'Employee Code',width:110},
								{field:'EmployeeName',title:'Employee Name',width:190}
								]],
								fitColumns: true
								">
								</select>
							  </td>
							</tr>
							<tr>
								<td colspan="2" align="left" valign="top"></td>
							</tr>												
						</table>
					</td>
					</td>
				</tr>
			</table>
			<!--Datagrid-->
			<div class="easyui-tabs" style="height:auto; margin-top:5px" data-options="tabHeight:18">
				<div id="tab_general" title="Items">
					<table id="dg_item" class="easyui-edatagrid"
					 toolbar="#toolbar" idField="id"
					 rownumbers="true" fitColumns="true" singleSelect="true" style="height:304px;">
						<thead>
							<tr>
								<th width="50" halign='center' field="ItemCode" editor="{type:'item',options:{required:true}}">Item</th>
								<th width="50" halign='center' field="Description" editor="description">Item Description</th>
								<th width="50" halign='center' field="ItemQty" editor="{type:'numberbox',options:{required:true}}">Qty</th>
								<th width="50" halign='center' field="ItemUnit" editor="unit" data-options="halign:'center'">Item Unit</th>
								<th width="50" halign='center' field="ItemPrice" editor="price" data-options="halign:'right'">Unit Price</th>
								<th width="50" halign='center' field="ItemDiscPcnt" editor="{type:'numberbox'}">Disc %</th>
								<th width="50" halign='center' field="ItemDiscount" editor="{type:'numberbox'}">Discount</th>
								<th width="75" halign='center' field="ItemAmount" editor="{type:'numberbox',options:{required:true}}">Amount</th>	
								<th width="75" halign='center' field="ItemSN" editor="{type:'text',options:{required:true}}">SN</th>			
							</tr>
						</thead>
					</table>
					<div id="toolbar">
						<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg_item').edatagrid('addRow')">New</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg_item').edatagrid('destroyRow')">Delete</a>						
						<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="javascript:$('#dg_item').edatagrid('cancelRow')">Cancel</a>
					</div>
				</div>					
			</div>
			<div style="margin-top:5px;">
				<table cellpadding="0" cellspacing="1" width="100%" height="100%" border="0">
					<tr>
						<td width="88" rowspan="4" valign="top" style="padding">Description </td>
						<td width="374" rowspan="4" valign="top"><textarea name="txa_description" cols="50" rows="4" class="textbox" style="resize:none;"></textarea></td>
						<td width="301" height="23" align="right" valign="top"><strong>Sub Total :</strong></td>
						<td width="144" align="right" valign="top"><strong><span id="sub_total">0</span></strong></td>
					</tr>
					<tr>
						<td height="20" align="right" valign="top">Discount : <input name="txt_disc_persent" type="text" id="txt_disc_persent" style="width:30px;"/></td>
						<td align="right" valign="top">%=<input type="text" name="txt_disc_value" id="txt_disc_value" value="0" style="text-align:right"/></td>
					</tr>
					<tr>
					  <td height="20" align="right" valign="top"><span class="disableme" style="display:none" >PPN 10%&nbsp;</span></td>
					  <td align="right" valign="top"><input type="text" name="txt_ppn_value3" id="txt_ppn_value3" value="0" class="disableme"  style="text-align:right;display:none"/></td>
					</tr>
					<tr>
						<td height="20" align="right" valign="top"><strong>Total Invoice :</strong></td>
						<td align="right" valign="top"><strong><span id="total_order">0</span></strong></td>
					</tr>
				</table>
			</div>			
		</div>
		<div id="form-footer">
			 <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>
			 <a href="javascript:void(0)" id="save_button" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="">Save</a> 								
			 <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-print" onclick="">Preview & Print</a>   
			 <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="">Cancel</a>	
		</div>		
	</div>
</form>
</div>
<script>
	$('#cmb_customer').combogrid({
		onSelect:function(rowIndex, rowData){
			$('#txa_address').val(rowData.CustomerAddress );			
  		}
		
	});
</script>

<?php $this->load->view('v_popup_item'); ?>

<script type="text/javascript">
	$("#save_button").click(function() { 
			$('#dg_item').edatagrid('saveRow');		
			var i=$('#dg_item').datagrid('getRows');
			var detail = JSON.stringify(i);
			$("#detail").val(detail);
			save_data('<?php echo $menu_link?>','#fm_sales_quotaion');								
	});
</script>

<script>
	//function show hide ppn
	function hideppn(){
		if($('#chk_taxtable').is(':checked')){
			$('.disableme').css('display','');
			$('#txt_ppn_value3').val('0');
		}
		else{
			$('.disableme').css('display','none');
		}
	}
	
</script>