<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base target="_self">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" media="all"
 href="/jscalendar/calendar-blue.css" title="win2k-cold-1" />
<script type="text/javascript" src="${ctx}/jscalendar/calendar.js"></script>
<script type="text/javascript"
 src="${ctx}/jscalendar/lang/calendar-zh.js"></script>
<script type="text/javascript" src="${ctx}/jscalendar/calendar-setup.js"></script>
<script language="javascript" src="/inc/check.js"></script>
<script type="text/javascript" src="${ctx}/jscalendar/calendar-setup.js"></script>
<script type="text/javascript" src="${ctx}/jquery/date.js"></script>
<script language="vbScript" src="/inc/entertotab.vbs"></script>
<script type='text/javascript' src='/dwr/interface/JHProductTService.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<style type="text/css">
 input{
  width: 100px;
 }
</style>
<script language="javascript">
    function check() {
        if (!checkclient(0)) {
            return false;
        }
  return true;
    }
    function limitLength(obj, length) {        
        if(obj.value.length > length) {
         obj.value = obj.value.substr(0,length);
        }            
    }
    function add() {
     var a = window.showModalDialog('/customer/selectJHCustomerT.do',window,'');
     var id = document.getElementById("hid").value;
     if(id!=null && id!=0){
      dwr.engine.setAsync(false);//设置是否为异步
      JHProductTService.getById(id,function(data)//调用方法
      {
         if(data!=null)
       {
           //添加行
           var row=document.getElementById("num").value;
           var newtr=addproduct.insertRow();
           //添加列
           var count=newtr.insertCell();
           var code=newtr.insertCell();
           var name=newtr.insertCell();
           var guige=newtr.insertCell();
           var zhaiyao=newtr.insertCell();
           var jHUnitT=newtr.insertCell();
           var price=newtr.insertCell();
           var number=newtr.insertCell();
           var jine=newtr.insertCell();
           count.innerHTML="<input type='text' value='"+(Number(row)+1)+"' readonly='readonly'/>";
           code.innerHTML="<input type='text'  id='code"+row+"' value='"+data.code+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].code' readonly='readonly' />";
           name.innerHTML="<input type='text'  id='name"+row+"' value='"+data.name+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].name' readonly='readonly' />";
           guige.innerHTML="<input type='text'  id='guige"+row+"' value='"+data.guige+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].guige' readonly='readonly' />";
           zhaiyao.innerHTML="<input type='text'  id='zhaiyao"+row+"' value='"+data.zhaiyao+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].zhaiyao' readonly='readonly' />";
           jHUnitT.innerHTML="<select width='100px' id='jHUnitT"+row+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].jHUnitT.id'> <s:iterator value='list_JHUnitT' status='stauts'><option value='<s:property value='id'/>'>${unitname}</option></s:iterator></select>";
           price.innerHTML="<input type='text'  id='price"+row+"' value='"+data.price+"' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].price' readonly='readonly' />";
           number.innerHTML="<input type='text'  id='number"+row+"' value='1' onblur='change("+row+")' name='jhSalesorderT.jhSalesOrderDetailsT.jHProductSaleOrderT["+row+"].number'/>";
           jine.innerHTML="<input type='text'  id='jine"+row+"' value='"+data.price+"' name='jine"+row+"' readonly='readonly' />";
           
           document.getElementById("row").rowSpan=Number(row)+Number(2);
           document.getElementById("num").value = Number(row)+Number(1);
           var sel = document.getElementById("jHUnitT"+row);
           sel.value = data.JHUnitT.id;
    }
   });
     }
     document.getElementById("hid").value = 0;
    }
    function change(row){
     var price = document.getElementById("price"+row).value;
     var num = document.getElementById("number"+row).value
     document.getElementById("jine"+row).value = Number(price)*Number(num);
    }
</script>
<body>
<div id="x-box_table">

<div class="x-box-tl">
<div class="x-box-tr">
<div class="x-box-tc"></div>
</div>
</div>
<div class="x-box-ml">

