<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%@ include file="/sessionInfo.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>
<%
   	String sOPERATOR = "add";
    String name = SzConvert.toSpaceStr(request.getParameter("name"));
    
	OfficePrintTemp officePrintTemp = new OfficePrintTemp(0);
	OfficeTemplate officeTemplate = null;    
	if (!name.equals("")) {
		officeTemplate = officePrintTemp.getTemplate(name);	
	}
	String desc = "";
	String note = "";
	String path = "share/wordtemp/";
	String saveDir = "upload/exportword/";
	String moduleName2 = "";
	if (officeTemplate != null) {
		desc = SzConvert.toSpaceStr( officeTemplate.getAttrs().get("desc"));
		note = SzConvert.toSpaceStr( officeTemplate.getAttrs().get("note"));
		path = officeTemplate.getAttrs().get("path");
		saveDir = officeTemplate.getAttrs().get("saveDir");
		moduleName2 = SzConvert.toSpaceStr(officeTemplate.getAttrs().get("moduleName"));
		sOPERATOR = "update";
	}
	
	BdFormControl formControl = new BdFormControl();
	String moduleName = SzConvert.strWriteData(request.getParameter("module"));
	boolean isFormEngine = formControl.isFormEngine(moduleName);
	boolean isDocumentEngine = formControl.isDocumentEngine(moduleName);		
%>
<!-----上面的工具栏------>
<%@ include file="/xml/formEngine2/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <tr>
    <td>    
      <%=SzPageHelp.saveButton()%>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
  </form>
</table>
<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formUpdate" method="post">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <tr>
    <td>名称</td>
    <td><input type="text" class="txtClass2" name="name" value="<%=name %>" onblur="javascript:ChangeName();">
    <font color="red">*</font>[可用字母、数字、下划线的组合]</td>
  </tr>
  <tr>
    <td>说明</td>
    <td><input type="text" class="txtClass2" name="desc" value="<%=desc%>">
    <font color="red">*</font></td>
  </tr>
  <tr>
    <td>描述</td>
    <td><input type="text" class="txtClass2" name="note" value="<%=note%>"></td>
  </tr>  
  <tr>
    <td>模板文件(.doc)</td>
    <td><input type="text" class="txtClass2" name="path" value="<%=path%>">
    <font color="red">*</font>
    <% 
    if (!path.equals("") && path.endsWith(".doc")) {
    	String sUrl = "../../../share/weboffice/template/TemplateEdit.jsp?module=" + moduleName2 + "&FileType=.doc&FilePath=" + path;
    	out.println(SzPageHelp.button("编辑模板","GoUrl('" + sUrl + "')"));	
    } else {
    	out.println("模板文件是以.doc结尾的word文件相对路径");
    }
    %>
    </td>
  </tr>
  <tr>
    <td>输出文件夹</td>
    <td><input type="text" class="txtClass2" name="saveDir" value="<%=saveDir%>">
    <font color="red">*</font></td>
  </tr>    
  <tr>
    <td><a href="#" onClick="javascript:SelectWin('formUpdate.moduleName');" onfocus="javascript:blur();">所属模块<img src="<%=strLevel_SESSION%>images/share2/select.gif" border="0" ></a></td>
    <td><input type="text" name="moduleName" value="<%=moduleName2%>" class="txtClass2R" readonly> <font color="red">*</font></td>
  </tr>    
  <tr>
    <td colspan="2">
    	名 称：跟表单属性中的"word格式的打印模板名称"绑定，一般使用英文<br>
    	说     明：打印时，如果有多个文件匹配，显示该说明用来区分是哪个打印文件<br>
    	模板文件：word文件的相对路径，打印的模板文件，必须在系统中存在<br>
    	输出文件夹：生成的打印文件存放的相对路径，可不修改<br>
    </td>
  </tr>  
  </form>  
</table>  

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
	<input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  </form>
</table>
<script language="javascript" src="../../../share/js/commonTool.js"></script>
<script language="javascript">
  function ChangeName() {
		var name = formUpdate.name.value;
		var path = formUpdate.path.value;

		if (path == "share/wordtemp/" && name != "") {
			path = path + name + ".doc";
			formUpdate.path.value = path;
		}

  }
  
  function FormSave(formName, url) {
    //检查是否可以保存
    if (!notSpace(formName.name, "名称")) {
      return false;
    }    
    if (!notSpace(formName.desc, "说明")) {
      return false;
    }  
    if (!notSpace(formName.path, "模板文件")) {
      return false;
    }
    if (!notSpace(formName.saveDir, "输出文件夹")) {
      return false;
    }            
    if (!notSpace(formName.moduleName, "所属模块")) {
      return false;
    }  
    formName.action = url;
    formName.submit();
  }
</script>
<script language="javascript">  
  function SelectWin(vModuleNameObject) {
    var url = "../module_select.jsp?moduleNameObject=" + vModuleNameObject; 
    window.showModalDialog(url,window,"status=no;dialogWidth=300px;dialogHeight=370px");  
  }   
</script>
