<%@ 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>
<%@ 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"));
	//流水号
	String LSH = SzConvert.strWriteData(request.getParameter("LSH"));
	//条件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 +"'");
	}
	//流水号
	if (!LSH.equals("")){
		sCond.append(" AND XXMC32='"+ LSH +"'");
	}
	//条件
	sCond.append("  AND XXMC37='预约上课'");
	
	String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
    	sSortField = "XXMC34";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    }
	sCond.append(" ORDER BY "+ sSortField + (iSortOrder==SzProperties.I_SortOrder_DESC? " DESC":" ASC"));
	//获取Vehicle对象
    Student student = new Student();
	//信息ID,学号,流水号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员
	String[] fields = new String[]{"XXMC1","XXMC3","XXMC32","XXMC24","XXMC2","XXMC40","XXMC5","XXMC16","XXMC6","XXMC8","XXMC10","XXMC28","XXMC23","XXMC21",
			"XXMC47","XXMC64","XXMC50","XXMC52"};
	
	//获取学员信息
	ArrayList<String[]> studentList = student.getXueYuanList(fields,sCond.toString());
	int iSize = studentList.size();
	//学员
	String[] studentInfo = null;
	
%>
<!-----上面的工具栏------>
<%@ 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="LSH" class="txtClassSearch" value="<%=LSH %>">
      姓名<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,'yuyueshangkeList2.jsp');")%>
      <%//=SzPageHelp.button("批量保存", "javascript:ShenHeSubmit(formList,'control.jsp');")%>
      <%=SzPageHelp.button("导到excel", "document.location.href='../../upload/driverschool/" + iDLID_SESSION + ".xls';")%>
    </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="yuyuequeren"> 
  <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="LSH" value="<%=LSH %>">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">
  <tr class="trClassTitle">
  	<!-- 信息ID,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员 -->
  	<td>序号</td>
  	<td><%=SzPageHelp.sortTitle("学号", "XXMC3", sSortField, iSortOrder, strLevel_SESSION)%></td>
  	<td><%=SzPageHelp.sortTitle("流水号", "XXMC32", 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>预约时间段</td>
    <td width="115"><input type="checkbox" name="checkAll" onclick="javascript:checked_All(this,'YWSJ');">确认有无时间</td>
    <td width="140">备注</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><%=SzPageHelp.sortTitle("审核状态", "XXMC21", sSortField, iSortOrder, strLevel_SESSION)%></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("数码回执");
	listColumn.add("接送地址");
	listColumn.add("招收人员");

	listExcel.add(listColumn);

	//获取当前时间
	String time_str = SzDateHelp.getTimeStr();
	String sKey = "";
	int i = 0;
	for (;i<iSize;i++){
		studentInfo = studentList.get(i);
		sKey = studentInfo[0];

		listColumn = new ArrayList();
		listColumn.add(studentInfo[1]);
		listColumn.add(studentInfo[2]);
		listColumn.add(SzConvert.truncate(studentInfo[3],10));							
		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]);
		listColumn.add(studentInfo[12]);
		listExcel.add(listColumn);

	%>
	<input type="hidden" name="XYID<%=i %>" value="<%=sKey %>">
	<input type="hidden" name="OPERATOR<%=i %>" value="yuyuequeren"> 
	<tr id="tr<%=i %>">
		<td><%=i+1 %></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><%=studentInfo[2] %>&nbsp;</td>
		<td><%=SzConvert.truncate(studentInfo[3],10) %>&nbsp;</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[17] %>至<%=studentInfo[14] %>&nbsp;</td>
		<td><input type="checkbox" name="YWSJ<%=i %>" value="有时间" <%//=studentInfo[15].equals("有时间")? "checked":"" %>>有无时间<INPUT class="btnClassShort" onclick="javascript:singleSubmit(this,<%=i %>);" value="保存" type="button" name="btnSelect"></td>
		<td><TEXTAREA name="yuyuebeizhu<%=i %>" class="txtClass140" onblur="javascript:this.className='txtClass140'" onfocus="javascript:this.className='areaClass140'"><%=studentInfo[16] %></TEXTAREA></td>
		<td><%=studentInfo[10] %>&nbsp;</td>
		<td><%=studentInfo[11] %>&nbsp;</td>
		<td><%=studentInfo[12] %>&nbsp;</td>
		<td><%=studentInfo[13] %>&nbsp;</td>
	</tr>
	<%
	}
	net.sz600.tool.SzFile.writeExcel("预约上课确认","upload//driverschool//", iDLID_SESSION + ".xls",listExcel);	
%>
	<input type="hidden" name="count" value="<%=i %>">
  </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){
		if (!confirm("确定是否要批量保存?")){
			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");	
  	}
	
	function checked_All(obj,prefixName){
		var count = document.getElementById("count").value;
		for (var i = 0;i<count;i++){
			var ocjCheckbox = document.getElementById(prefixName + i);
			ocjCheckbox.checked = obj.checked;
		}
	}
	
	function singleSubmit(obj,i){
		var key = document.getElementById("XYID"+i).value;
		var objYWSJ = document.getElementById("YWSJ"+i);
		var ywsj = objYWSJ.checked? objYWSJ.value:"";
		var yybz = document.getElementById("yuyuebeizhu"+i).value;
		var DLID = document.getElementById("SzDLID").value;
		var DLXM = document.getElementById("SzDLXM").value;
 
		var sUrl = "singleControl.jsp?post=ajaxPost&OPERATOR0=yuyuequeren&count=1";
		var postStr = "SzDLID="+ DLID +"&SzDLXM="+ encodeURI(encodeURI(DLXM)) +"&XYID0="+ key +"&YWSJ0="+ encodeURI(encodeURI(ywsj)) +"&yuyuebeizhu0="+encodeURI(encodeURI(yybz));
		
		//实例化Ajax
		var ajax = null;
		if (window.XMLHttpRequest){
			ajax = new XMLHttpRequest();
		} else if (window.ActiveXObject){
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			return;
		}
		obj.disabled = "disabled";
		//通过Post方式打开链接
		ajax.open("POST",sUrl,true);
		//定义传输文件头部信息
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
		//发送Post数据
		ajax.send(postStr);
		//回调函数
		ajax.onreadystatechange = function(){
			if (ajax.readyState == 4 && ajax.status == 200) {
				var message = ajax.responseText;
				message = message.substring(message.indexOf("[")+1,message.indexOf("]"));
				if (message == "true"){
					document.getElementById("OPERATOR"+i).value = "";
					document.getElementById("YWSJ"+i).disabled = "disabled";
					document.getElementById("yuyuebeizhu"+i).disabled = "disabled";
				} else {
					alert(message);
					obj.disabled = "";
				}
			}
		}
	}
	


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