<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ 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=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>

<%
    BdForm bdForm = new BdForm();
    String XML_str[] = new String[1];
    int iLen = XML_str.length;       
    String sModule = "simpleform.xml";
    XML_str[0] = sModule;    
%>
<!-----上面的工具栏------>
<%@ include file="simpleTitle.jsp"%>
<table width="100%">
  <form name="form" method="post" action="formIndex.jsp">
  <input type="hidden" name="OPERATOR" value="">
  <tr>
    <td>
     <% if (isBarManager_SESSION) { %>        
      <input type="button" class="btnClass120" value="增加新表单" title="增加新表单" 
       OnClick="javascript:document.location.href='formUpdate.jsp?moduleName=<%=sModule%>&OPERATOR=NewForm'" >
      <input type="button" class="btnClass120" value="加进菜单" title="加进菜单" 
       OnClick="javascript:document.location.href='formControl.jsp?moduleName=simpleform.xml&OPERATOR=AddModule'" >       
     <% } %> 
    </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>表单名称</td>
    <td>中文名</td>   
    <!--  
    <td>表格名称</td>
    --> 
    <td>操作</td>
    <td>删除</td>
  </tr>
<%

    Iterator iterForm = null;
    String sFormName = "";
    String formID = "";
    BdFormInfo bdFormInfo = null;
    boolean hasFlow = false;

    String sTableName = "";
    String sTemp = "";
    BdRelateForm bdRelateForm = new BdRelateForm();
		String sRelateButton = "";
		int i = 0;
		int iCount = 0;
		BdFormControl bdFormControl = new BdFormControl();
		int iMax = bdFormControl.getInvalidCount(sModule);
%>
<%
      //根据
      iterForm = bdForm.getFormInfoList(XML_str[i]).iterator();
      while (iterForm != null && iterForm.hasNext()) {
    	bdFormInfo = (BdFormInfo)iterForm.next();  
    	formID = bdFormInfo.getFormId();
        sFormName = bdFormInfo.getFormName();
        hasFlow = false;
        if ( bdFormInfo.getHasFlow().equals("1")) {
        	hasFlow = true;
        }
        sTableName  = bdForm.getTableStr(XML_str[i], sFormName);
        sTemp = "";
        if (bdFormInfo.getDesktop() > 0) {
        	sTemp += "<img width='14' height='14'  src='../../images/share/destop.gif' border='0'>";
        }
        if (bdFormInfo.getToolbar().endsWith(".gif")) {
        	sTemp += "<img width='14' height='14' src='../../images/share/top/" + bdFormInfo.getToolbar() + "' border='0'>";
        }
        sTemp += sFormName;
        
        //检查是否已经设置了关联
        if (bdRelateForm.hasRelateForm(XML_str[i], sFormName)) {
        	sRelateButton = "<font color='red'>设置关联</font>";
        } else {
        	sRelateButton = "设置关联";
        }
%>
  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td>&nbsp;&nbsp;&nbsp;&nbsp;<%=sTemp%></td>
    <td><%=bdFormInfo.getFormDesc()%>&nbsp;</td> 
        <!--    
    <td><%=sTableName%>&nbsp;</td>
         -->
    <td>
    <% if (isBarManager_SESSION) { %>    
      <a href="formUpdate.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>&OPERATOR=UpdateForm">修改</a>

      <%if (!bdFormInfo.getLock().equals("1") ) { %>
      <a href="javascript:EditUI('<%=XML_str[i]%>','<%=sFormName%>');">编辑界面</a>
      <a href="formField.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">字段属性</a>
      <a href="stat_index.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">设置统计</a>
      <a href="collect_index.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">设置汇总</a>
      <% } else { %>
      编辑界面
      字段属性
      <% } %><br>
      【辅助】
      <%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>
      <a href="formControl.jsp?PMKID=100&moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>&OPERATOR=AddModule2">加进菜单</a>
      <% } %>
      表单ID:<%=formID %>&nbsp;
    <% } %>         
      <% if (!hasFlow) { %>    
       【测试】<a href="../../share/formEngine2/update.jsp?OPERATOR=add&moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">添加</a>
        <a href="../../share/formEngine2/index.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">列表</a>
      <% } else { %>
       【测试】<a href="../../share/formEngine2/update.jsp?OPERATOR=add&moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">申请</a> 
      <a href="../../share/formEngine2/index.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">列表</a>
      <a href="../../share/formEngine2/index_transact.jsp?moduleName=<%=XML_str[i]%>&formName=<%=sFormName%>">待办</a>
      <% } %> &nbsp; 
    </td>
    <td align="center">
      <%if (!bdFormInfo.getLock().equals("1") && isBarManager_SESSION ) { %>
      <a href="#" onClick="javascript:DeleteForm('<%=XML_str[i]%>','<%=sFormName%>');">删除</a>
      <% } else {%>
      &nbsp;
      <% } %>      
    </td>
  </tr>
<%
			iCount++;
      }
%>
  <tr onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'" >
    <td colspan="10" class="trClassTitle2">
    <b>已创建表单数量：<%=iCount%>&nbsp;&nbsp;授权自定义的表单数量：<%=iMax%></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 DeleteModule(vModuleName) {
	var theResponse = window.prompt("请输入删除的密码：");
	if (theResponse == "xiaomutou") {
	  var vUrl = "formControl.jsp?moduleName=" + vModuleName + "&OPERATOR=DeleteModule";
	  document.location.href = vUrl;	  
	} else {
	  alert("密码不正确，不能删除模块");
	}  
  }
  
  function DeleteForm(moduleName, formName) {
  	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>
