<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ include file="sessionInfo2.jsp"%>
<%
  String strLevel = "../../";
%>
<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">
<style type="text/css">
  .readClass {
      background:#D4D0C8;
      readonly;
  }
  .selectClass {
      width:70;
  }  
</style>
</head>
<%
    //获取提交的参数
    String moduleName = SzConvert.toSpaceStr(request.getParameter("moduleName"));
    String formName = SzConvert.toSpaceStr(request.getParameter("formName"));

    String readonly = "";
    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));
    if (sOPERATOR.equals("UpdateForm")) {
        readonly = "readonly";
    }
    //读取formInfo
    BdForm bdForm = new BdForm();
    BdFormInfo bdFormInfo = new BdFormInfo();
    if (!moduleName.equals("") && !formName.equals("")) {
        bdFormInfo = (BdFormInfo)bdForm.getFormInfo(moduleName, formName);        
    } else {
    	//bdFormInfo.setPrefix("XX");
    	
    }
    BdFormControl formControl = new BdFormControl();
		boolean isFormEngine = formControl.isFormEngine(moduleName);
    String assistant = bdFormInfo.getAssistant();
    if (sOPERATOR.equals("NewForm")) {
    	assistant = BdFormHelp.Assistant_Read + "," + BdFormHelp.Assistant_Office;
    }
		
%>
<body>

<!-----上面的工具栏------>
<form name="formUpdate" method="post">
	<input type="hidden" name="formId" value="<%=bdFormInfo.getFormId()%>">
  <input type="hidden" name="moduleName" value="<%=moduleName%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
<%@ include file="/xml/formEngine2/title.jsp"%>

<table width="100%">
  <tr>
    <td>
      <%=SzPageHelp.saveButton()%>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0"> 
