<%@ 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.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ 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>

<%@ include file="/drivingSchool/tool/ReadIDCard.jsp"%>

</head>
<%
	
	//查询时间段
	String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
	String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));
	//获取选择的部门信息
	String BMID = SzConvert.toZeroStr(request.getParameter("BMID"));
	String BMMC = SzConvert.strWriteData(request.getParameter("BMMC"));
	//学号
	String XH = SzConvert.strWriteData(request.getParameter("XH"));
	//学号
	String XM = SzConvert.strWriteData(request.getParameter("XM"));
	
	//条件sCond
	StringBuffer sCond = new StringBuffer("");
	//如果开始时间和结束时间都为空，就默认为当前月
	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 (!sSearchBegin.equals("")) {
        sCond.append(" AND XXMC24>='" + sSearchBegin + "'");
    }
    if (!searchEnd.equals("")) {
        sCond.append(" AND XXMC24<'" + searchEnd + "'");
    }
	
	
	if (!BMMC.equals("")){
		sCond.append(" AND XXMC6='"+ BMMC +"'");
	}
	//学号
	if (!XH.equals("")){
		sCond.append(" AND XXMC3='"+ XH +"'");
	}
	//姓名
	if (!XM.equals("")){
		sCond.append(" AND XXMC2='"+ XM +"'");
	}
	//条件
	sCond.append(" AND XXMC21='未审'");
	
	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,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员
	String[] fields = new String[]{"XXMC1","XXMC3","XXMC24","XXMC2","XXMC40","XXMC5","XXMC16","XXMC6","XXMC8","XXMC10","XXMC28","XXMC23"};
	
	//获取学员信息
	ArrayList<String[]> studentList = student.getXueYuanList(fields,sCond.toString());
	int iSize = studentList.size();
	//学员
	String[] studentInfo = null;
	
	//最新学号
	String zxxh = student.getZXXH();
	
%>
<!-----上面的工具栏------>
<%@ include file="/docEngine/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <tr>
    <td>
      报名点<input type="text" name="BMMC" class="txtClassSearch" value="<%=BMMC %>">
      学号<input type="text" name="XH" class="txtClassSearch" value="<%=XH %>">
      姓名<input type="text" name="XM" class="txtClassSearch" value="<%=XM %>" OnDblClick="javascript:ReadIDCard();">
      开始<input type="text" name="txtSearchBegin" class="txtClassSearch" value="<%=sSearchBegin%>">
      <%=SzPageHelp.calendar2Select("../../","formBar.txtSearchBegin")%>
      结束<input type="text" name="txtSearchEnd" class="txtClassSearch" value="<%=sSearchEnd%>">
      <%=SzPageHelp.calendar2Select("../../","formBar.txtSearchEnd")%>
      <%=SzPageHelp.button("查询", "javascript:FormSubmit(formBar,'shenheList.jsp');")%>
      <%=SzPageHelp.button("导到excel", "document.location.href='../../upload/driverschool/" + iDLID_SESSION + ".xls';")%>
     
      <br>
      <INPUT type=radio name="shenhe" value="通过" onclick="javascript:formList.shenhe.value=this.value;" text="通过">通过
      <INPUT type=radio name="shenhe" value="未通过" onclick="javascript:formList.shenhe.value=this.value;" text="未通过">不通过
      <%=SzPageHelp.button("批量审核", "javascript:ShenHeSubmit(formList,'control.jsp');")%>
      上次录入学号：<span style="color: blue;"><%=zxxh %></span>
      <input type="hidden" id="ZXXH" name="ZXXH" value="<%=zxxh %>">
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="1500" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="OPERATOR" value="update"> 
  <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="BMMC" value="<%=BMMC%>">
  <input type="hidden" name="XH" value="<%=XH %>">
  <input type="hidden" name="XM" value="<%=XM %>">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">
  <input type="hidden" name="shenhe" value="">
  <tr class="trClassTitle">
  	<!-- 信息ID,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员 -->
  	<td width="25" align="center"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
