<%@ 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 sType = SzConvert.toZeroStr(request.getParameter("type"));	
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteDataHTML(request.getParameter("txtSearch"));
	//学号
	String XH = SzConvert.strWriteData(request.getParameter("XH"));
	//流水号
	String LSH = SzConvert.strWriteData(request.getParameter("LSH"));
	//班级
	String BJ = SzConvert.strWriteData(request.getParameter("BJ"));
	//姓名
	String XM = SzConvert.strWriteData(request.getParameter("XM"));
	String BMD = SzConvert.strWriteData(request.getParameter("BMD"));
	String SFZ = SzConvert.strWriteData(request.getParameter("SFZ"));

	//条件sCond
	StringBuffer sCond = new StringBuffer("");

	//姓名
	if (!XM.equals("")){
		sCond.append(" AND XXMC2='"+ XM +"'");
	}
	if (!BMD.equals("")){
		sCond.append(" AND XXMC5='"+ BMD +"'");
	}
	if (!SFZ.equals("")){
		sCond.append(" AND XXMC3='"+ SFZ +"'");
	}

	if (sType.equals("0")) {
		sCond.append(" AND CNSH<>'' ");
	} else if (sType.equals("1")) {
		//欠费查询
		sCond.append(" AND CWSH<>''  ");
	}

	String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
    	sSortField = "XXMC6";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    }
	String strSort = " ORDER BY "+ sSortField + (iSortOrder==SzProperties.I_SortOrder_DESC? " DESC":" ASC");
	//获取Charge对象
  Charge charge = new Charge();

	
	//获取学员信息
	//ArrayList<String[]> chargeList = charge.getArrearageList(sCond.toString(),""," AND (YSXF-YJXF > 0 OR YSBKF-YJBKF > 0)",strSort);
  int iCurrentPage = 1;
  try {
        iCurrentPage =  Integer.parseInt(sPage);
  }catch(Exception e) {
  }
  int iPageSize = 20;
	ArrayList<String[]> chargeList = charge.getChargeList(sCond.toString(), sSortField, iSortOrder, iCurrentPage, iPageSize);
	SzPageInfo pageInfo = charge.getPageInfo();
	int iPageCount = pageInfo.getPageCount();
	int iRecordCount = pageInfo.getRecordCount();
	iCurrentPage = pageInfo.getCurrentPage();


	
	int iSize = chargeList.size();
	//学员
	String[] chargeInfo = 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%>"> 
  <input type="hidden" name="type" value="<%=sType%>"> 
  <tr>
    <td>
      姓名<input type="text" name="XM" class="txtClassSearch" value="<%=XM %>" OnDblClick="javascript:ReadIDCard();">
      身份证<input type="text" name="SFZ" class="txtClassSearch" value="<%=SFZ %>" OnDblClick="javascript:ReadIDCard();">
      报名点<input type="text" name="BMD" class="txtClassSearch" value="<%=BMD %>">
		 <%=SzPageHelp.button("查询", "javascript:FormSubmit(formBar,'charge2.jsp');")%>
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="OPERATOR" value="shenhe">   
  <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="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <input type="hidden" name="XH" value="<%=XH %>">
  <input type="hidden" name="XM" value="<%=XM %>">
  <input type="hidden" name="BMD" value="<%=BMD %>">
  <input type="hidden" name="SFZ" value="<%=SFZ%>">
  <input type="hidden" name="LSH" value="<%=LSH %>">
  <input type="hidden" name="BJ" value="<%=BJ %>">
  <input type="hidden" name="type" value="<%=sType%>">
  <tr class="trClassTitle">
  	<!-- 姓名,身份证,报名点名称,付款方式  sum(XXMC9),sum(XXMC10),sum(XXMC9)-sum(XXMC10)  -->
  	<td>序号</td>
  	<td><%=SzPageHelp.sortTitle("姓名", "XXMC2", sSortField, iSortOrder, strLevel_SESSION)%></td>
  	<td><%=SzPageHelp.sortTitle("身份证", "XXMC3", sSortField, iSortOrder, strLevel_SESSION)%></td>
  	<td><%=SzPageHelp.sortTitle("合同编号", "XXMC4", sSortField, iSortOrder, strLevel_SESSION)%></td>
  	<td><%=SzPageHelp.sortTitle("报名点名称", "XXMC5", sSortField, iSortOrder, strLevel_SESSION)%></td>
		<td><%=SzPageHelp.sortTitle("本次应交金额", "XXMC9", sSortField, iSortOrder, strLevel_SESSION)%></td>
		<td><%=SzPageHelp.sortTitle("本次已交金额", "XXMC10", sSortField, iSortOrder, strLevel_SESSION)%></td>
		<td><%=SzPageHelp.sortTitle("项目", "XXMC17", sSortField, iSortOrder, strLevel_SESSION)%></td>
		<td><%=SzPageHelp.sortTitle("当前状态", "SHZT", sSortField, iSortOrder, strLevel_SESSION)%></td>
		<td><%=SzPageHelp.sortTitle("录入人员", "XXMC13", sSortField, iSortOrder, strLevel_SESSION)%>|
				<%=SzPageHelp.sortTitle("录入时间", "XXMC14", sSortField, iSortOrder, strLevel_SESSION)%>
		</td>
		<td><%=SzPageHelp.sortTitle("出纳", "CNSH", sSortField, iSortOrder, strLevel_SESSION)%>|
		    <%=SzPageHelp.sortTitle("审核时间", "CNSHSJ", sSortField, iSortOrder, strLevel_SESSION)%>
		</td>
		<td><%=SzPageHelp.sortTitle("财务", "CWSH", sSortField, iSortOrder, strLevel_SESSION)%>|
				<%=SzPageHelp.sortTitle("审核时间", "CWSHSJ", sSortField, iSortOrder, strLevel_SESSION)%>
		</td>
  </tr>
