<%@ 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 sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
	String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));
	//教练
	String JL = SzConvert.strWriteData(request.getParameter("JL"));
	//条件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)));
	
	
	if (!JL.equals("")){
		sCond.append(" AND XXMC2 like '%");
		sCond.append(JL);
		sCond.append("%'");
	}
	//out.println(sCond.toString());
	//
	Coach coach = new Coach();
	StatHelp statHelp = new StatHelp();
	//取得通过的情况统计：key(教练ID-科目，数组（及格，不及格，缺考）)
	Exam exam = new Exam();
	Map map = exam.statExamPass(sSearchBegin,searchEnd);
	//获取学员信息
	String[] field = new String[]{"XXMC1","XXMC2"};
	ArrayList<String[]> coachList = coach.getCoachList(field,sCond.toString());
	int iSize = coachList.size();
	
	//学员
	String[] coachInfo = null;
	//学员状态
	//String[] stateName = new String[]{"在学","暂停","休学(长时间不来)"};
	String[] stateName = new String[]{"在学","暂停"};  //2012-07-25修改
%>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td>  
      教练<input type="text" name="JL" class="txtClassSearch" value="<%=JL %>">
      开始<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,'statStudentCountOfCoach.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="JL" value="<%=JL %>">
  
  <tr class="trClassTitle">
  	<td width="50" rowspan="2">序号</td>
  	<td width="150"  rowspan="2">教练</td>
	<td colspan="3">场考(次数)</td>
	<td colspan="3">长训(次数)</td>
	<td colspan="3">路考(次数)</td>
	<td rowspan="2">合计</td>
  </tr>
  <tr class="trClassTitle">

	<td>通过</td>
	<td>未通过</td>
	<td>合计</td>

	<td>通过</td>
	<td>未通过</td>
	<td>合计</td>

	<td>通过</td>
	<td>未通过</td>
	<td>合计</td>
  </tr>
  <%
		//ToSetUpCourse toSetUpCourse = new ToSetUpCourse();
		Iterator iterStat = coachList.iterator();
		String strStatInfo[] = null;
		int j = 0;
		int[] sum = new int[13];
		int iPass = 0;
		int iNotPass = 0;
		int iNotPass2 = 0;	//缺考

		int iTotal = 0;
		while (iterStat.hasNext()) {
			coachInfo = (String[])iterStat.next();
			j++;
			iTotal = 0;

	%>
  <tr>
  	<td align="center"><%=j %></td>
  	<td align="center"><%=coachInfo[1] %></td>
		<%
			strStatInfo = (String[])map.get( new String(coachInfo[0] + "-" + "场考") );
			iPass = 0;
			iNotPass = 0;
			iNotPass2 = 0;	//缺考

			if (strStatInfo != null) {
			  iPass = SzConvert.toInt(strStatInfo[0]);
			  iNotPass = SzConvert.toInt(strStatInfo[1]);
			  iNotPass2 = SzConvert.toInt(strStatInfo[2]);
			}
			out.println("<td align='center'>" + iPass + "</td>");
			out.println("<td align='center'>" + (iNotPass + iNotPass2) + "</td>");
			out.println("<td align='center'>" + (iPass + iNotPass + iNotPass2) + "</td>");
			iTotal += iPass + iNotPass + iNotPass2;
			sum[0] += iPass;
			sum[1] += iNotPass + iNotPass2;
			sum[2] += iPass + iNotPass + iNotPass2;


			strStatInfo = (String[])map.get( new String(coachInfo[0] + "-" + "长训") );
			iPass = 0;
			iNotPass = 0;
			iNotPass2 = 0;	//缺考

			if (strStatInfo != null) {
			  iPass = SzConvert.toInt(strStatInfo[0]);
			  iNotPass = SzConvert.toInt(strStatInfo[1]);
			  iNotPass2 = SzConvert.toInt(strStatInfo[2]);
			}
			out.println("<td align='center'>" + iPass + "</td>");
			out.println("<td align='center'>" + (iNotPass + iNotPass2) + "</td>");
			out.println("<td align='center'>" + (iPass + iNotPass + iNotPass2) + "</td>");
			iTotal += iPass + iNotPass + iNotPass2;
			sum[3] += iPass;
			sum[4] += iNotPass + iNotPass2;
			sum[5] += iPass + iNotPass + iNotPass2;

			strStatInfo = (String[])map.get( new String(coachInfo[0] + "-" + "路考") );
			iPass = 0;
			iNotPass = 0;
			iNotPass2 = 0;	//缺考

			if (strStatInfo != null) {
			  iPass = SzConvert.toInt(strStatInfo[0]);
			  iNotPass = SzConvert.toInt(strStatInfo[1]);
			  iNotPass2 = SzConvert.toInt(strStatInfo[2]);
			}
			out.println("<td align='center'>" + iPass + "</td>");
			out.println("<td align='center'>" + (iNotPass + iNotPass2) + "</td>");
			out.println("<td align='center'>" + (iPass + iNotPass + iNotPass2) + "</td>");
			iTotal += iPass + iNotPass + iNotPass2;
			sum[6] += iPass;
			sum[7] += iNotPass + iNotPass2;
			sum[8] += iPass + iNotPass + iNotPass2;

			//strStatInfo = (String[])map.get( new String(coachInfo[0] + "-" + "路考") );
			iPass = 0;
			iNotPass = 0;
			iNotPass2 = 0;	//缺考

/*	
			if (strStatInfo != null) {
			  iPass = SzConvert.toInt(strStatInfo[0]);
			  iNotPass = SzConvert.toInt(strStatInfo[1]);
			  iNotPass2 = SzConvert.toInt(strStatInfo[2]);
			}
			out.println("<td align='center'>" + iPass + "</td>");
			out.println("<td align='center'>" + (iNotPass + iNotPass2) + "</td>");
			out.println("<td align='center'>" + (iPass + iNotPass + iNotPass2) + "</td>");

			iTotal += iPass + iNotPass + iNotPass2;
			sum[9] += iPass;
			sum[10] += iNotPass + iNotPass2;
			sum[11] += iPass + iNotPass + iNotPass2;
*/
			sum[9] += iTotal;

			out.println("<td align='center'>" + iTotal + "</td>");
		%>
	<%		
		} //while (iterStat.hasNext()) {
		
  %>
    </tr>
    <tr>
      <td colspan="2" align="center">合计</td>
      <%
	for (int i =0; i<10; i++) {
		out.println("<td align='center'>" + sum[i] + "</td>");
	}
      %>
    </tr>

  </form>
</table>

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