<!--  	<td><%=SzPageHelp.sortTitle("学号", "XXMC3", sSortField, iSortOrder, strLevel_SESSION)%></td>-->
    <td><%=SzPageHelp.sortTitle("报名时间", "XXMC24", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("姓名", "XXMC2", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("性别", "XXMC40", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("户籍", "XXMC5", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("班别", "XXMC16", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("报名点", "XXMC6", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("身份证号", "XXMC8", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("数码回执", "XXMC10", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("接送地址", "XXMC28", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td><%=SzPageHelp.sortTitle("招收人员", "XXMC23", sSortField, iSortOrder, strLevel_SESSION)%></td>
    <td width="100">学号<input type="button" class="btnClassShort" value="递加" OnClick="javascript:ZXXH();"></td>
<script language="javascript">
  //检查是否全部为数字
  function isNum(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      return true;
  }

  function ZXXH() {
    if (confirm("自动填充所有学号？只支持数字")) {
      var ZXXH = document.getElementById("ZXXH").value;  

      var iZXXH = 0;
      if (isNum(ZXXH)) {
	iZXXH = parseInt(ZXXH);
      }
      for (var i=0; i<formList.elements.length; i++) {
        e = formList.elements[i];
        if (e.name == "chkId") {
	  xuehao = document.getElementById("xuehao" + e.value);
	  if ( xuehao != null) {
 	    iZXXH++;	
	    xuehao.value = iZXXH;
	  } 
        }
      }
    }
  }
</script>
    <td width="115">档案递交时间</td>
    <td width="80">档案接收人</td>
    <td width="115">档案接收时间</td>
    <td width="75">应交资料</td>
    <td width="140">备注</td>
  </tr>
<%
	ArrayList listExcel = new ArrayList();
	ArrayList listColumn = null;

	listColumn = new ArrayList();
	listColumn.add("报名时间");							
	listColumn.add("姓名");
	listColumn.add("性别");
	listColumn.add("户籍");
	listColumn.add("班别");
	listColumn.add("报名点");
	listColumn.add("身份证号");
	listColumn.add("数码回执");
	listColumn.add("接送地址");
	listColumn.add("招收人员");


	listExcel.add(listColumn);

	String sKey = "";
	for (int i = 0;i<iSize;i++){
		studentInfo = studentList.get(i);
		sKey = studentInfo[0];

		listColumn = new ArrayList();
		listColumn.add(SzConvert.truncate(studentInfo[2],10));							
		listColumn.add(studentInfo[3]);
		listColumn.add(studentInfo[4]);
		listColumn.add(studentInfo[5]);
		listColumn.add(studentInfo[6]);
		listColumn.add(studentInfo[7]);
		listColumn.add(studentInfo[8]);
		listColumn.add(studentInfo[9]);
		listColumn.add(studentInfo[10]);
		listColumn.add(studentInfo[11]);
		listExcel.add(listColumn);
	%>
	<tr>
		<td><input title="<%=i+1 %>" type="checkbox" name="chkId" value="<%=sKey %>"></td>
<!--		<td><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;</td>-->
		<td><%=SzConvert.truncate(studentInfo[2],10) %>&nbsp;</td>
		<td><a href="javascript:void(0);" onclick="javascript:OpenWin_Detail('../../share/formEngine2/detail_win.jsp?OPERATOR=detail&FormID=1384&type=0&ShowMode=open&KEY=<%=sKey %>');"><%=studentInfo[3] %>&nbsp;</a></td>
		<td><%=studentInfo[4] %>&nbsp;</td>
		<td><%=studentInfo[5] %>&nbsp;</td>
		<td><%=studentInfo[6] %>&nbsp;</td>
		<td><%=studentInfo[7] %>&nbsp;</td>
		<td><%=studentInfo[8] %>&nbsp;</td>
		<td><%=studentInfo[9] %>&nbsp;</td>
		<td><%=studentInfo[10] %>&nbsp;</td>
		<td><%=studentInfo[11] %>&nbsp;</td>
		<td><input type="text" name="xuehao<%=sKey %>" id="xuehao<%=sKey %>" class="txtClassSearch" value=""></td>
		<td><input type="text" name="dijiaoshijian<%=sKey %>" class="txtClassSearch" value="" readonly><%=SzPageHelp.calendar2Select("../../","formList.dijiaoshijian"+sKey)%></td>
		<td><input type="text" name="jieshouren<%=sKey %>" class="txtClassSearch" value=""></td>
		<td><input type="text" name="jieshoushijian<%=sKey %>" class="txtClassSearch" value="" readonly><%=SzPageHelp.calendar2Select("../../","formList.jieshoushijian"+sKey)%></td>
		<td><INPUT type="checkbox" name="yingjiaoziliao<%=sKey %>" value="资料齐全" text="是否齐全">是否齐全</td>
		<td><TEXTAREA name="shenhebeizhu<%=sKey %>" class="txtClass140" onblur="javascript:this.className='txtClass140'" onfocus="javascript:this.className='areaClass140'"></TEXTAREA></td>
	</tr>
	<%
	}

	SzFile.writeExcel("学员档案审核","upload//driverschool//", iDLID_SESSION + ".xls",listExcel);	
%>

  </form>
</table>

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

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<script language="javascript" type="text/javascript">
	function ShenHeSubmit(formName,sUrl){
		var shenhe = formName.shenhe.value;
		var chkIds = document.getElementsByName("chkId");
		/*
		//2011-12-01修改。改成common.js里的NumberOfCheck判断是否选中。
		var len = chkIds.length;
		if (len <= 0){
			alert("暂时没有审核的信息!");
			return false;
		}
		var chkCount = 0;
		for (var i = 0;i < len;i++){
			if (chkIds[i].checked){
				chkCount++;
			}
		}
		*/
		var chkCount = NumberOfCheck(formName.chkId);
		if (chkCount <= 0){
			alert("请选择要审核的信息!");
			return false;
		}
		var len = chkIds.length;
		var chkCount = 0;
		for (var i = 0;i < len;i++){
			if (chkIds[i].checked && document.getElementById("xuehao"+chkIds[i].value).value == ""){
				alert("学号不能为空!");
				return false;
			}
		}
		if (shenhe == ""){
			alert("请确定审核状态!");
			return false;
		}
		formName.action = sUrl;
		formName.submit();
	}

    function OpenWin_Detail(sUrl) {
  		window.open(sUrl,"","left=100,top=50,width=800,height=600,status=yes,scrollbars=yes,resizable=yes");	
  	}
</script>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame("../../"));
%>