<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ include file="../sessionInfo2.jsp"%>
<%
    strLevel_SESSION = "../../../";
    strSkin_SESSION = "../../../images/skin2_blue2";
%>
<html>
<body>
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<%
    int iRelateMaxCount = 1;
	//是否支持关联多表单，
	int iRelateMult = SzProperties.SYS_FORM_RELATEMULT;
	if (iRelateMult > 0) {
		iRelateMaxCount = 20;
	}
	String moduleName = SzConvert.strWriteData(request.getParameter("moduleName"));
	String formName = SzConvert.strWriteData(request.getParameter("formName"));
    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));	
	String id = SzConvert.strWriteData(request.getParameter("id"));
	BdRelateFormInfo relateInfo = null;
	BdRelateForm relateForm = new BdRelateForm();
    int i = 0;
    //列出跟本表单关联的组合.
    relateInfo = relateForm.getRelateInfo(id);
	if (relateInfo == null) {
		relateInfo = new BdRelateFormInfo();
		relateInfo.setModuleName(moduleName);
		relateInfo.setFormName(formName);
	}
	String popedom = SzConvert.toZeroStr(relateInfo.getPopedom());
%>
<!-----上面的工具栏------>
<form name="formUpdate" method="post" action="relateForm_control.jsp">
<%@ include file="/xml/formEngine2/title.jsp"%>
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="id" value="<%=id%>">
<table width="100%">
  <tr>
    <td>
      <%=SzPageHelp.saveButton()%>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>  
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">                
  <tr>
    <td>模块名称</td>
    <td><input type="text" name="moduleName" value="<%=relateInfo.getModuleName()%>" class="txtClass1" readonly></td>
    <td>表单名称</td>
    <td><input type="text" name="formName" value="<%=relateInfo.getFormName()%>" class="txtClass1" readonly></td>
  </tr>   
  <tr>
    <td>关联描述</td>
    <td colspan="3"><input type="text" name="desc" value="<%=relateInfo.getDesc()%>" class="txtClass2">
    </td>
  </tr>   
  <tr>
    <td>被关联的主表</td>
    <td><input type="text" name="relateTable" value="<%=relateInfo.getRelateTable()%>" class="txtClass1"  readonly></td>
    <td colspan="2">&nbsp;
      <% if ( 1 != 1 ) { %>
       允许被同级查询
      <input type="checkbox" name="queryType" value="1" <% if (relateInfo.getQueryType().equals("1")) { %>checked<% } %> >
      <% } %>
    </td>      
    <input type="hidden" name="relateForeign" value="<%=relateInfo.getRelateForeign()%>" class="txtClass1">    
  </tr>  
  <tr>
    <td>权限设置</td>
    <td colspan="3">
      <input type="radio" name="popedom" value="0" <%if (popedom.equals("0")) { %> checked <% } %> >权限被关联
      <input type="radio" name="popedom" value="1" <%if (popedom.equals("1")) { %> checked <% } %> >独立权限
      <input type="radio" name="popedom" value="2" <%if (popedom.equals("2")) { %> checked <% } %> >独立流程
      <input type="radio" name="popedom" value="3" <%if (popedom.equals("3")) { %> checked <% } %> >关联主流程
    </td>      
    <input type="hidden" name="relateForeign" value="<%=relateInfo.getRelateForeign()%>" class="txtClass1">    
  </tr>        
</table>  
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">                
  <tr class="trClassTitle">
  	<td>序号</td>
    <td>被关联的模块名称</td>
    <td>表单名称</td>
    <td>删除</td>
  </tr>  
<%
	ArrayList listForm = relateInfo.getRelateForm();
	Iterator iterForm = null;
	if (listForm != null) {
		iterForm = listForm.iterator();
	}
	String s[] = null;
	int iCount = 1;
	while (iterForm != null && iterForm.hasNext()) {
		s = (String[])iterForm.next();
%>
  <tr>
	<td><%=iCount%> </td>  
    <td><input type="text" name="moduleName_<%=iCount%>" value="<%=s[0]%>" ></td>
    <td><input type="text" name="formName_<%=iCount%>" value="<%=s[1]%>">
    <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectWin(<%=iCount%>);">
    </td>
    <td><input type="checkbox" name="delete_<%=iCount%>" value="1"></td>
  </tr>  
<%		
		iCount ++;
		if (iCount >= iRelateMaxCount) {
			break;
		}
	}	
	for (i = iCount; i<=iRelateMaxCount; i++) {
%>
  <tr>
  	<td><%=i%> </td>
    <td><input type="text" name="moduleName_<%=i%>" readonly></td>
    <td><input type="text" name="formName_<%=i%>" readonly>
    <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectWin(<%=i%>);">
    </td>
    <td><input type="checkbox" name="delete_<%=i%>" value="1"></td>
  </tr>
<%		
	}
%>  
  <input type="hidden" name="count" value="<%=i%>">
</table>

</form>
<script language="javascript" src="../../../share/js/commonTool.js"></script>
<script language="javascript">

  //提交到控制保存的页面
  function FormSave() {

    //关联名称不能为空
    if (!notSpace(formUpdate.desc, "关联描述")) {
      return false;
    }      
    if (!notSpace(formUpdate.relateTable, "被关联的主表")) {
      return false;
    }        
    
    formUpdate.action = "relateForm_control.jsp";
    formUpdate.submit();
  } 
  
  function SelectWin(vIndex) {
    var relateTable = formUpdate.relateTable.value;
    var relateForeign = formUpdate.relateForeign.value;
    var url = "relateForm_select.jsp?relateTable=" + relateTable + "&relateForeign=" + relateForeign + "&detailIndex=" + vIndex;
    window.showModalDialog(url,window,"status=no;dialogWidth=200px;dialogHeight=370px");  
  }    
</script>

</body>
</html>
<!-- 
<iframe name="submitName" style='display:none;'></iframe>
 -->