<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ 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>
<%
    String moduleName = "";
    String formName = "";
    String objId = SzConvert.toSpaceStr(request.getParameter("objId"));	
    String sFormID = SzConvert.toZeroStr(request.getParameter("FormID"));  //表单ID 
    //根据表单取得moduleName, formName
    LcForm lcForm = new LcForm();
    LcFormInfo lcFormInfo = null;
    lcFormInfo = (LcFormInfo)lcForm.getInfoByKey(Integer.parseInt(sFormID));
    if (lcFormInfo != null) {
    	moduleName = lcFormInfo.getBDLJ();
    	formName = lcFormInfo.getBDBY1();
    }
%>

<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td align="center">
      <input type="button" value="确定" OnClick="javascript:Ok();">&nbsp;
    </td>
  </tr>
  </form>
</table>
<!-----信息列表----->
<%
    BdFormControl bdFormControl = new BdFormControl();
    bdFormControl.getMapStatic(moduleName, formName);
    Map formMap  = bdFormControl.getFormMap();
    Map tableMap = bdFormControl.getTableMap();
    Map fieldMap = bdFormControl.getFieldMap();
    
	BdFormInfo bdFormInfo = null;
	bdFormInfo = (BdFormInfo)formMap.get(new String(moduleName + "-" + formName));  
    if (bdFormInfo == null) {
      bdFormInfo = new BdFormInfo();
    }
    
	BdFormTableInfo bdFormTableInfo = null;
	Collection collFormTable = null;
	collFormTable = (Collection)tableMap.get(new String(moduleName + "-" + formName));
	Iterator iterFormTable = null;

	//字段信息
	BdFormFieldInfo bdFormFieldInfo = null;
	Collection collFormField = null;
	collFormField = (Collection)fieldMap.get(new String(moduleName + "-" + formName));
	Iterator iterFormField = null;    

    if (collFormTable != null) {
      iterFormTable = collFormTable.iterator();
    }

    if (collFormField != null) {
      iterFormField = collFormField.iterator();
    }
%>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formUpdate" method="post">
  <input type="hidden" name="moduleName" value="<%=moduleName%>">
  <input type="hidden" name="formName" value="<%=formName%>">
  <input type="hidden" name="FormID" value="<%=sFormID%>"> 
  <input type="hidden" name="objId" value="<%=objId%>"> 
  <tr class="trClassTitle">
    <td width="45">&nbsp;</td>
    <td>字段名</td>
    <td>中文名</td>

    <td width="45">&nbsp;</td>    
    <td>字段名</td>
    <td>中文名</td>
    
    <td width="45">&nbsp;</td>    
    <td>字段名</td>
    <td>中文名</td>
        
  </tr>   
<%
    int j = 0;
    int i = 0;
    String tableName = "";
    String tableId = "";
    String objectStr = "";
    String tableType = "";
    LcFieldPopedom lcFieldPopedom = new LcFieldPopedom();
    String strPopedom = "";
   
       

    String sCheck = "";
    while (iterFormTable != null && iterFormTable.hasNext()) {
        bdFormTableInfo = (BdFormTableInfo)iterFormTable.next();
        if (bdFormTableInfo.getGLBM().equals("")) {
            continue;
        }
        if (bdFormTableInfo.getGLLX().equals("1")) {
            continue;
        }        
        tableName = bdFormTableInfo.getGLBM();
        tableId = bdFormTableInfo.getGLID();
        //读取字段
        i=0;
        
        //本表已经设置的

%>
  <tr class="trClassTitle">
    <td colspan="20" align="left">对应的表：<%=bdFormTableInfo.getGLSM()%>&nbsp;<%=bdFormTableInfo.getGLBM()%>
      <input type="hidden" name="QXBM<%=j%>" value="<%=bdFormTableInfo.getGLBM()%>">
      &nbsp;
      <input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formUpdate, chkCheckAll, 'QXZDMC<%=j%>');">全选
    </td>
  </tr>
<%
        sCheck = "";
        iterFormField = collFormField.iterator();
        while ((iterFormField != null && iterFormField.hasNext())) {
            bdFormFieldInfo = null;
            if (iterFormField != null && iterFormField.hasNext()) {
                bdFormFieldInfo = (BdFormFieldInfo)iterFormField.next();
            }
            if (!tableId.equals(bdFormFieldInfo.getTableId())) {
                continue;
            }
            //字段是隐藏的，跳过

            if (i==0) {
            	out.println("<tr>");
            }
            sCheck = "";
            if (strPopedom.indexOf("," + tableName + "-" + bdFormFieldInfo.getZDMC() + ",") >=0) {
              sCheck = "checked";
            };
%>
    <td align="center"><input type="checkbox" name="QXZDMC<%=j%>" value="<%=bdFormFieldInfo.getZDID()%>" <%=sCheck%> ></td>
    <td align="left"><%=bdFormFieldInfo.getZDMC()%></td>
    <td align="left"><%=bdFormFieldInfo.getZDSM()%></td>
<%
            i ++;
            if (i==3) {
            	i = 0;
				out.println("</tr>");
			}
       } //while ends
       if (i < 3) {
       	   for (int k=i; k<3; k++) {
    	       out.println("<td>&nbsp;</td>");
    	       out.println("<td>&nbsp;</td>");
    	       out.println("<td>&nbsp;</td>");
           }
       	   out.println("</tr>");
       }
       j++;
   }
%>
   <input type="hidden" name="tableCount" value="<%=j%>" >
  </form>
</table>

<br>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  function Ok() {
    //选中了哪些字段？
    var tableCount = parseInt(formUpdate.tableCount.value);
    var vObj = "";
    var vValue = "";
    for (var i=0; i<tableCount; i++) {
	vObj = eval("formUpdate.QXZDMC" + i)
       //里面还有多个
       vValue  += ValueOfCheck(vObj);
    }	
    var objId = formUpdate.objId.value;
    var oWindow = window.dialogArguments;
    eval("oWindow." + objId + ".value='" + vValue + "';");
    window.close();
  }


</script>
