<%@ 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" %>
<%@ page import="net.sz600.assess.*" %>
<%@ include file="/sessionInfo.jsp"%>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007app.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../../share/js/commonTool.js"></script>
</head>
<%
    //获取提交的参数
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
		String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sNumber = SzConvert.strWriteData(request.getParameter("txtNumber"));
    String sName = SzConvert.strWriteData(request.getParameter("txtName"));
    String sState = SzConvert.strWriteData(request.getParameter("txtState"));

    StringBuffer sbCond = new StringBuffer("1=1");
    if (!sNumber.equals("")) {
    	sbCond.append(" AND order_sn LIKE '%" + sNumber + "%'");
    }
    if (!sName.equals("")) {
    	sbCond.append(" AND consignee LIKE '%" + sName + "%'");
    }    
    if (!sState.equals("")) {
    	sbCond.append(" AND order_status = " + sState + "");
    }   
    if (!sType.equals("0")) {
    	sbCond.append(" AND user_id = " + sType + "");
    }    
    
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
    	sSortField = "order_id";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    }
    int iPageSize = SzProperties.I_PageSize;
    int iCurrentPage = 1;    
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }	  
    int iColumnCount = 9;
    String sTable = "ecs_order_info";
    String sField = "order_id,order_sn,from_unixtime(add_time),consignee,mobile,address,goods_amount,order_amount,order_status";
	  String sCond = sbCond.toString();
	  
		SzDataReaderEcs dr = new SzDataReaderEcs();
	  
		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="type" value="<%=sType%>">  
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">  
      
      订单号<input type="text" name="txtNumber" value="<%=sNumber%>" class="txtClass80">
	    收货人<input type="text" name="txtName" value="<%=sName%>" class="txtClass80">
      订单状态 
     <%
     out.println(SzPageHelp.radio("txtState", s_id, s_name, sState));
     %>
	  <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="type" value="<%=sType%>">  
  <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="txtName" value="<%=sName%>">
  <input type="hidden" name="txtState" value="<%=sState%>">
  <tr class="trClassTitle">
    <td width="5"></td>

    <td><%=SzPageHelp.sortTitle("订单号", "order_sn", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("下单时间", "add_time", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("收货人", "consignee", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("总金额", "goods_amount", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("应付金额", "order_amount", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle("定单状态", "order_status", sSortField, iSortOrder)%></td>
    <td>详情</td>
  </tr>
<%
	//order_sn,add_time,consignee,mobile,address,goods_amount,order_amount,order_status
	  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"><%=str[1]%></td>
    <td align="center"><%=str[2]%></td>
    <td align="LEFT"><%=str[3]%>[TEL:<%=str[4]%>]<BR><%=str[5]%> </td>
    <td align="center"><%=str[6]%></td>
    <td align="center"><%=str[7]%></td>
    <td align="center"><%=s_name[SzConvert.toInt(str[8]) + 1]%></td>
    <td align="center">
    	<a href="javascript:FormSubmit(formPage,'detail.jsp?KEY=<%=str[0]%>');">详情</a>
    </td>
  </tr>
<%
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 8));
%>
  </form>
</table>

<!-----这里包含要提交的内容--->
<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="type" value="<%=sType%>">    
  <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="txtName" value="<%=sName%>">
  <input type="hidden" name="txtState" value="<%=sState%>">
  <tr>
    <td align="right">
      <%@ include file="/share/page/page_only_include.jsp"%>
    </td>
  </tr>
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" 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="txtName" value="<%=sName%>">
  <input type="hidden" name="txtState" value="<%=sState%>"> 
</form>
<script language="javascript">

</script>

