<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.tool.SzDateHelp"%>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ page import="net.sz600.database.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ include file="/sessionInfo.jsp"%>

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../../../share/js/commonTool.js"></script>
</head>
<%
	
  //查询时间段
  String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
  String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
  if (sSearchBegin.equals("")) {
    sSearchBegin = SzDateHelp.getDateStr();
  }

  SzDataReader szDataReader = new SzDataReader();
  String sql = " SELECT XXMC2 FROM BD_ZULIN_CHANPIN GROUP by XXMC2 ";
  int iColumnCount = 1;
  int iMapKeyIndex = 0;
  ArrayList list = szDataReader.readInfo(sql, iColumnCount);
  //总数
  sql = " SELECT XXMC2,COUNT(*) FROM BD_ZULIN_CHANPIN GROUP by XXMC2 ";
  iColumnCount = 2;
  iMapKeyIndex = 0;
  Map map1 = szDataReader.readInfoMap(sql, iColumnCount, iMapKeyIndex);

  //当前已出租数量
  sql = " SELECT XXMC2,COUNT(*) FROM BD_ZULIN_CHUZU WHERE XXMC2<>'' AND (XXMC7='已出租') GROUP BY XXMC2 ";
  iColumnCount = 2;
  iMapKeyIndex = 0;
  Map map2 = szDataReader.readInfoMap(sql, iColumnCount, iMapKeyIndex);

  //到期可回收的数
  sql = " SELECT XXMC2,COUNT(*) FROM BD_ZULIN_CHUZU WHERE XXMC5<>'' AND XXMC5<='" + sSearchBegin + "' AND (XXMC7='已出租' OR XXMC7='已预定') GROUP BY XXMC2 ";
  iColumnCount = 2;
  iMapKeyIndex = 0;
  Map map3 = szDataReader.readInfoMap(sql, iColumnCount, iMapKeyIndex);

  //到期被预定数量
  sql = " SELECT XXMC2,COUNT(*) FROM BD_ZULIN_CHUZU WHERE XXMC4<>'' AND XXMC4<='" + sSearchBegin + "' AND XXMC5>='" + sSearchBegin + "' AND (XXMC7='已预定') GROUP BY XXMC2 ";
  iColumnCount = 2;
  iMapKeyIndex = 0;
  Map map4 = szDataReader.readInfoMap(sql, iColumnCount, iMapKeyIndex);
	
%>
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td>
      型号<input type="text" name="txtSearch" class="txtClassSearch" value="<%=sSearch%>">
      开始<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>">
      <%=SzPageHelp.calendar2Select("../../../","formBar.txtSearchBegin")%>
      <%=SzPageHelp.button("查询", "javascript:FormSubmit(formBar,'stat.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">
  <tr class="trClassTitle_c">
    <td>产品型号</td>
    <td>总数</td>
    <td>当前正出租数量</td>
    <td>到期可回收数量</td>
    <td>到期被预定数量</td>
    <td>到期库存</td>
  </tr>
  <%
    String str[] = null;
    String sType = "";
    int i1 = 0;
    int i2 = 0;
    int i3 = 0;
    int i4 = 0;
    int i5 = 0;

    int i1_total = 0;
    int i2_total = 0;
    int i3_total = 0;
    int i4_total = 0;
    int i5_total = 0;

    for( int i=0; i<list.size(); i++) {
	str = (String[])list.get(i);	
	sType = str[0];
	if (!sSearch.equals("") && sType.indexOf(sSearch) == -1) {
	  continue;
	}

        str = (String[])map1.get(new String(sType));
	if (str != null) {
	  i1 = SzConvert.toInt(str[1]);
	} else {
	  i1 = 0;
	}

        str = (String[])map2.get(new String(sType));
	if (str != null) {
	  i2 = SzConvert.toInt(str[1]);
	} else {
	  i2 = 0;
	}

        str = (String[])map3.get(new String(sType));
	if (str != null) {
	  i3 = SzConvert.toInt(str[1]);
	} else {
	  i3 = 0;
	}

        str = (String[])map4.get(new String(sType));
	if (str != null) {
	  i4 = SzConvert.toInt(str[1]);
	} else {
	  i4 = 0;
	}
	i5 = i1 - i2 + i3 - i4;

	i1_total += i1;
	i2_total += i2;
	i3_total += i3;
	i4_total += i4;
	i5_total += i5;

  %>
  <tr>
    <td align="center"><%=sType%></td>
    <td align="center"><%=i1%></td>
    <td align="center"><%=i2%></td>
    <td align="center"><%=i3%></td>
    <td align="center"><%=i4%></td>
    <td align="center"><%=i5%></td>
  </tr>  
  <%
    }
  %>
  <tr class="trClassTitle_c">
    <td align="center">合计</td>
    <td align="center"><%=i1_total%></td>
    <td align="center"><%=i2_total%></td>
    <td align="center"><%=i3_total%></td>
    <td align="center"><%=i4_total%></td>
    <td align="center"><%=i5_total%></td>
  </tr>
  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame("../../../"));
%>