<% if (isFormEngine) { %>
  <tr>
    <td class="tdClassTitle" style="width:200;" title="<%=bdFormInfo.getFormId() %>">选择模板</td>
    <td colspan="3"><input type="text" name="moduleNameTemp" class="txtClass1R" value="" readonly>
    <input type="text" name="formNameTemp" class="txtClass1R" value="" readonly>
    <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectWin();">
    </td>
  </tr> 
<% } %>
  <tr>
    <td class="tdClassTitle" style="width:200;" title="<%=bdFormInfo.getFormId() %>">表单名称(英文名)</td>
    <td colspan="3"><input type="text" name="formName" class="txtClass1" value="<%=bdFormInfo.getFormName()%>" <%=readonly%>>
    <font color="red">*</font>[可用字母、数字、下划线的组合]</td>
  </tr>
  <tr>
    <td class="tdClassTitle" style="width:200;">表单描述(中文名)</td>
    <td colspan="3"><input type="text" name="formDesc" class="txtClass1" value="<%=bdFormInfo.getFormDesc()%>">
    <font color="red">*</font>&nbsp;
    
    </td>
  </tr>
  <tr>
    <td class="tdClassTitle" style="width:200;">附件数据表名</td>
    <td colspan="3"><input type="text" name="hasAnnex" class="txtClass200R" value="<%=bdFormInfo.getHasAnnex()%>" readonly>
    [不填写表示不需要附件]
    <input type="checkbox" name="annexDefault" onClick="javascript:AnnexDefault();" <% if (!bdFormInfo.getHasAnnex().equals("")) { out.println("checked");} %>>默认附件表名
    <%
    //附件必须填写
    String s_id_annex[] = {BdFormHelp.Assistant_Annex_NoNull};
    String s_name_annex[] = {"附件必填"};
    out.println(SzPageHelp.checkbox("assistant", s_id_annex, s_name_annex, assistant));
    %>
    </td>
  </tr>
  <tr>
    <td class="tdClassTitle" style="width:200;">是否使用流程</td>
    <td colspan="3">
      <input type="radio" name="hasFlow" value="0" <% if (bdFormInfo.getHasFlow().equals("0")) { %> checked <% } %> OnClick="javascript:HasFlow(0);">不使用
      <input type="radio" name="hasFlow" value="1" <% if (bdFormInfo.getHasFlow().equals("1")) { %> checked <% } %> OnClick="javascript:HasFlow(1);">使用
      
      <% if (1 != 1) { %>
      &nbsp;<input type="checkbox" name="hasFlowSms" value="1" <% if (bdFormInfo.getHasFlowSms().equals("1")) { %> checked <% } %>>审批到来时手机短信提醒
      <% } %>
    </td>      
  </tr> 
  <tr>
    <td class="tdClassTitle" style="width:200;">是否使用编辑器</td>
    <td colspan="3">
      <input type="radio" name="hasEditor" value="0" OnClick="ChangeEditor();">不使用
      <input type="radio" name="hasEditor" value="1" OnClick="ChangeEditor();">使用html，内容字段为：
      <input type="text" name="editor" class="txtClass1R" value="<%=bdFormInfo.getEditor()%>" readonly>
    </td>
  </tr>  
  <tr>
    <td class="tdClassTitle" style="width:200;">是否使用weboffice</td>
    <td colspan="3">
      <input type="radio" name="weboffice" value="" checked>不使用
      <input type="radio" name="weboffice" value=".doc" <% if (bdFormInfo.getWeboffice().equals(".doc")) { %>checked<%}%> >word
      <input type="radio" name="weboffice" value=".xls" <% if (bdFormInfo.getWeboffice().equals(".xls")) { %>checked<%}%> >excel
      <input type="radio" name="weboffice" value=".ppt" <% if (bdFormInfo.getWeboffice().equals(".ppt")) { %>checked<%}%> >ppt            
    </td>
  </tr> 
  <tr>
    <td class="tdClassTitle" style="width:200;">默认weboffice模板(word)</td>
    <td colspan="3">
      <%
      net.sz600.weboffice.OfficeHelp officeHelp = new net.sz600.weboffice.OfficeHelp();
      out.println(officeHelp.selectTemp(".doc",bdFormInfo.getTemplateSelect() ));
      %>
    </td>
  </tr>
  <tr>
    <td class="tdClassTitle" style="width:200;">列表选择关联名称</td>
    <td colspan="3">
      <input type="text" name="selectName" class="txtClass2R" value="<%=bdFormInfo.getSelectName()%>" readonly>
      <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectProperty('listSelect');">
    </td>    
  </tr> 
  <tr>
    <td class="tdClassTitle" style="width:200;">触发关联名称</td>
    <td colspan="3">
      <input type="text" name="triggerName" class="txtClass2R" value="<%=bdFormInfo.getTriggerName()%>" readonly>
      <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectProperty('trigger');">
    </td>
  </tr>    
  <tr>
    <td class="tdClassTitle" style="width:200;">word格式的打印模板名称</td>
    <td colspan="3">
      <input type="text" name="printTemp" class="txtClass2R" value="<%=bdFormInfo.getPrintTemp()%>" readonly>
      <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectProperty('printTemp');">
    </td>
  </tr>      
  <tr>   
    <td class="tdClassTitle" style="width:200;">默认查询条件</td>  
    <td colspan="3">    
      <input type="text" name="defaultCond" class="txtClass2" value="<%=bdFormInfo.getDefaultCond()%>" >
    </td>  
  </tr>   
  <tr>
    <td class="tdClassTitle" style="width:200;">本表单数据的权限类型</td>
    <td colspan="3">
    
      <div id="modulePopedomDiv0"><input type="radio" name="modulePopedom" value="0" checked ><span id="modulePopedom0">0、私人资料，其他人不能查看</span><br>
      <div id="modulePopedomDiv1"><input type="radio" name="modulePopedom" value="1" <% if (bdFormInfo.getModulePopedom().equals("1")) { %>checked<%}%> ><span id="modulePopedom1">1、管理员发布信息，一般人员只能查看</span><br></div>
      <div id="modulePopedomDiv2"><input type="radio" name="modulePopedom" value="2" <% if (bdFormInfo.getModulePopedom().equals("2")) { %>checked<%}%> ><span id="modulePopedom2">2、仅管理员可录入、查看</span><br></div>
      <div id="modulePopedomDiv3"><input type="radio" name="modulePopedom" value="3" <% if (bdFormInfo.getModulePopedom().equals("3")) { %>checked<%}%> ><span id="modulePopedom3">3、一般人员录入、修改、删除、查看自己的资料，管理员管理所有人资料</span><br></div>      
      <div id="modulePopedomDiv4"><input type="radio" name="modulePopedom" value="4" <% if (bdFormInfo.getModulePopedom().equals("4")) { %>checked<%}%> ><span id="modulePopedom4">4、一般人员录入、修改,所有人可以查看，管理员管理所有人资料</span><br></div>
      <div id="modulePopedomDiv5"><input type="radio" name="modulePopedom" value="5" <% if (bdFormInfo.getModulePopedom().equals("5")) { %>checked<%}%> ><span id="modulePopedom5">5、一般人员录入、修改,同部门人员可以查看，管理员管理所有人资料</span><br></div>      
		  <div id="modulePopedomDiv6"><input type="radio" name="modulePopedom" value="6" <% if (bdFormInfo.getModulePopedom().equals("6")) { %>checked<%}%> ><span id="modulePopedom6">6、个人维护自己的资料，部门负责人可查看下级资料，管理员可查看所有人资料</span><br></div>      
			<div id="modulePopedomDiv7"><input type="radio" name="modulePopedom" value="7" <% if (bdFormInfo.getModulePopedom().equals("7")) { %>checked<%}%> ><span id="modulePopedom7">7、个人维护自己的资料，部门负责人维护下级资料，管理员维护所有人资料</span><br></div>
		  <div id="modulePopedomDiv8"><input type="radio" name="modulePopedom" value="8" <% if (bdFormInfo.getModulePopedom().equals("8")) { %>checked<%}%> ><span id="modulePopedom8">8、个人维护自己的资料，部门负责人可查看<b>多级</b>下级资料，管理员可查看所有人资料</span><br></div>      
			<div id="modulePopedomDiv9"><input type="radio" name="modulePopedom" value="9" <% if (bdFormInfo.getModulePopedom().equals("9")) { %>checked<%}%> ><span id="modulePopedom9">9、个人维护自己的资料，部门负责人维护<b>多级</b>下级资料，管理员维护所有人资料</span><br></div>

    </td>
  </tr> 
