<%@ 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>

</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("")){
		sSearchBegin = SzDateHelp.dateToYMD(SzDateHelp.getFirstDateMonth());
	}
	if (sSearchEnd.equals("")){
		sSearchEnd = SzDateHelp.dateToYMD(SzDateHelp.getLastDateMonth());
	}
	//查询的结束时间
	String searchEnd = SzDateHelp.dateToYMD(SzDateHelp.nextDay(SzDateHelp.stringToDate(sSearchEnd)));
	//查询条件 XXMC67:状态改变时间，XXMC24:报名时间
	sCond.append(" AND XXMC24>='");
	sCond.append(sSearchBegin);
	sCond.append("' AND XXMC24<'");
	sCond.append(searchEnd);
	sCond.append("'");
	
	//辅助类
	CommonMethods commonMethods = new CommonMethods();
	//
	Student student = new Student();
	//取得分点招收的各状态的人数
	Map mapStateStudent = student.getStudentCountByState(sCond.toString());
	Map mapFDStudent = student.getStudentCountByFD(sCond.toString());
	//获取学员信息
	ArrayList<String[]> fendianList = student.getFenDianList("");
	int iSize = fendianList.size();
	//学员
	String[] fendianInfo = null;
	
	String stateName[] = {"在学","暂停","休学(长时间不来)","失踪","领证","退学"};
	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="txtDate" value="">     
<!--  	<input type="hidden" name="selectWeek" value="<%=selectWeek%>">-->
<!--	 	<input type="button" value="上周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '-1', 'statStudentOfState.jsp');">-->
<!--	 	<input type="button" value="本周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '0', 'statStudentOfState.jsp');">-->
<!--    <input type="button" value="下周" class="btnClassShort" OnClick="javascript:checkMonth(formBar, '1', 'statStudentOfState.jsp');">-->
      开始<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>" readonly>
      <%=SzPageHelp.calendar2Select("../../","formBar.txtSearchBegin")%>
      结束<input type="text" name="txtSearchEnd" class="txtClassSearch" value="<%=sSearchEnd%>" readonly>
      <%=SzPageHelp.calendar2Select("../../","formBar.txtSearchEnd")%>
      <%=SzPageHelp.button("btnClass", "查询", "javascript:FormSubmit(formBar,'statStudentOfState.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>
		<%
			
			for (int i = 0;i<stateName.length;i++) {
				out.println("<td colspan=\"2\">");
				out.println(stateName[i].startsWith("休学")? "休学":stateName[i]);
				out.println("</td>");
			}
		%>
<!--	<td>合计</td>-->
  </tr>
  <%
		//ToSetUpCourse toSetUpCourse = new ToSetUpCourse();
		Iterator iterFendian = fendianList.iterator();
		String strFendian[] = null;
		String strFD[] = null;
		int sumStudent[] = new int[stateName.length];
		int allSum = 0;
		int fdSum = 0;
		while (iterFendian.hasNext()) {
			strFendian = (String[])iterFendian.next();
			strFD = (String[])mapFDStudent.get(strFendian[0]);
			
			fdSum = strFD==null? 0:Integer.valueOf(strFD[1]);
			allSum += fdSum;
	%>
  <tr>
  	<td align="center"><%=strFendian[1] %></td>
		<%
			int j = 0,sum=0,iCount=0;
			for (int i = 0;i<stateName.length;i++) {
				//取得已排课
				String str[] = (String[])mapStateStudent.get(new String(strFendian[0] + ":" + stateName[i]));
				iCount = str==null? 0:Integer.valueOf(str[1]);
				//out.println(new String(strFendian[0] + ":" + strDate));
				out.print("<td align=\"center\">");
				out.print(iCount);		
				out.println("</td>");
				out.print("<td align=\"center\">");
				out.print(fdSum==0? 0:commonMethods.toDouble2(iCount*100.0/fdSum));		
				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>
  		<%
  		for (int m=0;m<stateName.length;m++){
  			out.print("<td align=\"center\">");
			out.print(sumStudent[m]);		
			out.println("</td>");
			out.print("<td align=\"center\">");
			out.print(allSum==0? 0:commonMethods.toDouble2(sumStudent[m]*100.0/allSum));		
			out.println("%</td>");
  		}
  		//out.print("<td>");
		//out.print(allSum);		
		//out.println("</td>");
  		%>
  	<tr/>
  </form>
</table>

<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame("../../"));
%>


