<%@ page contentType="text/html;charset=gbk" %>
<%@ 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.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%@ include file="sessionInfo2.jsp"%>
<html>
<head>
<BASE target=_self>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
  //类型
	String type = SzConvert.toSpaceStr(request.getParameter("type"));
	//控件
	String object = SzConvert.toSpaceStr(request.getParameter("object"));
	//模块
	String moduleName = SzConvert.toSpaceStr(request.getParameter("moduleName"));
	//System.out.println(object);
	ArrayList list = null;
	int i = 0;
	ArrayList listName = new ArrayList();
	String str_name[] = null;
	String strTitle = "";
  if (type.equals("listSelect")) {
	  strTitle = "列表选择关联名称：";
	  BdListSelect bdListSelect = new BdListSelect();
	  list = bdListSelect.getList();
	  BdListSelectInfo info = null;
	  
	  for (i=0; i<list.size(); i++) {
		  info = (BdListSelectInfo)list.get(i);
		  if (info.getModuleName().equals(moduleName)) {
			  str_name = new String[2];
			  str_name[0] = info.getGLSM();
			  str_name[1] = info.getGLBZ();
			  listName.add(str_name);
		  }
	  }
	  
  } else if (type.equals("trigger")) {
	  strTitle = "触发关联名称：";
	  BdTrigger bdTrigger = new BdTrigger();
	  list = bdTrigger.getList();
	  BdTriggerInfo info = null;
	  
	  for (i=0; i<list.size(); i++) {
		  info = (BdTriggerInfo)list.get(i);
		  if (info.getModuleName().equals(moduleName)) {
			  str_name = new String[2];
			  str_name[0] = info.getGLSM();
			  str_name[1] = info.getGLBZ();
			  listName.add(str_name);
		  }
	  }
  } else if (type.equals("printTemp")) {
	  OfficePrintTemp officePrintTemp = new OfficePrintTemp(0);
	  list = (ArrayList)officePrintTemp.getTemplateList(); 	  
	  OfficeTemplate officeTemplate = null;
	  for (i=0; i<list.size(); i++) {
		  officeTemplate = (OfficeTemplate)list.get(i);
		  if (SzConvert.toSpaceStr(officeTemplate.getAttrs().get("moduleName")).equals(moduleName)) {
			  str_name = new String[2];
			  str_name[0] = SzConvert.toSpaceStr(officeTemplate.getAttrs().get("name"));
			  str_name[1] = SzConvert.toSpaceStr(officeTemplate.getAttrs().get("desc"));
			  listName.add(str_name);
		  }
	  }  
	  
  }
    
%>    
<table width="100%">
  <form name="formUpdate" method="post" action="field_select.jsp">
  <input type="hidden" name="object" value="<%=object%>">
  <input type="hidden" name="type" value="<%=type%>">
  <input type="hidden" name="moduleName" value="<%=moduleName%>">
  <tr>
  	<td><%=strTitle%></td>
  </tr>
  <tr>
    <td><select name="field" size="20" style="width:240;" OnDblClick="javascript:Ok();" multiple>
<%
    
    String sName = "";
    String sValue = "";
    
       
    for (i=0; i<listName.size(); i++) {
    	str_name = (String[])listName.get(i);
    	sValue = str_name[0];
    	sName = "[" + str_name[0] + "]" + str_name[1]; 
%>
	<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 vObject = formUpdate.object.value;
		var oWindow = window.dialogArguments;
		
		var vValue = "";
		
		var vLen = formUpdate.field.length; 
		for (var i=0; i<vLen; i++) {
			if (formUpdate.field.options(i).selected == true) {
      	vValue+= "," + formUpdate.field.options(i).value;
			}
		}
		if (vValue.length > 0) {
		  vValue = vValue.substring(1,vValue.length);
		} 

    if (vObject != "" && vObject != "undefined" ) {
				eval("oWindow." + vObject + ".value='" + vValue + "';");		
		}
		window.close();
  }
</script>

