<%@ page contentType="text/html;charset=gbk" %>
<%@ 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=GBK">
<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);
%>
<body>

<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <input type="hidden" name="moduleName" value="<%=moduleName%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
<% if (isFormEngine) { %>
<%@ include file="title.jsp"%>
<% } else { %>
<%@ include file="simpleTitle.jsp"%>
<% } %>
<table width="100%">
  <tr>
    <td>
      <%=SzPageHelp.saveButton()%>
      <%=SzPageHelp.backButton()%>
      <b><%=bdFormInfo.getFormTypeName()%></b>
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="700" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0"> 
  <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="txtClass200" value="<%=bdFormInfo.getHasAnnex()%>" <% if (!isFormEngine) {out.println("readonly");} %>>
    [不填写表示不需要附件]
    <input type="checkbox" name="annexDefault" onClick="javascript:AnnexDefault();">默认附件表名</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 <% } %>>不使用
      <input type="radio" name="hasFlow" value="1" <% if (bdFormInfo.getHasFlow().equals("1")) { %> checked <% } %>>使用
      
      &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="txtClass1" value="<%=bdFormInfo.getEditor()%>" <% if (!isFormEngine) {out.println("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模板</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="txtClass2" value="<%=bdFormInfo.getSelectName()%>">
    </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">
      <input type="radio" name="modulePopedom" value="0" checked >私人资料，其他人不能查看<br>
			<input type="radio" name="modulePopedom" value="7" <% if (bdFormInfo.getModulePopedom().equals("7")) { %>checked<%}%> >个人维护自己的资料，部门负责人维护下级资料，管理员维护所有人资料<br>
		  <input type="radio" name="modulePopedom" value="6" <% if (bdFormInfo.getModulePopedom().equals("6")) { %>checked<%}%> >个人维护自己的资料，部门负责人可查看下级资料，管理员可查看所有人资料<br>      
      <input type="radio" name="modulePopedom" value="3" <% if (bdFormInfo.getModulePopedom().equals("3")) { %>checked<%}%> >一般人员录入、修改、删除、查看自己的资料，管理员管理所有人资料<br>      
      <input type="radio" name="modulePopedom" value="4" <% if (bdFormInfo.getModulePopedom().equals("4")) { %>checked<%}%> >一般人员录入、修改,所有人可以查看，管理员管理所有人资料<br>
      <input type="radio" name="modulePopedom" value="5" <% if (bdFormInfo.getModulePopedom().equals("5")) { %>checked<%}%> >一般人员录入、修改,同部门人员可以查看，管理员管理所有人资料<br>      
      <input type="radio" name="modulePopedom" value="1" <% if (bdFormInfo.getModulePopedom().equals("1")) { %>checked<%}%> >管理员发布信息，一般人员只能查看<br>
      <input type="radio" name="modulePopedom" value="2" <% if (bdFormInfo.getModulePopedom().equals("2")) { %>checked<%}%> >仅管理员可录入、查看
    </td>
  </tr> 
<% if (isFormEngine) { %>
  <tr>
    <td class="tdClassTitle" style="width:200;" title="<%=bdFormInfo.getFormId() %>">选择模板</td>
    <td colspan="3"><input type="text" name="moduleNameTemp" class="txtClass1" value="" readonly>
    <input type="text" name="formNameTemp" class="txtClass1" value="" readonly>
    <input type="button" class="btnClassShort" value="选择" OnClick="javascript:SelectWin();">
    </td>
  </tr>   
  <tr>
    <td class="tdClassTitle" style="width:200;">word格式的打印模板名称</td>
    <td colspan="3">
      <input type="text" name="printTemp" class="txtClass2" value="<%=bdFormInfo.getPrintTemp()%>">
    </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>
    <td class="tdClassTitle" style="width:200;">触发关联名称</td>
    <td colspan="3">
      <input type="text" name="triggerName" class="txtClass2" value="<%=bdFormInfo.getTriggerName()%>">
    </td>
  </tr>
   
  <tr>
    <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 assistant = bdFormInfo.getAssistant();
    	  String s_id[]   = {"1","2","3","5","6","7","8","9","10"};
      	String s_name[] = {"全文检索","图表统计","需要授权","显示正文<br>","需要催办","需要跳转","部门统计","个人统计<br>","需要转移"};
      	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()%>";
		}
		var vName = formUpdate.hasAnnex.value;
		vName = vName.toUpperCase();
		formUpdate.hasAnnex.value = vName;
	
  }
  
  function SelectWin() {
    var url = "form_select.jsp";
    window.showModalDialog(url,window,"status=no;dialogWidth=200px;dialogHeight=370px");  
  }  

</script>
</body>
