<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ 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">
</head>
<%
    int iFormID = SzConvert.toInt(request.getParameter("FormID"));
	int iFrom = SzConvert.toInt(request.getParameter("From"));
    String flowType = SzConvert.toSpaceStr(request.getParameter("flowType"));
	if (flowType.equals("")) {
		flowType = "-1";
	}
    //取得表单的信息
    String moduleName = "";
    String formName = "";
	//根据表单取得moduleName, formName
	LcForm lcForm = new LcForm();
	LcFormInfo lcFormInfo = null;    
    if (iFormID == 0) {
    	moduleName = SzConvert.toSpaceStr(request.getParameter("moduleName"));
    	formName = SzConvert.toSpaceStr(request.getParameter("formName")); 
    	//
    	iFormID = lcForm.getKeyByCond(moduleName, formName); 
    } else {
    	lcFormInfo = (LcFormInfo)lcForm.getInfoByKey(iFormID);    
    	if (lcFormInfo != null) {
    		moduleName = lcFormInfo.getBDLJ();
    		formName = lcFormInfo.getBDBY1();  
    	}
    }
    //System.out.println("moduleName=" + moduleName);
    //System.out.println("formName=" + formName);
    if (moduleName.equals("") || formName.equals("")) {
    	out.println("还没有设置相关表单信息！");
    	return;
    }
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    
    BdFormControl bdFormControl = new BdFormControl();
    String detailTableId = bdFormControl.detailTableId;
    //字段信息
    bdFormControl.getMapStatic(moduleName, formName);
    Map fieldMap = bdFormControl.getFieldMap();
    BdFormFieldInfo bdFormFieldInfo = null;
    Collection collFormField = null;
    collFormField = (Collection)fieldMap.get(new String(moduleName + "-" + formName));
    Iterator iterFormField = null;  
    int i =0;
%> 
<form name="formUpdate" method="post" action="stat.jsp">   
<%@ include file="title.jsp"%>
<table width="100%">
  <tr>
    <td>
      <%
      if (isBarManager_SESSION) {
    	  out.println(SzPageHelp.button("设置统计","javascript:document.location.href='stat_index.jsp?FormID=" + iFormID + "&From=" + iFrom + "'"));
    	  out.println(SzPageHelp.button("设置汇总","javascript:document.location.href='collect_index.jsp?FormID=" + iFormID + "&From=" + iFrom + "'"));    	  
      }
      %>
      <%=SzPageHelp.backButton()%>
      <%
      	String s_id2[] = {"-1","0","1","2"};
      	String s_name2[] = {"全部","办理中","否决","办结"};
      	out.println(SzPageHelp.radioSubmit("flowType", s_id2, s_name2, flowType));
      %>      
    </td>
  </tr>
</table>

<table width="700" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">

  <input type="hidden" name="FormID" value="<%=iFormID%>">
  <input type="hidden" name="From" value="<%=iFrom%>">   
<%
	//获得
    BdStatControl statControl = new BdStatControl();
    Iterator iter = statControl.getInfoFromXML(moduleName, formName).iterator();	
%>   
  <tr>  
    <td colspan="6" align="center">
<%
    String id = ""; 
    String s[] = null;
    while (iter != null && iter.hasNext()) {
    	s = (String[])iter.next();
    	if (s == null) {
    		continue;
    	}
    	id = s[0];
    	i++;
    	out.println("<a href='#' OnClick=\"javascript:FormSubmit(formUpdate, 'searchOk.jsp?type=stat&id=" + id + "');\">");
    	out.println(s[3]);
    	out.println("</a>");
    	out.println("<br>");
    }
	
	//获得
    BdCollectControl collectControl = new BdCollectControl();
    Iterator iter2 = collectControl.getInfoFromXML(moduleName, formName).iterator();	

    while (iter2 != null && iter2.hasNext()) {
    	s = (String[])iter2.next();
    	if (s == null) {
    		continue;
    	}
    	id = s[0];
    	i++;    	
    	out.println("<a href='#' OnClick=\"javascript:FormSubmit(formUpdate, 'searchOk.jsp?type=collect&id=" + id + "');\">");
    	out.println(s[3]);
    	out.println("</a>");
    	out.println("<br>");    	
    }
%>    
    </td>     
  </tr>     
  <tr class="trClassTitle">
  	<td>字段名称</td>
  	<td>条件</td>
  	<td>值</td>
  	
  	<td>字段名称</td>
  	<td>条件</td>
  	<td>值</td> 	
  </tr>
  
<%
    if (collFormField != null) {
    	iterFormField = collFormField.iterator();
    }

    String s_name[] = {"包含","等于","大于","大于等于","小于","小于等于"};
    String s_id[] = {"1","0","2","3","4","5"};    

	while (iterFormField != null && iterFormField.hasNext()) {
		bdFormFieldInfo = (BdFormFieldInfo) iterFormField.next();
		if (detailTableId.equals(bdFormFieldInfo.getTableId())) {
			continue;
		}	
		if (bdFormFieldInfo.getZDCX() != 1) {
			continue;
		}
%>
  <tr>
  	<td>
  	  <input type="hidden" name="field<%=i%>" value="<%=bdFormFieldInfo.getZDMC()%>">
  	  <%=bdFormFieldInfo.getZDSM()%>&nbsp;
  	</td>
  	<td><%=SzPageHelp.idSelectArray(s_name, s_id, "cond" + i, "", "")%>&nbsp;</td>
  	<td><input type="text" name="value<%=i %>" class="txtClass120">&nbsp;</td>
  	
  	<td>
  	  <input type="hidden" name="field<%=i + 1%>" value="<%=bdFormFieldInfo.getZDMC()%>">
  	  <%=bdFormFieldInfo.getZDSM()%>&nbsp;
  	</td>
  	<td><%=SzPageHelp.idSelectArray(s_name, s_id, "cond" + i + 1, "", "")%>&nbsp;</td>
  	<td><input type="text" name="value<%=i + 1 %>" class="txtClass120">&nbsp;</td>
  </tr>
<%	
		i = i+ 2;
	}
%>

  <input type="hidden" name="count" value="<%=i %>">

</table>
</form>
<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>"> 
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>"> 
  <input type="hidden" name="FormID" value="<%=iFormID%>">   
  <input type="hidden" name="From" value="<%=iFrom%>">    
  <input type="hidden" name="flowType" value="<%=flowType%>">  
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  function FormSave(formName, url) {
    formName.action = url;
    formName.submit();      
  }   
 
</script> 