<!--
  <tr>
    <td class="tdClassTitle" style="width:200;">word格式的关联打印模板</td>
    <td colspan="3">
      <input type="text" name="printTempRelate" class="txtClass2" value="<%=bdFormInfo.getPrintTempRelate()%>">
    </td>
  </tr>    
-->

   
  <tr style="display:none;">
    <td class="tdClassTitle" style="width:200;">字段前缀</td>
    <td>
      <input type="text" name="prefix" class="txtClass1" value="<%=bdFormInfo.getPrefix()%>">
    </td>
    <td align="right">需要代录人</td>
    <td style="width:200;"><input type="checkbox" name="allograph" value="1" <% if (bdFormInfo.getAllograph().equals("1")) { %>checked<%}%> ></td>        
  </tr>            

  <tr>   
    <td class="tdClassTitle" style="width:200;">辅助选项</td>  
    <td colspan="3">    
      <%
    	//String s_id[]   = {"1","2","3","5","6","7","8","9","10","11","12"};
      	//String s_name[] = {"全文检索","图表统计","需要授权","显示正文<br>","需要催办","需要跳转","部门统计","个人统计<br>","需要转移","批量审批","需要传阅"};
    	//String s_id[]   = {"10","3","5","11","6","7","12","8","9"};
      	//String s_name[] = {"需要转移","需要授权","显示正文","批量办理(审批)<br>","需要催办","需要跳转","需要传阅(印发、分发)<br>","部门办理统计","个人办理统计<br>"};
      	//String s_id[]   = {"10","3","11","5","6","7","12","13","8","9"};
      	//String s_name[] = {"需要转移","需要授权","批量办理(审批)<br>","显示正文","需要催办","需要跳转","需要传阅(印发、分发)<br>","阅读标志","部门办理统计","个人办理统计<br>"};
      	String s_name[] = {
      			"阅读标志","需要转移","需要授权","显示weboffice","需要传阅(印发、分发)<br>",
      			"需要催办","需要跳转","批量审批","部门办理统计&nbsp;","个人办理统计<br>",
      			"需要反馈","列表日期查询","列表姓名查询","列表部门查询","办结才可打印<br>",
      			"页面打印不含审批意见","详情弹出","允许多个word和excel"
      	};
      	
      	String s_id[]   = {
      		BdFormHelp.Assistant_Read,	BdFormHelp.Assistant_Transfer, 
      		BdFormHelp.Assistant_Popedom, BdFormHelp.Assistant_Office, BdFormHelp.Assistant_Pass,
      		BdFormHelp.Assistant_Press, BdFormHelp.Assistant_Skip,
      		BdFormHelp.Assistant_Bat, BdFormHelp.Assistant_Depart,BdFormHelp.Assistant_Person,
      		BdFormHelp.Assistant_Feedback,
      		BdFormHelp.Assistant_DateSearch, BdFormHelp.Assistant_NameSearch, BdFormHelp.Assistant_DepartSearch, BdFormHelp.Assistant_Print,
      		BdFormHelp.Assistant_Print_Flow, BdFormHelp.Assistant_Detail_Win,BdFormHelp.Assistant_Office_Mult,
      	};


      	out.println(SzPageHelp.checkbox("assistant", s_id, s_name, assistant));      
      %>
    </td>  
  </tr>   

  <tr>   
    <td class="tdClassTitle" style="width:200;">显示在桌面</td>  
    <td colspan="3">    
      <input type="checkbox" name="desktop" value="5" <% if (bdFormInfo.getDesktop() > 0) { %>checked<%}%> >
    </td>  
  </tr>  
 
  <!----   
  <tr>   
  <%
  	String toolbar[] = {"", "icon4.gif","icon5.gif","icon6.gif","icon7.gif","icon8.gif"};
  %>
    <td class="tdClassTitle" style="width:200;">显示在快捷方式</td>  
    <td colspan="3" valign="middle">  
    <%
      for (int i = 0; i<toolbar.length; i++) {
    	out.println("<input type='radio' name='toolbar' value=");
    	out.println(toolbar[i]);
    	if (bdFormInfo.getToolbar().equals(toolbar[i])) {
    		out.println(" checked ");
    	}
    	out.println(" > ");
    	if (toolbar[i].endsWith(".gif")) {
    		out.println("<img src='../../images/share/top/");
    		out.println(toolbar[i]);
    		out.println("'>");
    	} else {
    		out.println("不显示");
    	}
    	if (i % 5 == 0) {
    		out.println("<br>");
    	}
    %>
        
    <%
      }
    %>  
    </td>  
  </tr>  
   ---->
  <tr>
    <td class="tdClassTitle" style="width:200;">锁定，锁定后不能修改</td>
    <td colspan="3">
      <input type="hidden" name="locked" value="<%=bdFormInfo.getLock()%>">
      <input type="radio" name="lock" value="0" <% if (bdFormInfo.getLock().equals("0")) { %>checked<%}%> onClick="CancleLock();" >解锁
      <input type="radio" name="lock" value="1" <% if (bdFormInfo.getLock().equals("1")) { %>checked<%}%> >锁定
    </td>
  </tr>   
