<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ page import="net.sz600.formCreate.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.tool.*" %>
<%@ page import="java.util.*" %>
<%@ include file="sessionInfo2.jsp"%>
<head>
<title>数飞表单引擎</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>

<%
    BdForm bdForm = new BdForm();
    String XML_str[] = bdForm.getXMLModuleList();
    int iLen = XML_str.length;  
    String sModule = SzConvert.toSpaceStr(request.getParameter("module")); 
    if (!sModule.equals("") && !sModule.endsWith(".xml")) {
    	sModule = sModule + ".xml";
    }
    BdFormControl formControl = new BdFormControl();
	  if (!net.sz600.check.SzHasp.getInstance().checkFormEdit(sModule)) {
		  out.println("<font color='red'>[提示]本授权的版本不能使用表单引擎</font>");
  		return;
  	} 	
	  
	  BdModule bdModule = new BdModule();	  
	  ArrayList list = bdModule.getModuleList();
	  String str_module[] = null;
	    
		String cate_pro = SzConvert.strWriteData(request.getParameter("cate_pro") );
		String cate_fun = SzConvert.strWriteData(request.getParameter("cate_fun") );
		BdFormHelp formHelp = new BdFormHelp();
				
%>
<!-----上面的工具栏------>
<%@ include file="title.jsp"%>
<table width="100%">
  <form name="form" method="post" action="formIndex.jsp">
  <input type="hidden" name="OPERATOR" value="">
  <tr>
    <td>
      按行业分类：
    	<%
    		out.println(formHelp.professionSelectButton("cate_pro", cate_pro, "this.form.submit()"));
    	%>      
      按功能分类：
    	<%    		
    		out.println(formHelp.functionSelectButton("cate_fun", cate_fun, "this.form.submit()"));
    	%>   
    	    
      请选择模块：
    	<%    		
    		out.println(SzPageHelp.selectArrayFunc(list, 0, 0,1,8,"module", sModule, "txtClass200","simpleform.xml", 5, cate_pro,6, cate_fun, "this.form.submit()"));
    	%>        

    </td>
  </tr>
  </form>
</table>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass"
       cellpadding="3" cellspacing="0" align="center">
  <tr class="trClassTitle">
    <td width="30">&nbsp;</td>  
    <td width="150">表单名称</td>
    <td width="150">中文名</td>   
    <!--  
    <td>表格名称</td>
    --> 
    <td>操作</td>
  </tr>
