<%@ page contentType="text/html; charset=GBK"  errorPage="../../../error.jsp" %>
<%@ page import = "zr.zrpower.collectionengine.service.ConfigService"%>

<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.common.web.SelectBox" %>
<%@ page import = "zr.zrpower.collectionengine.CollectionInfo" %>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.*" %>
<%
ConfigService configManage = new ConfigService();
UIService userUI =new UIService();
SessionUser user = (SessionUser)session.getAttribute("userinfo");
String ID=request.getParameter("SelectedItems");
CollectionInfo[] bg=configManage.allListConfig(ID.trim());

SelectBox sb = new SelectBox(configManage.getTableList());
String[][] fields = configManage.getFieldList1(bg[0].getMAINTABLE());
SelectBox sb1 = new SelectBox(fields);

%>
<HTML>
<HEAD>
<TITLE>文档配置编辑</TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK type="text/css" rel="stylesheet" href="../../../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/script/Public.js"></SCRIPT>
<script type='text/javascript' src='../../../dwr/engine.js'></script>
<script type='text/javascript' src='../../../dwr/util.js'></script>
<script type='text/javascript' src='../../../dwr/interface/CollConfigBean.js'></script>
<script language="JavaScript" type="text/javascript">
<!--
 // 加载字段下拉列表。
    function loadFieldList(tableid){
        if(tableid==null||tableid==''){
        clearFieldSel();
        return;
        }

        CollConfigBean.getFieldList(tableid,
        function(items){
              clearFieldSel();
              dwr.util.addOptions("OTHERFIELD",items,0,1);
        }
        );

    }


    function clearFieldSel(){
        dwr.util.removeAllOptions("OTHERFIELD");
    }
// 加载字段下拉列表。
    function loadFieldList1(tableid){
        if(tableid==null||tableid==''){
        clearFieldSel1();
        return;
        }

        CollConfigBean.getFieldList(tableid,
        function(items){
              clearFieldSel1();
              dwr.util.addOptions("PHOTOFIELD",items,0,1);
              dwr.util.addOptions("PHOTOCFIELD",items,0,1);
              dwr.util.addOptions("PHOTOMFIELD",items,0,1);

        }
        );
    }


    function clearFieldSel1(){
        dwr.util.removeAllOptions("PHOTOFIELD");
        dwr.util.removeAllOptions("PHOTOCFIELD");
        dwr.util.removeAllOptions("PHOTOMFIELD");
    }
function bak()
{
  window.location.href='MainInfo.jsp?SelectedItems=<%=bg[0].getID()%>';
}
//有效性检察
function Check(theForm){
  if (theForm.DOCNAME.value == ""){

   <%if("6".equals(user.getUserWINDOWTYPE())){%>
    parent.layer.alert('文档名称不能为空!', {icon: 7});
    <%}else{%>
    alert("文档名称不能为空！");
    <%}%>
    theForm.DOCNAME.focus();
    document.form1.reset();
    return;
  }
document.form1.submit();
}

function ShowModalTableTree()
{
  var url="SelectTableTree.jsp";
  var status="dialogHeight:450px;dialogWidth:250px;status:0;help:no;center:yes";
  var rtnResult=window.showModalDialog(url,window,status);
  if (rtnResult!=null)
  {
     document.form1.MAINTABLE.value = rtnResult;
     loadFieldList(rtnResult);
  }
}
-->
</script>
</HEAD>
<BODY class="BodyMain">
<form action="../../../actionsubconfigmsg.do" method="post" name="form1" onsubmit="return Check(this);">
<%
if(bg!=null)
{
  %>
<input type="hidden" name="ID" value='<%=ID%>'>
<input type="hidden" name="DOCTYPE" value="<%=bg[0].getDOCTYPE()%>">
<input type="hidden" name="TEMPLAET" value='<%=bg[0].getTEMPLAET()%>'>


<DIV id="divMessage" style='padding-left:0;padding-top:0;width:99%;height:100%;overflow:auto'>
           <br>&nbsp;
           <fieldset style="width: 98%">
           <legend>文档配置编辑</legend>
           <TABLE  width="100%" align="center" border="0">
            <TR>
             <TD colspan=2 height=5>
             <input class="input" type="hidden" name="Act" value="edit" />
             </TD>
             </TR>
             <TR>
               <TD class="PutdSet" width="15%">文档名称：</TD>
               <TD><input class="text" type="text" name="DOCNAME" size="80" maxlength="200" value="<%=bg[0].getDOCNAME()%>"><Font class="WriteSign">&nbsp;*</Font></TD>
             </TR>
             <TR>
               <TD class="PutdSet" width="14%">模板：</td>
               <TD><%=bg[0].getTEMPLAET()%></td>
             </TR>
             <TR>
               <TD class="PutdSet" width="15%"></TD>
               <TD>

                 <div style="display:'none'">
                 <select style="width:280px" name="MAINTABLE" id="MAINTABLE" onchange="loadFieldList(this.value)">
                 <%
                  sb.setSelected(bg[0].getMAINTABLE());
                  out.println(sb.show());
                  %>
                   </select>
                 </div>

               </TD>
             </TR>
              <TR>
               <TD class="PutdSet" width="15%">关联主键：</TD>
               <TD><select style="width:280px" name="OTHERFIELD" id="OTHERFIELD">
              <%
                  sb1.setSelected(bg[0].getOTHERFIELD());
                  out.println(sb1.show());
                  %>
             </select></TD>
             </TR>

          </table>

          <br>
          </fieldset>
               <center><br>
                 <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <%=userUI.ClickButton("保存","JavaScript:if(Check(document.form1)){document.form1.submit();}","buttonSave.gif",user.getUserImage())%>
                 <%=userUI.ClickButton("返回","JavaScript:bak();","buttonReturn.gif",user.getUserImage())%>
                 </tr></table>
                 <br>
                 </center>
  </DIV>


  <%
}
%>
</FORM>
</BODY>
</HTML>
<%
//清空相关对象
user = null;
userUI = null;
configManage = null;
sb = null;
bg = null;
sb1 = null;
%>
