<%@ 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>
<base target="_self">
<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 XH = SzConvert.strWriteData(request.getParameter("XH"));
	int iSelectCoach = SzConvert.toInt(request.getParameter("selectCoach"));
	int iSelectSubject = SzConvert.toInt(request.getParameter("selectSubject"));
	int iSelectBMID = SzConvert.toInt(request.getParameter("selectBM"));
	Subject subjectClass = new Subject();
	String sSubjectName = subjectClass.getSubjectName(iSelectSubject);
	
	String txtShijianduan = SzConvert.toZeroStr(request.getParameter("txtShijianduan"));
	String txtDate = SzConvert.toZeroStr(request.getParameter("txtDate"));
	String txtBMIDStr = SzConvert.toZeroStr(request.getParameter("txtBMIDStr"));
	//姓名
	String XM = SzConvert.strWriteData(request.getParameter("XM"));
	//班级
	String BJ = SzConvert.strWriteData(request.getParameter("BJ"));
	
	//条件sCond
	StringBuffer sCond = new StringBuffer(" ");
	//学号
	if (!XH.equals("")){
		sCond.append(" AND XXMC3='"+ XH +"'");
	}	
	//姓名
	if (!XM.equals("")){
		sCond.append(" AND XXMC2='"+ XM +"'");
	}
	//班级
	if (!BJ.equals("")){
		sCond.append(" AND XXMC16='"+ BJ +"'");
	}
	//分点选择
	if (iSelectBMID == 0){
		sCond.append(" AND XXMC14 in ("+ txtBMIDStr +")");
	} else {
		sCond.append(" AND XXMC14="+ iSelectBMID +"");
	}
	//以下几种状态可练车
	//sCond.append(" AND XXMC37 in ('桩考教练已分配','桩考练车','桩考可考','桩考预约','桩考不及格')");
	Exam exam = new Exam();
	//sCond.append(exam.getCond("课程安排", sSubjectName));		
	//只显示教练已分配的学员
	sCond.append(" AND XXMC1 in ( select XXMC14 from BD_DRIVINGSCHOOL_TOSETUPCOACH where XXMC18=");
	sCond.append(iSelectCoach);
	sCond.append(" and XXMC16=");
	sCond.append(iSelectSubject);
	sCond.append(") ");
	//只显示当前时间点未分配的学员
	sCond.append(" AND XXMC1 not in ( select KCXXMC5 from BD_DRIVINGSCHOOL_TOSETUPCOURSE where KCXXMC8='");
	sCond.append(txtDate);
	sCond.append("' and KCXXMC9='");
	sCond.append(txtShijianduan);
	sCond.append("' and KCXXMC13='");
	sCond.append(iSelectSubject);
	sCond.append("' ");
	sCond.append(") ");	
	
	String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
  int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
  if (sSortField.equals("")) { 
    	sSortField = "XXMC24";
    	iSortOrder = SzProperties.I_SortOrder_ASC;
  }
	sCond.append(" ORDER BY "+ sSortField + (iSortOrder==SzProperties.I_SortOrder_DESC? " DESC":" ASC"));
	//获取Vehicle对象
  Student student = new Student();
	//信息ID,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员,报名点ID
	String[] fields = new String[]{"XXMC1","XXMC3","XXMC24","XXMC2","XXMC40",
			"XXMC5","XXMC16","XXMC6","XXMC8","XXMC10",
			"XXMC28","XXMC23","XXMC20","XXMC37","XXMC41",
			"XXMC14","XXMC19","XXMC32"};

	//获取学员信息
	ArrayList<String[]> studentList = student.getXueYuanList(fields, sCond.toString());
	int iSize = studentList.size();
	//学员
	String[] studentInfo = null;
	ToSetUpCourse toSetUpCourse = new ToSetUpCourse();
%>
<!-----上面的工具栏------>
<form name="formList" method="post">
<%@ include file="/share/titleDialog.jsp"%>