</table>
</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //初始化
  var vEditor = formUpdate.editor.value;
  if (vEditor == "") {
	formUpdate.hasEditor[0].checked = true;
	formUpdate.editor.disabled = true;
  } else {
	formUpdate.hasEditor[1].checked = true;  
	formUpdate.editor.disabled = false;
  }

  function ChangeEditor() {
    var hasEditor = ValueOfRadio(formUpdate.hasEditor);
    if (hasEditor == "1") {
      var vEditor = formUpdate.editor.value;
	  formUpdate.editor.disabled = false; 
	  if (vEditor == "") {
	    formUpdate.editor.value = "szContent";
	  }     	  
    } else {
	  formUpdate.editor.disabled = true; 	
    }
  }

  function FormSave(formName, url) {
    //检查是否可以保存
    if (!notSpace(formName.formName, "表单英文名称")) {
      return false;
    }
    if (!isLetterOrNumOrLine(formName.formName.value)) {
      alert("表单英文名称有不允许的字符");
      formName.formName.focus();
      return false;
    }
    if (!notSpace(formName.formDesc, "表单中文名称")) {
      return false;
    }    
    //表名不可以数字开头    
    var vName = formName.hasAnnex.value;
    if (vName != null && vName.length > 0) {    
    	vName = vName.substring(0,1);
    	if (isNum(vName)) {
			alert("附件数据表名第一个只能为字母");
			formName.hasAnnex.focus();
			return false;    
    	}   
    }
  
    
    formName.action = "formControl.jsp";
    formName.submit();
  }
  
  //解除锁定需要输入密码
  function CancleLock() {
    var vLock = formUpdate.locked.value;
    if (vLock != "1") {
      //原来不是锁定的，不理
	  return;
    }
	/*
	var theResponse = window.prompt("请输入解锁的密码：");
	if (theResponse == "xiaomutou") {
	  //alert("密码正确");	  
	} else {
	  alert("密码不正确，不能选择解锁");
	  CheckRadio(formUpdate.lock, "1");
	}
	*/
  }  
  
  //chek后附件名为默认
  function AnnexDefault() {
    var moduleName = formUpdate.moduleName.value;
    var vLen = moduleName.length;
    //moduleName = moduleName.substring(vLen - 4, vLen);
    if (vLen > 4 && moduleName.substring(vLen - 4, vLen) == ".xml") {
	    moduleName = moduleName.substring(0, vLen - 4);
    }
    var formName = formUpdate.formName.value;
    
		if (formUpdate.annexDefault.checked == true) {
			formUpdate.hasAnnex.value = "BD_" + moduleName + "_" + formName + "_ANNEX";
		} else {
			//formUpdate.hasAnnex.value = "<%=bdFormInfo.getHasAnnex()%>";
			//2016-04-15增加
			formUpdate.hasAnnex.value = "";
		}
		var vName = formUpdate.hasAnnex.value;
		vName = vName.toUpperCase();
		formUpdate.hasAnnex.value = vName;
	
  }
  
  function SelectWin() {
    var url = "form_temp_select.jsp";
    //2014-06,适应chrome修改为open 
    //window.showModalDialog(url,window,"status=no;dialogWidth=280px;dialogHeight=370px");  
    window.open(url,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=280px,height=370px");
  }  
  function SelectProperty(vType) {
  	var url = "property_select.jsp";
  	var vObject = null;
  	var moduleName = formUpdate.moduleName.value;
  	if (vType == "listSelect") {
  		vObject = "formUpdate.selectName";
  	} else if (vType == "trigger") {
  		vObject = "formUpdate.triggerName";
  	} else if (vType == "printTemp") {
  		vObject = "formUpdate.printTemp";
  	}
    url = url + "?object=" + vObject + "&type=" + vType + "&moduleName=" + moduleName;
    window.showModalDialog(url,window,"status=no;dialogWidth=260px;dialogHeight=370px");  
  } 
  
  function HasFlow(vHasFlow) {
    if (vHasFlow==0) {
			document.getElementById("modulePopedom0").innerText = "0、私人资料，其他人不能查看";
			document.getElementById("modulePopedom1").innerText = "1、管理员发布信息，一般人员只能查看";
			document.getElementById("modulePopedom2").innerText = "2、仅管理员可录入、查看";
			document.getElementById("modulePopedom3").innerText = "3、一般人员录入、修改、删除、查看自己的资料，管理员管理所有人资料";
			document.getElementById("modulePopedom4").innerText = "4、一般人员录入、修改,所有人可以查看，管理员管理所有人资料";
			document.getElementById("modulePopedom5").innerText = "5、一般人员录入、修改,同部门人员可以查看，管理员管理所有人资料";
			document.getElementById("modulePopedom6").innerText = "6、个人维护自己的资料，部门负责人可查看下级资料，管理员可查看所有人资料";
			document.getElementById("modulePopedom7").innerText = "7、个人维护自己的资料，部门负责人维护下级资料，管理员维护所有人资料";
			document.getElementById("modulePopedom8").innerText = "8、个人维护自己的资料，部门负责人可查看多级下级资料，管理员可查看所有人资料";
			document.getElementById("modulePopedom9").innerText = "9、个人维护自己的资料，部门负责人维护多级下级资料，管理员维护所有人资料";
			
			document.getElementById("modulePopedomDiv0").style.display="";
			document.getElementById("modulePopedomDiv1").style.display="";
			document.getElementById("modulePopedomDiv2").style.display="";
			document.getElementById("modulePopedomDiv3").style.display="";
			document.getElementById("modulePopedomDiv4").style.display="";
			document.getElementById("modulePopedomDiv5").style.display="";
			document.getElementById("modulePopedomDiv6").style.display="";
			document.getElementById("modulePopedomDiv7").style.display="";
			document.getElementById("modulePopedomDiv8").style.display="";
			document.getElementById("modulePopedomDiv9").style.display="";
    } else {    
			document.getElementById("modulePopedom0").innerText = "0、仅自己能查看";
			document.getElementById("modulePopedom1").innerText = "1、所有人能查看";
			document.getElementById("modulePopedom2").innerText = "2、--不允许的权限--";
			document.getElementById("modulePopedom3").innerText = "3、自己能看，管理员能看";
			document.getElementById("modulePopedom4").innerText = "4、--所有人能查看--";
			document.getElementById("modulePopedom5").innerText = "5、自己能看，同部门能查看，管理员能查看";
			document.getElementById("modulePopedom6").innerText = "6、自己能看，部门负责人能查看下级，管理员能查看";
			document.getElementById("modulePopedom7").innerText = "7、--自己能看，部门负责人能查看下级，管理员能查看--";
			document.getElementById("modulePopedom8").innerText = "8、自己能看，部门负责人能查看多级下级，管理员能查看";
			document.getElementById("modulePopedom9").innerText = "9、--自己能看，部门负责人能查看多级下级，管理员能查看料--";
			
			
			document.getElementById("modulePopedomDiv0").style.display="";
			document.getElementById("modulePopedomDiv1").style.display="";
			document.getElementById("modulePopedomDiv2").style.display="none";
			document.getElementById("modulePopedomDiv3").style.display="";
			document.getElementById("modulePopedomDiv4").style.display="none";
			document.getElementById("modulePopedomDiv5").style.display="";
			document.getElementById("modulePopedomDiv6").style.display="";
			document.getElementById("modulePopedomDiv7").style.display="none";
			document.getElementById("modulePopedomDiv8").style.display="";
			document.getElementById("modulePopedomDiv9").style.display="none";			
    }
  }
  
  HasFlow(<%=bdFormInfo.getHasFlow()%>);
</script>
</body>
