<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ 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.SzPageHelp" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ page import="net.sz600.formCreate.*" %>
<%@ include file="sessionInfo2.jsp"%>
<html>
<head>
<BASE target=_self>
<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>
<body>
<%
	String object = SzConvert.toSpaceStr(request.getParameter("object"));
	String strName = "选择字段";
	
	String moduleName = SzConvert.strWriteData(request.getParameter("moduleName"));
  String formName = SzConvert.strWriteData(request.getParameter("formName"));

    BdForm bdForm = new BdForm();
    String XML_str[] = bdForm.getXMLModuleList();    
    //根据moduleName获取响应的表单信息

    
%>    
<table width="100%">
  <form name="formUpdate" method="post" action="field_select.jsp">
  <input type="hidden" name="object" value="<%=object%>">
  <input type="hidden" name="navigator" value="<%=sNavigator_SESSION%>" >

  <tr>
    <td width="80">模块</td>
    <td><%=moduleName%> </td>
  </tr>    
  <tr>
    <td>表单</td>
    <td><%=formName%> </td>
  </tr>
  <tr>
    <td valign="top"><%=strName%></td>
    <td><select name="field" size="18" style="width:200;" OnDblClick="javascript:Ok();">
<%
    //根据
    BdFormTableInfo bdFormTableInfo = null;
    Collection collFormTable = null;
    if (!moduleName.equals("") && !formName.equals("")) {
    	collFormTable = bdForm.getTableList(moduleName, formName);
    }
    Iterator iterFormTable = null;
    if (collFormTable != null) {
      iterFormTable = collFormTable.iterator();
    }
    
    BdFormFieldInfo bdFormFieldInfo = null;
    Collection collFormField = null;
    Iterator iterFormField = null;
    if (!moduleName.equals("") && !formName.equals("")) {
    	collFormField = bdForm.getFieldList(moduleName, formName);
    }
    if (collFormField != null) {
      iterFormField = collFormField.iterator();
    }
    String sName = "";
    String sValue = "";
    
    String tableName = "";
    String tableId = "";    
    while (iterFormTable != null && iterFormTable.hasNext()) {
      bdFormTableInfo = (BdFormTableInfo)iterFormTable.next();
      if (bdFormTableInfo.getGLID().equals("") || bdFormTableInfo.getGLBM().equals("")) {
        continue;
      }
      tableName = bdFormTableInfo.getGLBM();
			tableId = bdFormTableInfo.getGLID();
      iterFormField = collFormField.iterator();
    	while ((iterFormField != null && iterFormField.hasNext())) {
    		bdFormFieldInfo = (BdFormFieldInfo)iterFormField.next();
        if (!tableId.equals(bdFormFieldInfo.getTableId())) {
          continue;
        }    		
		    sValue = tableName + "&" + bdFormFieldInfo.getZDMC();
		    sName = "[" + bdFormFieldInfo.getZDMC() + "]" + bdFormFieldInfo.getZDSM(); 
%>
	<option value="<%=sValue%>"><%=sName%></option>
<%    	  
    	}
    }
%></select>
    </td>
  </tr>  
  <tr>
    <td colspan="2" align="center"  class="trClassTitle">                        
      <input type="button" value="确定" class="btnClass" OnClick="Ok();">
      <input type="button" value="关闭" class="btnClass" OnClick="window.close();">
    </td>  
  </tr>    
  </form>
</table>
</body>
</html>
<script language="javascript">
  function Ok() {

	//取到字段的值
	var vIndex = 0;
	var vLen = 0;
	var vTable = "";

	var vObject = formUpdate.object.value;
		var navigator = formUpdate.navigator.value;
		var vField  = formUpdate.field.value;

	//var oWindow = window.dialogArguments;
	var oWindow = null;

	if (navigator == "MSIE") {
	  oWindow = window.dialogArguments;
	} else {
	  oWindow = window.opener;
	}
	//把表单名称，模块名称也填写过去。
	if (1==1) {
	    //格式为：表&字段
	    vIndex = vField.indexOf("&");
	    vLen = vField.length;	    
	    vTable = vField.substring(0,vIndex);
	    vField = vField.substring(vIndex + 1, vLen);
	    if (vObject != "" && vObject != "undefined" ) {
				eval("oWindow." + vObject + ".value='" + vField + "';");		
			}
	} 
	window.close();

  }
</script>

