<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ page import="net.sz600.database.*" %>
<%@ page import="net.sz600.database.other.*" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ include file="/sessionInfoWeixin.jsp"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<%@ include file="/share/oa_app_title.jsp"%>
<link href="<%=strSkin_SESSION%>/css2007app.css" rel="stylesheet" type="text/css">
 <script type="text/javascript" src="<%=strLevel_SESSION%>share/js/commonTool.js"></script> 

<script language="javascript">
  function GoUrl(url, name) {  	
  	document.location.href = url + "?txtName2=" + encodeURIComponent(name);
  }
</script>
</head>
<%@ include file="/app/title.jsp"%>
<%
    //获取提交的参数
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sNumber = SzConvert.strWriteData(request.getParameter("txtNumber"));
    String sNumber2 = SzConvert.strWriteData(request.getParameter("txtNumber2"));
    String sName = SzConvert.strWriteData(request.getParameter("txtName"));
    
    String ProdBaseName = SzConvert.strWriteData(request.getParameter("ProdBaseName"));
    String ProdBaseName2 = SzConvert.toSpaceStr(request.getParameter("ProdBaseName2"));
    String ProductName = SzConvert.strWriteData(request.getParameter("ProductName"));
    String ProductName2 = SzConvert.toSpaceStr(request.getParameter("ProductName2"));
    String BillNo = SzConvert.strWriteData(request.getParameter("BillNo"));
    String BatchName = SzConvert.strWriteData(request.getParameter("BatchName"));
    String BatchName2 = SzConvert.toSpaceStr(request.getParameter("BatchName2"));
    String BillDate1 = SzConvert.strWriteData(request.getParameter("BillDate1"));
    String BillDate2 = SzConvert.strWriteData(request.getParameter("BillDate2"));    
    String sState = SzConvert.strWriteData(request.getParameter("txtState"));
    
    if (ProdBaseName.equals("")) {
    	ProdBaseName = ProdBaseName2;
    }
    if (BatchName.equals("")) {
    	BatchName = BatchName2;
    }
    if (ProductName.equals("")) {
    	ProductName = ProductName2;
    }    
    
    StringBuffer sbCond = new StringBuffer("A.ProdBaseId=B.ProdBaseId AND A.ProductId=C.ProductId AND A.BatchId=D.BatchId");

    if (!ProdBaseName.equals("")) {
    	sbCond.append(" AND B.ProdBaseName LIKE '%" + ProdBaseName + "%'");
    }    
    if (!ProductName.equals("")) {
    	sbCond.append(" AND C.ProductName LIKE '%" + ProductName + "%'");
    }
    if (!BillNo.equals("")) {
    	sbCond.append(" AND A.BillNo LIKE '%" + BillNo + "%'");
    }
    if (!BatchName.equals("")) {
    	sbCond.append(" AND D.BatchName LIKE '%" + BatchName + "%'");
    }
    if (!BillDate1.equals("")) {
    	sbCond.append(" AND A.BillDate >='" + BillDate1.replaceAll("-","") + "'");
    }
    if (!BillDate2.equals("")) {
    	sbCond.append(" AND A.BillDate <= '" + BillDate2.replaceAll("-","") + "'");
    }    
  
    
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
    	sSortField = "ProductId";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    }
    int iPageSize = SzProperties.I_PageSize;
    int iCurrentPage = 1;    
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }	  
    int iColumnCount = 8;
    String sTable = "X_ReviewRecordMaster A, X_ProdBaseInfoMaster B, X_WebProductInfo C, X_WebTraceInfo D";
	  String sField = "A.BillNo,A.BillDate,A.ProdBaseId,B.ProdBaseName,A.ProductId,C.ProductName,A.BatchId,D.BatchName";
	  String sCond = sbCond.toString();
	  
		SzDataReaderZs dr = new SzDataReaderZs();
	  
		ArrayList list = dr.readInfoArray(sTable, sField, sCond, sSortField, iSortOrder, iCurrentPage, iPageSize, iColumnCount);
	  SzPageInfo pageInfo = dr.getPageInfo();				
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    
    String s_id[] = {"","0","1","2","3","4"};
    String s_name[] = {"全部","未确认","确认","已取消","无效","退货"};
    

