<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
	<head>
	<base href="<%=basePath%>" />
	<sx:head extraLocales="en-us" />
		<title>订货单</title>
		<link rel="stylesheet" href="css/main.css" type="text/css" />
		<script language="javascript" src="script/main.js"></script>
<script type='text/javascript' src='dwr/interface/stockorderAction.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type="text/javascript">
	var textAmount;

	function init() {
		textAmount = document.getElementById("amount");

	}

	function out_amount() {
		var chk = false;
		var exp = /[^\d]/;
		if (!exp.test(textAmount.value) && textAmount.value > 0
				&& textAmount.value < 999) {

			show_message("msg_amount", "1", '输入正确!');
			chk = true;
		} else {
			show_message('msg_amount', '0', '进货数量必须输入大于零小于999的整型数字形式');

		}
		return chk;
	}
	function formSubmit() {
		var chk = false;
		var chkRetAmount = out_amount();
		var chkRetDate = out_pickerDate('p_date', 'msg_date', '日期不能为空!');
		var chkRetMerchandise = out_chkEmpty('merchandise', 'msg_merchandise',
				'商品不能为空!');
		var chkRetEmployee = out_chkEmpty('employee', 'msg_employee',
				'经手人不能为空!');
		var chkRetClient = out_chkEmpty('client', 'msg_client', '供应商不能为空!');
		if (chkRetAmount && chkRetEmployee && chkRetClient
				&& chkRetDate && chkRetMerchandise) {
			chk = true;
		}
		return chk;
	}
	dojo.event.topic.subscribe("/value", function(textEntered, date, widget) {

		out_pickerDate('p_date', 'msg_date', '日期不能为空!');

	});
	window.onload = init;
</script>
	<body>
	<s:form action="stockorderAction" method="post" theme="simple" onsubmit="return formSubmit();">
		<s:hidden name="stockorder.id" ></s:hidden>
	        <s:hidden name="stockorder.code"></s:hidden>
		<p></p>
		<p><font style="font-size: 10pt;">销售管理->订货单->修改</font></p>
		
		<p></p>
		<table border="0" cellpadding="1" cellspacing="1" width="95%">
			<tr>
				<td align="right" width="10%" nowrap="true">订货单编号</td>
				<td width="20%">
					<s:textfield name="stockorder.code"
				cssClass="TextInput" disabled="true"></s:textfield>
	      </td>				
				<td align="right" width="10%" nowrap="true">货物名称</td>
				<td width="20%">
						<s:select list="merchandises"
				name="stockorder.merchandise.id" listKey="id" listValue="name"
				theme="simple" emptyOption="true" onFocus="show_message('msg_merchandise','2','请选择货物名称!')"
				onBlur="out_chkEmpty('merchandise','msg_merchandise','货物名称不能为空!')"
				id="merchandise"></s:select>

			<DIV style="DISPLAY: show" id="msg_merchandise" class="box_div_right">&nbsp;</DIV>
	      </td>
				<td align="right" width="10%" nowrap="true">货物数量</td>
				<td width="20%">
						<s:textfield name="stockorder.merchandisenumber"
				cssClass="TextInput" id="amount"
				onFocus="show_message('msg_amount','2','请输入进货数量')"
				onBlur="out_amount()"></s:textfield>
			<DIV style="DISPLAY: show" id="msg_amount" class="box_div_right">&nbsp;</DIV>
	      </td>	      
	      <td width="10%">&nbsp;</td>     
			</tr>
			<tr>
				<td align="right" width="10%" nowrap="true">订货日期</td>
				<td width="20%">
					<sx:datetimepicker label="" name="stockorder.orderdate" displayFormat="yyyy-MM-dd" language="en-us" type="date"  id="p_date" required="true"
				valueNotifyTopics="/value" />
			<DIV style="DISPLAY: show" id="msg_date" class="box_div_right">&nbsp;</DIV>
			
	      </td>
				<td align="right" width="10%">销售商</td>
				<td width="20%">
					<s:select list="clients"
				name="stockorder.client.id" listKey="id" listValue="name"
				theme="simple" emptyOption="true" id="client"
				onFocus="show_message('msg_client','2','请选择供应商名称!')"
				onBlur="out_chkEmpty('client','msg_client','供应商不能为空!')"></s:select>
			<DIV style="DISPLAY: show" id="msg_client" class="box_div_right">&nbsp;</DIV>
	      </td>		      
				<td align="right" width="10%" nowrap="true">经手人</td>
				<td width="20%">
					<s:select list="employees" name="stockorder.employee.id"
				listKey="id" listValue="name" theme="simple" emptyOption="true"  id="employee"
				onFocus="show_message('msg_employee','2','请选择经手人名称!')"
				onBlur="out_chkEmpty('employee','msg_employee','经手人不能为空!')"></s:select>
			<DIV style="DISPLAY: show" id="msg_employee" class="box_div_right">&nbsp;</DIV>
	      </td>	      
	      <td width="40%" colspan="5">&nbsp;</td>     
			</tr>			
		</table>

		<p></p>
		<div style="margin-left: 30px; margin-right: 0px">
			<table border="0" cellpadding="0" cellspacing="0"  width="95%">
				<tr>
		    	<td width="10%">
		    			<s:submit value="保存" cssClass="BtnAction"
				method="updateStockorder" ></s:submit>
		    	</td>
		    	<td width="10%">
		    			<input type="button" class="BtnAction" value="返回" onClick="history.go(-1);">
		    	
		    	</td>
		    	<td width="80%">&nbsp;</td>   	
		  	</tr>
			</table>
		</div>
		</s:form>
	</body>
</html>