<%
		Collection collForm = null;
    Iterator iterForm = null;
    String sFormName = "";
    String formID = "";
    BdFormInfo bdFormInfo = null;
    boolean hasFlow = false;
    String assistant = "";
    String sTableName = "";
    String sTemp = "";
    BdRelateForm bdRelateForm = new BdRelateForm();
		String sRelateButton = "";
		int iCount = 0;
		String sModuleInfo = "";
		int j = 0;
		int k = 0;
    for (int i=0; i<iLen; i++) {
    	if (!sModule.equals("") && !sModule.equals(XML_str[i])) {
    		continue;
    	}
    	if (!isSystemManager_SESSION && XML_str[i].startsWith("manage.xml") && XML_str[i].equals("simpleform.xml") ) {
    		continue;
    	}

    	if (XML_str[i].equals("log.xml") || XML_str[i].equals("manage.xml")) {
    		continue;
    	}
    	
    	//取得模块信息
    	str_module  = bdModule.getModuleInfo(XML_str[i]);
    	if (str_module == null) {
    		continue;
    	}
    	
    	if (!cate_pro.equals("") && !cate_pro.equals(str_module[5])) {
    		continue;
    	}
    	if (!cate_fun.equals("") && !cate_fun.equals(str_module[6])) {
    		continue;
    	} 
    	
    	sModuleInfo = "模块名称：" + str_module[0]
    	            + "\n中文名称：" + str_module[1]
    	            + "\n功能介绍：" + str_module[2]
    	            + "\n行业分类：" + str_module[5]
    	            + "\n功能分类：" + str_module[6];   
    	
    	collForm = bdForm.getFormInfoList(XML_str[i]);
    	j ++;
%>
  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td colspan="3" title="<%=sModuleInfo%>" style="cursor:hand;height:50px;"><b>模块(<%=j %>)：</b><%=XML_str[i]%> <%=str_module[1]%></td>
    <td>
    <% if (isBarManager_SESSION) { %>
      <a href="formUpdate.jsp?moduleName=<%=XML_str[i]%>&OPERATOR=NewForm">增加新表单</a>
      <% if (collForm.size() > 0) { %>
      <% 
      		sTemp = "formControl.jsp?moduleName=" + XML_str[i] + "&OPERATOR=AddModule";
      		out.println(SzPageHelp.operatorFunc("加进菜单","GoUrlConfirm('" + sTemp + "','确定要把功能加到系统菜单中，确定后请刷新菜单')")); 
      %>
      <a href="#" OnClick="javascript:ReCreateTable('<%=XML_str[i]%>', '', 'CreateTable');">重新创建表</a>      
      <a href="formControl.jsp?moduleName=<%=XML_str[i]%>&OPERATOR=SaveTemplate">存为模板</a>
      <% } %>      
    <% } %>&nbsp;
    </td>
  </tr>
<%
      //根据
      iterForm = collForm.iterator();
      while (iterForm != null && iterForm.hasNext()) {
    		bdFormInfo = (BdFormInfo)iterForm.next();  
    		formID = bdFormInfo.getFormId();
        sFormName = bdFormInfo.getFormName();
        assistant = bdFormInfo.getAssistant();
        hasFlow = false;
        if ( bdFormInfo.getHasFlow().equals("1")) {
        	hasFlow = true;
        }
        
        //检查是否已经设置了关联
        if (bdRelateForm.hasRelateForm(XML_str[i], sFormName)) {
        	sRelateButton = "<font color='red'>下级表单</font>";
        } else {
        	sRelateButton = "下级表单";
        }
        
        //表单的属性显示：附件、编辑器、weboffice、列表关联、打印模板、触发关联、是否有表、是否异常
        k++;
%>
  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
  	<td width="30" align="center"><%=k%></td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;<%=sFormName%></td>
    <td><%=bdFormInfo.getFormDesc()%>&nbsp;</td> 
    <td><%=sTableName%>
    <% if (isBarManager_SESSION) { %>    
      <font color='blue'>【基本】</font><a href="formUpdate.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>&OPERATOR=UpdateForm">修改</a>

      <%if (!bdFormInfo.getLock().equals("1") ) { %>
      <a href="#" onClick="javascript:DeleteForm('<%=XML_str[i]%>','<%=sFormName%>');">删除</a>
      <a href="javascript:EditUI('<%=XML_str[i]%>','<%=sFormName%>');">编辑界面</a>
      <a href="formField.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">字段属性</a>
      <% } %>  
      <br>
      <font color='blue'>【辅助】</font><%if (!bdFormInfo.getLock().equals("1") ) { %><a href="#" OnClick="javascript:ReCheckTable('<%=XML_str[i]%>', '<%=sFormName%>', 'FormTableCreate');">重建表</a>
      <a href="#" OnClick="javascript:ReCheckTable('<%=XML_str[i]%>', '<%=sFormName%>', 'FormTableCheck');">检测表</a>
      <% 
      		sTemp = "formControl.jsp?PMKID=5024&moduleName=" + XML_str[i] + "&formName=" + sFormName + "&OPERATOR=AddModule2";
      		out.println(SzPageHelp.operatorFunc("加进菜单","GoUrlConfirm('" + sTemp + "','确定要把表单功能加到系统菜单中，确定后请刷新菜单')")); 
      %>      
      <a href="formFieldIndex.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">字段索引</a>
      <% } %>
      <a href="formCopy.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>&OPERATOR=CopyForm">复制到</a>

			<br>
			<font color='blue'>【测试】</font><% if (!hasFlow) { %><a href="../../share/formEngine2/index.jsp?FormID=<%=formID%>">列表</a>
      <% } else { %><a href="../../share/formEngine2/index.jsp?FormID=<%=formID%>">列表</a>
      <a href="../../share/formEngine2/index_transact.jsp?FormID=<%=formID%>">待办</a>  
      <a href="../../share/formEngine2/index_transacted.jsp?FormID=<%=formID%>">已办</a>
      <a href="../../share/formEngine2/index_manage.jsp?FormID=<%=formID%>">管理</a>

      
			<% if ((";" + assistant + ";").indexOf(";11;") >=0) {  %>
			<a href="../../share/formEngine2/index_transact_all.jsp?FormID=<%=formID%>">批量办理</a>
			<% } %>
			
			<% if ((";" + assistant + ";").indexOf(";12;") >=0) {  %>
			<a href="../../share/formEngine2/index_receive.jsp?FormID=<%=formID%>">待阅</a>
			<% } %>			
			
			<% if ((";" + assistant + ";").indexOf(";6;") >=0) {  %>
			<a href="../../flow/press/index.jsp?FormID=<%=formID%>&type=0">催办</a>
			<% } %>

			<% if ((";" + assistant + ";").indexOf(";7;") >=0) {  %>
			<a href="../../flow/press/index.jsp?FormID=<%=formID%>&type=1">跳签</a>
			<% } %>

			<% if ((";" + assistant + ";").indexOf(";8;") >=0) {  %>
			<a href="../../share/formEngine2/stat_transact_depart.jsp?FormID=<%=formID%>">部门办理统计</a>
			<% } %>

			<% if ((";" + assistant + ";").indexOf(";9;") >=0) {  %>
			<a href="../../share/formEngine2/stat_transact_user.jsp?FormID=<%=formID%>">个人办理统计</a>
			<% } %>
      
      <% } %> 
      <br>     
    <% } %>         
  		<%=formHelp.formProperty(XML_str[i], bdFormInfo) %>
    </td>
  </tr>
<%
				iCount++;
      }
    }