%>
<!-----上面的工具栏------>
<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td>
  <input type="hidden" name="page" value="<%=sPage%>"> 
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">      
	    基地名称<input type="text" name="ProdBaseName" value="<%=ProdBaseName%>" class="txtClass80">
	    单据编号<input type="text" name="BillNo" value="<%=BillNo%>" class="txtClass80">
	    产品名称<input type="text" name="ProductName" value="<%=ProductName%>" class="txtClass80">
	    批次<input type="text" name="BatchName" value="<%=BatchName%>" class="txtClass80">
	    日期从<input type="text" name="BillDate1" value="<%=BillDate1%>" class="txtClass80"><%=SzPageHelp.calendar2Select2("formBar.BillDate1")%>
	    到<input type="text" name="BillDate2" value="<%=BillDate2%>" class="txtClass80"><%=SzPageHelp.calendar2Select2("formBar.BillDate2")%>
      
	  <input type="button" name="btnOk" class="btnClass" value="确定" OnClick="javascript:FormSubmit(formBar, 'index.jsp');">


    </td>
  </tr>
  </form>  
</table>

<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">  
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">  
  <input type="hidden" name="txtNumber" value="<%=sNumber%>">
  <input type="hidden" name="txtNumber2" value="<%=sNumber2%>">
  <input type="hidden" name="txtName" value="<%=sName%>">
  <input type="hidden" name="txtState" value="<%=sState%>">
    <input type="hidden" name="ProdBaseName" value="<%=ProdBaseName%>">
    <input type="hidden" name="ProductName" value="<%=ProductName%>">
    <input type="hidden" name="BillNo" value="<%=BillNo%>">
    <input type="hidden" name="BatchName" value="<%=BatchName%>">
    <input type="hidden" name="BillDate1" value="<%=BillDate1%>">
    <input type="hidden" name="BillDate2" value="<%=BillDate2%>">    
  <tr class="trClassTitle">
    <td width="5"></td>

    <td><%=SzPageHelp.sortTitle("单据编号", "BillNo", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("单据日期", "BillDate", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("生产基地", "A.ProdBaseId", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("产品名称", "A.ProductId", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("批次", "BatchId", sSortField, iSortOrder)%></td>  
    <td>详情</td>
  </tr>
<%
		//A.BillNo,A.BillDate,A.ProdBaseId,B.ProdBaseName,A.ProductId,C.ProductName,A.BatchId,D.BatchName
	  Iterator iter = null;
    if (list != null) {
    	iter = list.iterator();
    }
		String str[] = null;
    while (iter != null && iter.hasNext()) {
    	str = (String[])iter.next();
      i++;
%>
  <tr  onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
  	<td align="center"><%=i%></td>
  	<td align="center"><a href="#" OnClick="GoUrl('../reviewrecorddetail/index.jsp','<%=str[0]%>');"><%=str[0]%></a></td>
    <td align="center"><%=str[1]%></td>
    <td align="center"><a href="#" OnClick="GoUrl('../prodbase/index.jsp','<%=str[3]%>');"> <%=str[3]%></a></td>
    <td align="center"><a href="#" OnClick="GoUrl('../webproduct/index.jsp','<%=str[5]%>');"><%=str[5]%></a></td>
    <td align="center"><a href="#" OnClick="GoUrl('../webtrace/index.jsp','<%=str[7]%>');"> <%=str[7]%></a></td>

    <td align="center">
    	<a href="javascript:FormSubmit(formPage,'../reviewrecorddetail/index.jsp?txtName2=<%=str[0]%>&txtSortField=');">详情</a>    	
    </td>
  </tr>
<%
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 7));
%>
  </form>
</table>

<!-----这里包含要提交的内容--->
<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">  
  <input type="hidden" name="txtNumber" value="<%=sNumber%>">
  <input type="hidden" name="txtNumber2" value="<%=sNumber2%>">
  <input type="hidden" name="txtName" value="<%=sName%>">
  <input type="hidden" name="txtState" value="<%=sState%>"> 
    <input type="hidden" name="ProdBaseName" value="<%=ProdBaseName%>">
    <input type="hidden" name="ProductName" value="<%=ProductName%>">
    <input type="hidden" name="BillNo" value="<%=BillNo%>">
    <input type="hidden" name="BatchName" value="<%=BatchName%>">
    <input type="hidden" name="BillDate1" value="<%=BillDate1%>">
    <input type="hidden" name="BillDate2" value="<%=BillDate2%>">     
  <tr>
    <td align="right">
      <%@ include file="/share/page/page_only_include.jsp"%>
    </td>
  </tr>
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post"> 
</form>
<script language="javascript">

</script>
<%
	out.println(SzPageHelp.calendarFrame2());
	out.println(SzPageHelp.calendar2Frame2());
%>