<%
	//获取当前时间
	String time_str = SzDateHelp.getTimeStr();
	String sKey = "0";
	boolean isPass = false;
	int i = 0;
	double YS=0,YJ=0,HQ=0;
	for (i=0 ;i<iSize;i++){
		chargeInfo = chargeList.get(i);
		YS = Double.valueOf(chargeInfo[5]);
		YJ = Double.valueOf(chargeInfo[6]);
		//chargeInfo[7]	id
	%>
	<input type="hidden" id="OPERATOR<%=i %>" name="OPERATOR<%=i %>" value="add"> 
	<input type="hidden" name="KEY<%=i %>" value="<%=sKey %>"> 
	<input type="hidden" name="id<%=i %>" value="<%=chargeInfo[7]%>">

	<tr id="tr<%=i %>">
		<td><%=i+1 %></td>
		<td><%=chargeInfo[0] %>&nbsp;</td>
		<td><%=chargeInfo[1] %>&nbsp;</td>
		<td><%=chargeInfo[2] %>&nbsp;</td>
		<td><%=chargeInfo[3] %>&nbsp;</td>
		<td><%=YS %>&nbsp;</td>
		<td><%=YJ %>&nbsp;</td>
		<td><%=chargeInfo[8] %>&nbsp;</td>
		<td><%=chargeInfo[9] %>&nbsp;</td>
		<td><%=chargeInfo[10]%>|<%=chargeInfo[11]%>&nbsp;</td>
		<td><%=chargeInfo[12]%>|<%=chargeInfo[13]%>&nbsp;</td>
		<td><%=chargeInfo[14]%>|<%=chargeInfo[15]%>&nbsp;</td>
	</tr>
	<%
	}
%>
	<input type="hidden" name="count" value="<%=i %>">
  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <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="BMD" value="<%=BMD %>">
  <input type="hidden" name="SFZ" value="<%=SFZ%>">
  <tr>
    <td align="right">
      <%@ include file="/share/page/page_include.jsp"%>
    </td>
  </tr>
  </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 singleSubmit(obj,i){
		var sOPERATOR = document.getElementById("OPERATOR"+i).value;
		
		var key = document.getElementById("KEY"+i).value;
		var xyid = document.getElementById("XYID"+i).value;
		var xyxm = document.getElementById("XYXM"+i).value;
		var xyxh = document.getElementById("XYXH"+i).value;
		var xf = document.getElementById("YJXF"+i).value;
		var bkf = document.getElementById("YJBKF"+i).value;
		
		var dlid = document.getElementById("SzDLID").value;
		var dlxm = document.getElementById("SzDLXM").value;
		var bmmc = document.getElementById("SzBMMC").value;
		var bmid = document.getElementById("SzBMID").value;
		
		//本次交学费必须为数字
		if (xf != '' && isNaN(xf)){
			alert("本次补交学费必须为数字！");
			return false;
		}
		if (bkf != '' && isNaN(bkf)){
			alert("本次补交补考费必须为数字！");
			return false;
		}
		if (xf == '' && bkf == ''){
			alert("请输入交费金额！");
			return false;
		}
		var sUrl = "singleControl.jsp?post=ajaxPost&OPERATOR0="+ sOPERATOR +"&count=1";
		var postStr = "SzDLID="+ dlid +"&SzDLXM="+ dlxm + "&SzBMID="+ bmid +"&SzBMMC="+ bmmc +
					"&KEY0="+ key + "&XYID0="+ xyid +"&XYXM0="+ xyxm +"&XYXH0="+ xyxh +"&YJXF0="+ xf + "&YJBKF0="+ bkf;
		//编码post数据
		postStr = encodeURI(encodeURI(postStr));
		//实例化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 = "";
					obj.disabled = "disabled";
				} else {
					alert(message);
					obj.disabled = "";
				}
				ajax.abort();
				ajax = null;
			}
		}
	}
	


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