<div class="x-box-mc">
<s:hidden name="hid" id="hid"></s:hidden>
<input type="hidden" id="num" name="num" value="0">
<fieldset><s:form name="jHCustomerTForm" id="jHCustomerTForm"
 action="saveSalesorderJHCustomerT.do" method="get" namespace="/customer"
 cssClass="x-form" onsubmit="return true;">
 <legend>添加销售订单</legend>customerid
 
 <table width="100%" border="0" cellspacing="1" cellpadding="0"
  class="dataTable" bgcolor="99BBE8" align="center">
  <tr>
   <td class="row0">购货单位</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="24" type="text" name="JhSalesorderT.JHCustomerT.unit"
    value="${jHCustomerT.unit}" id="JhSalesorderT.JHCustomerT.unit" readonly="readonly" nodeName="购货单位|_not"></DIV>
   </td>
   <td class="row0">联系人</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="24" type="text" name="JHSalesorderT.JHCustomerT.person" readonly="readonly"
    value="${jHCustomerT.person}" id="JHSalesorderT.JHCustomerT.person"></DIV>
   </td>
  </tr>
  <tr>
   <td class="row0">联系电话</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="20" type="text" name="JHSalesorderT.JHCustomerT.phone"
    value="${jHCustomerT.phone}" id="JHSalesorderT.JHCustomerT.phone" readonly="readonly"/></DIV>
   </td>
   <td class="row0">传真</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="20" type="text" name="JHSalesorderT.JHCustomerT.fax"
    value="${jHCustomerT.fax}" id="JHSalesorderT.JHCustomerT.fax" readonly="readonly"/>
   </DIV>
   </td>
  </tr>
  <tr>
   <td class="row0">电子邮件</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="24" type="text" name="JHSalesorderT.JHCustomerT.email"
    value="${jHCustomerT.email}" id="JHSalesorderT.JHCustomerT.email" readonly="readonly"></DIV>
   </td>
   <td class="row0">邮政编码</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="10" type="text" name="JHSalesorderT.JHCustomerT.postalcode"
    value="${jHCustomerT.postalcode}" id="JHSalesorderT.JHCustomerT.postalcode" readonly="readonly" onkeyup="value=value.replace(/[^0-9]/g,'');"></DIV>
   </td>
  </tr>
  <tr>
   <td class="row0">单位地址</td>
   <td class="row1" colspan="3">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input size="90"
    maxlength="50" type="text" name="JHSalesorderT.JHCustomerT.address"
    value="${jHCustomerT.address}" id="JHSalesorderT.JHCustomerT.address" readonly="readonly"></DIV>
   </td>
   
  </tr>
  <tr>
   <td class="row0">交货方式</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="10" type="text" name="JHSalesorderT.jiaohuotype"
    id="JHSalesorderT.jiaohuotype"></DIV>
   </td>
   <td class="row0">交货日期</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="20" type="text" name="JHSalesorderT.jiaohuotime" id="JHSalesorderT.jiaohuotime" readonly="readonly">
    <script type="text/javascript"> 
      Calendar.setup({
         inputField     :    "JHSalesorderT.jiaohuotime",   // id of the input field
         ifFormat       :    "%Y-%m-%d ",       // format of the input field
         showsTime      :    true,
         timeFormat     :    "24",
         singleClick    :    true
     });       
    </script>
   </DIV>
   </td>
  </tr>
  <tr>
   <td class="row0">付款方式</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="49" type="text" name="JHSalesorderT.fukuantype" id="JHSalesorderT.fukuantype"></DIV>
   </td>
   <td class="row0">收款时间</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="49" type="text" name="JHSalesorderT.shoukuantime" id="JHSalesorderT.shoukuantime" readonly="readonly">
    <script type="text/javascript"> 
      Calendar.setup({
         inputField     :    "JHSalesorderT.shoukuantime",   // id of the input field
         ifFormat       :    "%Y-%m-%d ",       // format of the input field
         showsTime      :    true,
         timeFormat     :    "24",
         singleClick    :    true
     });       
    </script>
   </DIV>
   </td>
  </tr>
  <tr>
   <td class="row0">经办人</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="49" type="text" name="JHSalesorderT.jingbanren" id="JHSalesorderT.jingbanren"></DIV>
   </td>
   <td class="row0">联系电话</td>
   <td class="row1">
   <DIV align="left">&nbsp;&nbsp;&nbsp;&nbsp; <input
    maxlength="20" type="text" name="JHSalesorderT.jbrphone" id="JHSalesorderT.jbrphone">
   </DIV>
   </td>
  </tr>
  <tr>
   <td colspan="10" class="row0">
    <table width="1000px" border="0" cellspacing="1" cellpadding="0"
  class="dataTable" bgcolor="99BBE8" align="center" id="addproduct" >
     <tr class="row1">
      <th width="10%" class="tableHeader" style="text-align: center;"><b>序号</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>编码</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>品名</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>规格</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>摘要</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>单位</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>单价</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>数量</b></th>
      <th width="10%" class="tableHeader" style="text-align: center;"><b>金额</b></th>
      <td rowspan="1" id="row" width="10%"><input type="button" onclick="add()" width="100%" height="100%" value="添加产品" /></td>
     </tr>   
    </table>
   </td>
  </tr>
  <tr class="row1">
   <td class="row0">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注</td>
   <td colspan="5"><textarea name="JHSalesorderT.beizhu" id="JHSalesorderT.beizhu"
    rows="8" cols="90" onkeyup="limitLength(this,499)" accesskey="500"></textarea><font
    color="blue">&nbsp;&nbsp;&nbsp;&nbsp;【最多500字】</font></td>
  </tr>  
  <tr>
   <td colspan="6" class="row1"><input type="submit"
   class="button" value="添加" onclick="check()" />&nbsp;&nbsp;<input
   type="button" class="button" value="返回" onclick="history.back();" /></td>    
  </tr>
 </table>
</s:form></fieldset>

</div>
</div>
</div>
</body>
</html>