<%@ 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.drivingSchool.*" %>
<%@ 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>
<script language="javascript">
  
 	function checkMonth(oFormName, sV, sUrl) {
 		oFormName.selectWeek.value = sV;
 		oFormName.action = sUrl;
 		oFormName.target = "_self";
 		oFormName.submit();
 	} 

</script>
</head>
<%
	//查询时间段
	//科目顺序
	String sSubjectOrder = SzConvert.strWriteData(request.getParameter("subjectOrder"));	 //科目
	
	//科目信息
	Subject subjectClass = new Subject();
	
	String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
	String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));
	//教练
	int iSelectCoach = SzConvert.toInt(request.getParameter("selectCoach"));
	String selectWeek = SzConvert.toZeroStr(request.getParameter("selectWeek"));
	//获取选择的部门信息
	String BMID = SzConvert.toZeroStr(request.getParameter("BMID"));
	String BMMC = SzConvert.strWriteData(request.getParameter("BMMC"));
	//学号
	String XH = SzConvert.strWriteData(request.getParameter("XH"));
	//流水号
	String LSH = SzConvert.strWriteData(request.getParameter("LSH"));
	//条件sCond
	StringBuffer sCond = new StringBuffer("");
	//如果开始时间和结束时间都为空，就默认为当前月
	Date currentDate = null;
	if (sSearchBegin.equals("")) {
		currentDate = SzDateHelp.getDate();
	} else {
		currentDate = SzDateHelp.stringToDate(sSearchBegin);
	}
	if (selectWeek.equals("0")) {
		currentDate = SzDateHelp.getDate();
	} else if (selectWeek.equals("-1")) {
		//上一周
		currentDate = SzDateHelp.dayBefore(currentDate, 7);
	} else if (selectWeek.equals("1")) {
		//下一周
		currentDate = SzDateHelp.dayAfter(currentDate, 7);
	}
	Date dSearchBegin = SzDateHelp.getFirstDateWeek(currentDate);
	Date dSearchEnd = SzDateHelp.getLastDateWeek(currentDate);
	sSearchBegin = SzDateHelp.dateToYMD(dSearchBegin);
	sSearchEnd = SzDateHelp.dateToYMD(dSearchEnd);
	String strDate = SzDateHelp.dateToYMD(currentDate);
	
   // sSearchBegin = SzDateHelp.dateToYMD(SzDateHelp.getFirstDateWeek(selDate));
   // sSearchEnd = SzDateHelp.dateToYMD(SzDateHelp.getFirstDateNextWeek(selDate));
	//查询的结束时间
	String searchEnd = SzDateHelp.dateToYMD(SzDateHelp.nextDay(SzDateHelp.stringToDate(sSearchEnd)));
	//查询条件
	sCond.append(" AND XXMC24>='");
	sCond.append(sSearchBegin);
	sCond.append("' AND XXMC24<'");
	sCond.append(searchEnd);
	sCond.append("'");
	
	//
	Student student = new Student();
	//取得分点招收的人数
	Map mapFenDianStudentDay = student.getStudentCountByDay(sCond.toString());
	//获取学员信息
	ArrayList<String[]> fendianList = student.getFenDianList("");
	int iSize = fendianList.size();
	//学员
	String[] fendianInfo = null;

	String weekName[] = {"周日","周一","周二","周三","周四","周五","周六"};
	Date date = null;
	ArrayList list = null;
%>	
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td>  
<!--      学号<input type="text" name="XH" class="txtClassSearch" value="<%=XH %>">-->
<!--      流水号<input type="text" name="LSH" class="txtClassSearch" value="<%=LSH %>">   	-->
  	<input type="hidden" name="txtShijianduan" value="">
  	<input type="hidden" name="txtDate" value="">     
  	<input type="hidden" name="selectWeek" value="<%=selectWeek%>">
	 	<input type="button" value="上周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '-1', 'statStudentOfWeek.jsp');">
	 	<input type="button" value="本周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '0', 'statStudentOfWeek.jsp');">
    <input type="button" value="下周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '1', 'statStudentOfWeek.jsp');">
      开始<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>" readonly>
      结束<input type="text" name="txtSearchEnd" class="txtClassSearch" value="<%=sSearchEnd%>" readonly>
      <%=SzPageHelp.button("btnClass", "查询", "javascript:FormSubmit(formBar,'statStudentOfWeek.jsp');", "btnSearch")%>
    </td>
  </tr>
  </form>
</table>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formUpdate" method="post">
  <input type="hidden" name="OPERATOR" value="add"> 
  <input type="hidden" name="SzDLXM" value="<%=sDLXM_SESSION %>">
  <input type="hidden" name="SzDLID" value="<%=iDLID_SESSION %>">
  <input type="hidden" name="SzBMMC" value="<%=sBMMC_SESSION %>">
  <input type="hidden" name="SzBMID" value="<%=iBMID_SESSION %>">
  <input type="hidden" name="XH" value="<%=XH %>">
  <input type="hidden" name="LSH" value="<%=LSH %>">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">
  <input type="hidden" name="txtShijianduan" value="">
  <input type="hidden" name="txtDate" value="">
  <input type="hidden" name="selectWeek" value="<%=selectWeek%>">
  <!-- 用于存放临时的选择值 -->
  <input type="hidden" name="tempMC" value=""> 
  <input type="hidden" name="tempID" value=""> 
  
  <tr class="trClassTitle">
  	<td width="150">分点名称</td>
		<%
			int i = 0;
			for (date = dSearchBegin; date.before(SzDateHelp.dayAfter(dSearchEnd, 1)); date = SzDateHelp.dayAfter(date, 1)) {
				out.println("<td>");
				out.println(weekName[date.getDay()]);
				out.println("(" + SzDateHelp.dateToYMD(date).substring(8) + "号)");
				out.println("</td>");
				i++;
			}
		%>
	<td>合计</td>
  </tr>
  <%
		//ToSetUpCourse toSetUpCourse = new ToSetUpCourse();
		Iterator iterFendian = fendianList.iterator();
		String strFendian[] = null;
		strDate = "";
		int sumStudent[] = new int[i];
		while (iterFendian.hasNext()) {
			strFendian = (String[])iterFendian.next();
	%>
  <tr>
  	<td align="center"><%=strFendian[1] %></td>
		<%
			int j = 0,sum=0,iCount=0;
			for (date = dSearchBegin; date.before(SzDateHelp.dayAfter(dSearchEnd, 1)); date = SzDateHelp.dayAfter(date, 1)) {
				strDate = SzDateHelp.dateToYMD(date);
				//取得已排课
				String str[] = (String[])mapFenDianStudentDay.get(new String(strFendian[0] + ":" + strDate));
				iCount = str==null? 0:Integer.valueOf(str[1]);
				//out.println(new String(strFendian[0] + ":" + strDate));
				out.print("<td>");
				out.print(iCount);		
				out.println("</td>");
				sum += iCount;
				sumStudent[j] += iCount;
				j++;
			}
			out.print("<td>");
			out.print(sum);		
			out.println("</td>");
		%>
	<%		
		}
  %>
    </tr>
    <tr>
  		<td align="center"><b>合计</b></td>
  		<%
  		int allSum = 0;
  		for (int m=0;m<i;m++){
  			out.print("<td>");
			out.print(sumStudent[m]);		
			out.println("</td>");
			allSum += sumStudent[m];
  		}
  		out.print("<td>");
		out.print(allSum);		
		out.println("</td>");
  		%>
  	<tr/>
  </form>
</table>





