<%@ 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>
<script language="javascript">
	function SelectOk() {
		//教练ID
		//教练名称
		var vId = ValueOfRadio(formList.id);
		var vName = "";
		var oName = document.getElementById("name" + vId);
		if (oName != null) {
			vName = oName.value;
		}
		if (vId != "0" && vName != "") {
			var oWindow = window.dialogArguments;
			if (oWindow != null) {
    		var objId   = formList.objId.value;		
    		var objName = formList.objName.value;	
    		if (objId != "") {
    			eval("oWindow." + objId + ".value ='" + vId + "';");
    		}
    		if (objName != "") {
    			eval("oWindow." + objName + ".value ='" + vName + "';");
    		} 
    		window.close();   					
			}
		}
	}
</script>
</head>
<%
	String objId = SzConvert.toSpaceStr(request.getParameter("objId"));
	String objName = SzConvert.toSpaceStr(request.getParameter("objName"));
	String currentDate = SzConvert.toSpaceStr(request.getParameter("currentDate"));
	
	//学号selectSubject
	String XH = SzConvert.strWriteData(request.getParameter("XH"));
	int iSelectSubject = SzConvert.toInt(request.getParameter("selectSubject"));
	Subject subjectClass = new Subject();
	String sSubjectName = subjectClass.getSubjectName(iSelectSubject);
	

	//条件sCond
	StringBuffer sCond = new StringBuffer(" ");
	//学号
	if (!XH.equals("")){
		sCond.append(" AND XXMC2='"+ XH +"'");
	}	

	
	String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
  int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
  if (sSortField.equals("")) { 
    	sSortField = "XXMC1";
    	iSortOrder = SzProperties.I_SortOrder_ASC;
  }
	sCond.append(" ORDER BY "+ sSortField + (iSortOrder==SzProperties.I_SortOrder_DESC? " DESC":" ASC"));
	//获取Vehicle对象
  Coach coach = new Coach();
	//
	String[] fields = new String[]{"XXMC1","XXMC2","XXMC3","XXMC4","XXMC9"};

	//获取学员信息
	ArrayList<String[]> coachList = coach.getCoachList(fields, sCond.toString());
	int iSize = coachList.size();

	String[] coachInfo = null;
	ToSetUpCourse toSetUpCourse = new ToSetUpCourse();
	ToSetUpCoach toSetUpCoach = new ToSetUpCoach();	
%>
<!-----上面的工具栏------>
<form name="formList" method="post">
<%@ include file="/share/titleDialog.jsp"%>
  <input type="hidden" name="objId" value="<%=objId%>">
  <input type="hidden" name="objName" value="<%=objName%>">
  <input type="hidden" name="currentDate" value="<%=currentDate%>">
  <input type="hidden" name="selectSubject" value="<%=iSelectSubject%>">
<table width="100%">
  <tr>
    <td>
      科目：<B><%=sSubjectName%></B>    
      教练名称<input type="text" name="XH" class="txtClassSearch" value="<%=XH %>">
     <input type="hidden" name="selectCoachName">
     <%=SzPageHelp.button("查询", "javascript:FormSubmit(formList,'coach_select.jsp');")%>
     <%=SzPageHelp.button("确定", "javascript:SelectOk();")%>		 
    </td>
    <td align="right"><%=SzPageHelp.closeButton() %></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%>">
  <tr class="trClassTitle">
  	<!-- 信息ID,学号,报名时间,姓名,性别,户籍,班别,报名点,身份证号,数码回执,接送地址,招收人员 -->
  	<td width="25" align="center">&nbsp;</td>
  	<td><%=SzPageHelp.sortTitle("教练姓名", "XXMC2", sSortField, iSortOrder, strLevel_SESSION, "ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("负责科目", "XXMC3", sSortField, iSortOrder, strLevel_SESSION, "ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("负责场地", "XXMC4", sSortField, iSortOrder, strLevel_SESSION, "ReSortDialog")%></td>
    <td><%=SzPageHelp.sortTitle("车牌", "XXMC9", sSortField, iSortOrder, strLevel_SESSION, "ReSortDialog")%></td>
    <td>学员数量</td>
    <td>本周课程数</td>
  </tr>
<%
	String sKey = "";
 
	for (int i = 0;i<iSize;i++) {
		coachInfo = coachList.get(i);
		sKey = coachInfo[0];
	%>
	<tr>
		<td><input title="<%=i+1 %>" type="radio" name="id" value="<%=sKey %>">
		<input type="hidden"  name="name<%=sKey%>" id="name<%=sKey%>" value="<%=coachInfo[1]%>">
		</td>
		<td align="center"><span contentEditable="true"><%=coachInfo[1]%></span></td>
		<td align="center"><span contentEditable="true"><%=coachInfo[2]%></span></td>
		<td align="center"><span contentEditable="true"><%=coachInfo[3]%></span></td>
		<td align="center"><span contentEditable="true"><%=coachInfo[4]%></span></td>
		<td align="center"><span contentEditable="true"><%=toSetUpCoach.getStudentCount(SzConvert.toInt(coachInfo[0]), iSelectSubject, 0)%></span></td>
		<td align="center"><span contentEditable="true"><%=toSetUpCourse.getCoachCourseCountWeek(coachInfo[0], currentDate)%></span></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>
