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

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../../../share/js/commonTool.js"></script>
</head>
<%
	String curDate = SzDateHelp.getDateStr();
	String YEAR = SzConvert.toZeroStr(request.getParameter("YEAR"));
	
	if (YEAR.equals("0")||!YEAR.matches("20\\d{2}")){
		YEAR = curDate.substring(0,4);
	}
	String sSearchBegin = YEAR+"-01-01";
	String sSearchEnd = (Integer.valueOf(YEAR)+1)+"-01-01";
	
	String month[] = new String[]{"01","02","03","04","05","06","07","08","09","10","11","12"};
	
	//获取对象信息
	Customer customer = new Customer();
	
	//StringBuffer sCond = new StringBuffer("1=1");
	String searchStr = customer.getStat_SQL("","","KHXXMC18", sSearchBegin, sSearchEnd, "");
	
    Map KHMap = customer.getStat_KH_year_Map(searchStr);
    searchStr = customer.getStat_SQL("","","HTXXMC14", sSearchBegin, sSearchEnd, "");
    Map HTMap = customer.getStat_HT_year_Map(searchStr);
    searchStr = customer.getStat_SQL("","","BJXXMC13", sSearchBegin, sSearchEnd, "");
    Map BJMap = customer.getStat_BJ_year_Map(searchStr);
    searchStr = customer.getStat_SQL("","","XXMC3", sSearchBegin, sSearchEnd, "");
    Map DTMap = customer.getStat_DT_year_Map(searchStr);

%>
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <tr>
  	<td valign="bottom" style="padding-bottom: 5px;padding-top: 5px;" align="center">
  		<h4 style="display: inline;"><%=YEAR %>年业务数据统计</h4>
  	</td>
  </tr>
  <tr>
  	<td>
  		 年份<input style="CURSOR: hand;" title="格式：YYYY" type="text" name="YEAR" class="txtClassSearch" value="<%=YEAR%>">
  		<%=SzPageHelp.button("查询", "javascript:FormSubmit(formBar,'stat_customer_year.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>
    <td>报价数量</td>
    <td>动态数量</td>
  </tr>
<%

	double count = 0;
	double sum = 0;
	Object[] value = null;
	Object[] sumValue = new Object[7];
	int valueSize = 0;
	Object obj = null;
	for(int i =0;i<12;i++){
		if (curDate.substring(0,7).equals(YEAR+"-"+month[i])){
			out.println("<tr align=\"center\" style=\"background-color: #fff0b3;\">");
		} else {
			out.println("<tr align=\"center\">");
		}
		out.println("<td>"+ month[i] +"月&nbsp;</td>");
		
		value = (Object[])KHMap.get(YEAR+"-"+month[i]);
		count = value != null? Double.valueOf(value[0].toString()):0;
		out.println("<td>"+ (int)count +"&nbsp;</td>");
		obj = sumValue[0];
		count = count + (obj != null? Double.valueOf(obj.toString()):0);
		sumValue[0] = count;
		
		value = (Object[])HTMap.get(YEAR+"-"+month[i]);
		for (int j =0;j<4;j++){
			count = value != null? Double.valueOf(value[j].toString()):0.00;
			if (j == 0){
				out.println("<td>"+ (int)count +"&nbsp;</td>");
			} else {
				out.println("<td>"+ SzConvert.formatFloat2Str(count) +"&nbsp;</td>");
			}
			obj = sumValue[j+1];
			count = count + (obj != null? Double.valueOf(obj.toString()):0.00);
			sumValue[j+1] = count;
		}
		
		value = (Object[])BJMap.get(YEAR+"-"+month[i]);
		count = value != null? Double.valueOf(value[0].toString()):0.00;
		out.println("<td>"+ (int)count +"&nbsp;</td>");
		obj = sumValue[5];
		count = count + (obj != null? Double.valueOf(obj.toString()):0.00);
		sumValue[5] = count;
		
		value = (Object[])DTMap.get(YEAR+"-"+month[i]);
		count = value != null? Double.valueOf(value[0].toString()):0.00;
		out.println("<td>"+ (int)count +"&nbsp;</td>");
		obj = sumValue[6];
		count = count + (obj != null? Double.valueOf(obj.toString()):0.00);
		sumValue[6] = count;
		
		out.println("</tr>");
	}
	
	
    
    out.println("<tr class=\"trClassTitle2\" align=\"center\">");
    out.println("<td style=\"color: red;\">合计</td>");
    for (int i = 0;i<7;i++){
    	obj = sumValue[i];
		count = obj != null? Double.valueOf(obj.toString()):0.00;
		if (i>1&&i<5){
			out.println("<td>"+ SzConvert.formatFloat2Str(count) +"&nbsp;</td>");
		} else {
			out.println("<td>"+ (int)count +"&nbsp;</td>");
		}
    }
    out.println("<tr>");
    KHMap = null;
    HTMap = null;
    BJMap = null;
    DTMap = null;
    
%>

  </form>
</table>

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

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