<table width="100%">
  <tr>
    <td>
     科目：<B><%=sSubjectName%></B>
     当前日期：<b><%=txtDate%></b>
      当前时间段：<b><%=txtShijianduan%></b>
     <%
  		if (iSelectCoach > 0) {
  			out.println("所选教练当前周已安排的课时:<b>" + toSetUpCourse.getCoachCourseCountWeek(Integer.toString(iSelectCoach), txtDate) + "</b>");
  		}
     %>	
     <br>
      学号<input type="text" name="XH" class="txtClassSearch" value="<%=XH %>">
      班级<input type="text" name="BJ" class="txtClassSearch" value="<%=BJ %>">
     姓名<input type="text" name="XM" class="txtClassSearch" value="<%=XM %>">
      <input type="hidden" name="selectSubject" value="<%=iSelectSubject%>">   
     <input type="hidden" name="txtShijianduan" value="<%=txtShijianduan%>">
     <input type="hidden" name="selectCoachName">
     <input type="hidden" name="selectSubjectName" value="<%=sSubjectName%>">
  		<input type="hidden" name="KSKM" value="<%=sSubjectName%>">
 	 	<input type="hidden" name="KSKMID" value="<%=iSelectSubject %>">     
  	 <input type="hidden" name="txtDate" value="<%=txtDate%>">    
  	 <input type="hidden" name="txtBMIDStr" value="<%=txtBMIDStr%>">
      
      <br>
      分点选择:<%=SzPageHelp.idSelectSubmit("SZXT_BM", "BMID", "BMMC","selectBM", iSelectBMID, "","BMID IN ("+ txtBMIDStr +")") %>
      教练选择:<%=SzPageHelp.idSelectSubmit("BD_DRIVINGSCHOOL_COACH", "XXMC1", "XXMC2","selectCoach", iSelectCoach, "", "") %>
     <%=SzPageHelp.button("查询", "javascript:FormSubmit(formList,'student_select.jsp');")%>
		 <%=SzPageHelp.closeButton() %>
		 <%=SzPageHelp.button("btnClassLong","批量保存当前课程安排", "javascript:ShenHeSubmit(formList,'control.jsp');")%>
    </td>
  </tr>
</table>
<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <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="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <input type="hidden" name="XM" value="<%=XM %>">
  <input type="hidden" name="BJ" value="<%=BJ %>">
  
  <tr class="trClassTitle">
  	<!-- 信息ID,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员 -->
  	<td width="25" align="center"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'student');"></td>
  	<td><%=SzPageHelp.sortTitle("学号", "XXMC3", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("报名时间", "XXMC24", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("姓名", "XXMC2", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("性别", "XXMC40", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("班别", "XXMC16", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("学车进展状态", "XXMC37", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("就近训练场", "XXMC20", sSortField, iSortOrder, strLevel_SESSION,"ReSortDialog")%></td>
    <td>当前科目课时</td>
  </tr>
<%
	String sKey = "";
	
	for (int i = 0;i<iSize;i++){
		studentInfo = studentList.get(i);
		sKey = studentInfo[0];
	%>
	<tr>
		<input type="hidden" name="sName<%=studentInfo[0] %>" value="<%=studentInfo[3] %>">
		<input type="hidden" name="sBJ<%=studentInfo[0] %>" value="<%=studentInfo[6] %>">
		<input type="hidden" name="sBJID<%=studentInfo[0] %>" value="<%=studentInfo[16] %>">
		<input type="hidden" name="sXH<%=studentInfo[0] %>" value="<%=studentInfo[1] %>">
		<input type="hidden" name="sLSH<%=studentInfo[0] %>" value="<%=studentInfo[17] %>">	
		<input type="hidden" name="sFDID<%=studentInfo[0] %>" value="<%=studentInfo[15] %>">
		<input type="hidden" name="sFDMC<%=studentInfo[0] %>" value="<%=studentInfo[7] %>">	
	
		<td><input title="<%=i+1 %>" type="checkbox" name="student" value="<%=sKey %>"></td>
		<td><span contentEditable="true"> <a href="javascript:void(0);" onclick="javascript:OpenWin_Detail('../../share/formEngine2/update.jsp?OPERATOR=detail&FormID=1384&type=0&ShowMode=open&KEY=<%=sKey %>');"><%=studentInfo[1] %></a>&nbsp;</span></td>
		<td><span contentEditable="true"> <%=SzConvert.truncate(studentInfo[2],10) %>&nbsp;</span></td>
		<td><span contentEditable="true"> <%=studentInfo[3] %>&nbsp;</span></td>
		<td><span contentEditable="true"> <%=studentInfo[4] %>&nbsp;</span></td>
		<td><span contentEditable="true"> <%=studentInfo[6] %>&nbsp;</span></td>
		<td><span contentEditable="true"> <%=studentInfo[13] %>&nbsp;</span></td>			
		<td><%=SzPageHelp.idSelect("BD_DRIVINGSCHOOL_CHANGDI", "XXMC1", "XXMC2", "1=1","CDID" + studentInfo[0], SzConvert.toInt(studentInfo[14]), "") %></td>
		<td><%=toSetUpCourse.getStudentCourseCount(sKey, Integer.toString(iSelectSubject)) %></td>
	</tr>
	<%
	}
%>  
</table>
</form>

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

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<script language="javascript" type="text/javascript">
  function OpenWin_Detail(sUrl) {
  	window.open(sUrl,"","left=100,top=50,width=800,height=600,status=yes,scrollbars=yes,resizable=yes");	
  }  

	function ShenHeSubmit(formName,sUrl){
		if (!confirm("确定是否要批量保存?")){
			return false;
		}
		//教练名称
		formName.selectCoachName.value =  formName.selectCoach[formName.selectCoach.selectedIndex].text;
		//formName.selectSubjectName.value =  formName.selectSubject[formName.selectSubject.selectedIndex].text;
		//科目名称
		formName.action = sUrl;
		formName.submit();
	}
	  		
</script>
