<%@ page contentType="text/html;charset=UTF-8" %>
<%@ 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.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ include file="/sessionInfo.jsp"%>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<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;
    boolean hasFlow = bdFormControl.getHasFlow(iFormID);
    //字段信息
    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>
      <%=SzPageHelp.backButton()%>    
    </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%>">   

  <tr>  
    <td colspan="6" align="center">
<%
	//获得
	String sUrl = "";
	BdStat stat = new BdStat();
	Iterator iter = stat.getList().iterator();	
    String id = ""; 
    String s[] = null;
    while (iter != null && iter.hasNext()) {
    	s = (String[])iter.next();
    	if (s == null) {
    		continue;
    	}
    	if (!s[1].equals(moduleName) || !s[2].equals(formName)) {
    		continue;
    	}
    	id = s[0];
    	i++;
    	sUrl = "stat_result.jsp?type=stat&id=" + id;
    	out.println("<a href='#' OnClick=\"javascript:FormSubmit(formUpdate, '" + sUrl + "');\">");
    	out.println(s[3]);
    	out.println("</a>");
    	out.println("<br>");
    }
	
	//获得
    BdCollect bdCollect = new BdCollect();
    Iterator iter2 = bdCollect.getList().iterator();	

    while (iter2 != null && iter2.hasNext()) {
    	s = (String[])iter2.next();
    	if (s == null) {
    		continue;
    	}
    	if (!s[1].equals(moduleName) || !s[2].equals(formName)) {
    		continue;
    	}    	
    	id = s[0];
    	i++;    	
    	sUrl = "collect_result.jsp?type=collect&id=" + id;
    	out.println("<a href='#' OnClick=\"javascript:FormSubmit(formUpdate, '" + sUrl + "');\">");
    	out.println(s[3]);
    	out.println("</a>");
    	out.println("<br>");    	
    }
    if (i==1 && !sUrl.equals("")) {
    	out.println("<script language='javascript'>");
    	out.println("formUpdate.action='" + sUrl + "';");
    	out.println("formUpdate.submit();");
    	out.println("</script>");    	
    }
%>    
    </td>     
  </tr>     

</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> 
