<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ 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.*" %>
<%@ 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=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 = "-2";
	}	
  //取得表单的信息
  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"))); 
		String datefield = SzConvert.strWriteData(request.getParameter("datefield"));   //日期字段，     
    
    BdFormControl bdFormControl = new BdFormControl();
    
    //字段信息
    bdFormControl.getMapStatic(moduleName, formName);
    
    //2011-12-07 增加：可以去掉明细表字段的查询
    bdFormControl.getFormInfo(moduleName, formName);
    String detailTableId = bdFormControl.detailTableId;
    
    Map fieldMap = bdFormControl.getFieldMap();
    BdFormFieldInfo bdFormFieldInfo = null;
    Collection collFormField = null;
    collFormField = (Collection)fieldMap.get(new String(moduleName + "-" + formName));
    Iterator iterFormField = null;  
    
    String sSearchCond = SzConvert.strWriteDataHTML(request.getParameter("searchCond"));
		BdFormHelp bdFormHelp = new BdFormHelp();
		ArrayList list = bdFormHelp.spliSearchCond(sSearchCond);
		
%>    
<%@ include file="title.jsp"%>
<table width="700" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
<form name="formUpdate" method="post">
  <input type="hidden" name="FormID" value="<%=iFormID%>">
  <input type="hidden" name="From" value="<%=iFrom%>">   
  <input type="hidden" name="datefield" value="<%=datefield%>">     
  <tr class="trClassTitle2">
  	<td>字段名称</td>
  	<td>条件</td>
  	<td>值</td>
  	
  	<td>字段名称</td>
  	<td>条件</td>
  	<td>值</td> 	
  </tr>
  
<%
    if (collFormField != null) {
    	iterFormField = collFormField.iterator();
    }
    int i =0;
    int j = 0;
    String s_name[] = {"包含","等于","大于","大于等于","小于","小于等于"};
    String s_id[] = {"1","0","2","3","4","5"};   
    
    String field = "";
    String cond = "";
    String value = "";
    String str[] = null;

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

  %>  	
  	<td>
  	  <input type="hidden" name="field<%=j%>" value="<%=field%>">
  	  <%=bdFormFieldInfo.getZDSM()%>&nbsp;
  	</td>
  	<td><%=SzPageHelp.idSelectArray(s_name, s_id, "cond" + j, cond, "")%>&nbsp;</td>
  	<td><input type="text" name="value<%=j %>" class="txtClass120" value="<%=value%>">&nbsp;</td>
  </tr>
<%	
		i = i+ 2;
	}
%>
  <tr>
    <td colspan="6" align="left">
      <%=SzPageHelp.button("查询","javascript:FormSubmit(formUpdate, 'searchOk.jsp?type=search');")%>
      <%=SzPageHelp.backButton()%>
      <%
      	if (iFrom == 2) {
      	  String s_id2[] = {"-1","0","1","2"};
      	  String s_name2[] = {"全部","办理中","否决","办结"};
      	  out.println(SzPageHelp.radioSubmit("flowType", s_id2, s_name2, flowType));
      	}
      %>        
    </td>
  </tr>  
  <input type="hidden" name="count" value="<%=i %>">
</form>
</table>
<!-----这里包含要提交的内容--->
<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%>"> 
  <input type="hidden" name="datefield" value="<%=datefield%>">  
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  function FormSave(formName, url) {
    formName.action = url;
    formName.submit();      
  }   
 
</script> 