%>
  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'" >
    <td colspan="10" class="trClassTitle2"><b>已创建表单数量：<%=iCount%></b></td>
  </tr>
</table>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //增加一个XML模块配置文件
  function SaveXMLModule() {
    if (form.moduleName.value == "") {
      form.moduleName.focus();
      alert("模块名称不能为空");
      return;
    }
    if (!isLetterOrNumOrLine(form.moduleName.value)) {
      alert("模块名称有不允许的字符");
      form.moduleName.focus();
      return false;
    }    
    form.action = "formControl.jsp";
    form.OPERATOR.value = "XMLModule";
    form.submit();
  }
  
  function EditUI(moduleName, formName) {
  	var url = "formEdit.jsp?moduleName=" + moduleName + "&formName=" + formName;
    window.open(url, '', 'left=20,top=20,scrollbars=yes,resizable=yes,status=yes,width=1100,height=720');
  }
    
  function DeleteForm(moduleName, formName) {
  	if (confirm("确定要删除?")) {
  		if (confirm("删除后本表单的相关数据将无法恢复，是否继续?")) {
  			var vUrl = "formControl.jsp?moduleName=" + moduleName + "&formName=" + formName + "&OPERATOR=DeleteForm";
  			document.location.href = vUrl;
  		}  	
  	}
  }
  
  //重新创建表
  function ReCreateTable(moduleName, formName, operator) {
  	var vUrl = "formControl.jsp?moduleName=" + moduleName;
  	if (formName != "") {
		vUrl += "&formName=" + formName;
		
  	}
  	vUrl += "&OPERATOR=" + operator;
  	if (confirm("重新创建表将丢失已录入的数据,是否继续?")) {
		document.location.href = vUrl;
  	}  	
  }
  
  function ReCheckTable(moduleName, formName, operator) {
  	var vUrl = "formCheck.jsp?moduleName=" + moduleName + "&formName=" + formName;
  	vUrl += "&OPERATOR=" + operator;
		document.location.href = vUrl;
  }  
</script>