<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collection" %>
<%@ 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.flow.*" %>
<%@ page import="net.sz600.online.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.formEngine.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%//@ page import="net.fckeditor.*"%>
<%//@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<%@ include file="/sessionInfo.jsp"%>
<% 
  String strLevel = "../../"; 
%> 
<%
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sOPERATOR = request.getParameter("OPERATOR");    
    
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String from =  SzConvert.toZeroStr(request.getParameter("from"));
    
    int iFormID = SzConvert.toInt(request.getParameter("FormID"));
    int iInfoID = SzConvert.toInt(sKEY);
    
		String datefield = SzConvert.strWriteData(request.getParameter("datefield")); 
	  String sSearchName = SzConvert.strWriteData(request.getParameter("txtSearchName"));
	  String sSearchDepart = SzConvert.strWriteData(request.getParameter("txtSearchDepart"));
	  //查询时间段
	  String sSearchBegin = SzConvert.strWriteData(request.getParameter("txtSearchBegin"));
	  String sSearchEnd = SzConvert.strWriteData(request.getParameter("txtSearchEnd"));      
	  //out.println("==sSearchBegin==" + sSearchBegin);
    //取得表单的信息
    String moduleName = "";
    String formName = "";
		LcForm lcForm = new LcForm();
		LcFormInfo lcFormInfo = null;    
    if (iFormID == 0) {
    	moduleName = SzConvert.toSpaceStr(request.getParameter("moduleName"));
    	formName = SzConvert.toSpaceStr(request.getParameter("formName")); 
    	//
    	iFormID = lcForm.getKeyByCond(moduleName, formName); 
    } else {
    	lcFormInfo = (LcFormInfo)lcForm.getInfoByKey(iFormID);    
    	if (lcFormInfo != null) {
    		moduleName = lcFormInfo.getBDLJ();
    		formName = lcFormInfo.getBDBY1();  
    	}
    } 	
    //System.out.println("moduleName=" + moduleName);
    //System.out.println("formName=" + formName);
    if (moduleName.equals("") || formName.equals("")) {
    	out.println("还没有设置相关表单信息！");
    	return;
    }   
    
    //2015-01增加锁定判断
    if (iInfoID > 0) {
    	if (SzEditLock.getInstance().isLocking("formEngine", "" + iFormID, iInfoID)) {
    		sOPERATOR = "detail";    	
    	} else if (sNavigator_SESSION.equals("MSIE") || sNavigator_SESSION.equals("CHROME")) {
    		SzEditLock.getInstance().lock(session, "formEngine", "" + iFormID, iInfoID); 
    	}
    }
    
    //2010-2-21
    BdPopedom bdPopedom = new BdPopedom();        
    String strDenyField = bdPopedom.getDenyField(iFormID, 0, iDLID_SESSION);
    String strDenyField2 = bdPopedom.getDenyField(iFormID, iInfoID, iDLID_SESSION);
    bdPopedom.read(iFormID, iInfoID, iDLID_SESSION);
    
    BdFormControl bdFormControl = new BdFormControl();
    //取得关联的名称
    BdTrigger bdTrigger = new BdTrigger();
    String sTriggerName = bdFormControl.getTriggerName(moduleName, formName);    
  	//根据名称取得关联的条件控件
    //String sRelateObject = bdFormControl.getRelateObject(sTriggerName);    
    
    String sHTML = "";    
	BdValueControl bdValueControl = new BdValueControl(moduleName, formName);	
	sHTML = bdValueControl.getHTML();
	String sTable = bdValueControl.getTableName();
	String sFieldID = bdValueControl.getKeyField();
	
	//获取附件名
	String assistant = bdValueControl.getAssistant();
	String sTableAnnex = bdValueControl.getTableAnnex();
	String sEditor    = bdValueControl.getEditor();
	String sWeboffice = bdValueControl.getWebOffice();
	String sTemplateSelect = bdValueControl.getTemplateSelect();
	String printTemp = bdValueControl.getPrintTemp();
	String printTempRelate = bdValueControl.getPrintTempRelate();
	String allograph = bdValueControl.getAllograph();
	//System.out.println("allograph==" + allograph);
	
	boolean hasFlow   = bdValueControl.getHasFlow();
	boolean hasAnnex  = false;
	if (!sTableAnnex.equals("")) {
		hasAnnex = true;
	}
	
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.startsWith("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    if (sOPERATOR.equals("detailPass")) {
    		LcFlowControl.readPass(iFormID, iDLID_SESSION, iInfoID);
        sReadonly = "readonly";
        bReadonly = true;    	
    } else if (sOPERATOR.equals("detailSave")) {
    		//2016-03-16增加
				bdValueControl.readSave(iFormID,iInfoID, iDLID_SESSION);
        sReadonly = "readonly";
        bReadonly = true;    	    
    }
    //读取数据
		String value_str[] = null;
    if (!sKEY.equals("0")) {
    	value_str = (String[])bdValueControl.getInfoByKey(iInfoID);
    }
    String loginID2 = SzConvert.toSpaceStr(bdValueControl.getLoginID2(value_str));
    String loginName2 = SzConvert.toSpaceStr(bdValueControl.getLoginName2(value_str));
    String loginID = SzConvert.toSpaceStr(bdValueControl.getLoginID(value_str));
    if (loginID.equals("")) {
    	loginID = Integer.toString(iDLID_SESSION);
    }
    
    //检查是否有权利办理，如果没有就进入待办列表中

    if (sOPERATOR.equals("transact")) {
    	
    	LcFlowControl lcFlowControl = new LcFlowControl();
    	String str_InfoID = lcFlowControl.getTransactInfoID(iFormID, iDLID_SESSION) + ",0"; 

    	if (value_str == null || value_str[0] == null || str_InfoID.indexOf(("," + sKEY + ",")) == -1) {
    		//不在待办中，提示已过期
    		
    		//解除锁定//2016-04-13增加，从消息进来，判断到不存在时，要解除缩定，否则一定认为是办理中。
    		SzEditLock.getInstance().unLock(session, "formEngine", "" + iFormID, iInfoID); 
    		out.println(SzPageHelp.jsAlertBack("该文已办理或不存在"));
    		return;
    	} else {
				//读取相关的提醒。
    		OlMessageControl olMessageControl = new OlMessageControl();
    		olMessageControl.readMessage(iFormID, iInfoID, iDLID_SESSION);
    		
    		//2011-07-12 该文设置为已读
    		lcFlowControl.readTransact(iFormID, iInfoID, iDLID_SESSION);    		
    	}
    }   
%>
<%    
    //流程相关
    //根据已经有的信息ID，读取流程ID
    LcFlowControl lcFlowControl = new LcFlowControl();
    //取得流程权限信息
    LcFlowPopedomInfo lcFlowPopedomInfo = lcFlowControl.getFlowPopedomInfo(iFormID, iInfoID, iDLID_SESSION);
    
    int iFlowID = lcFlowPopedomInfo.getFlowID();
    int iState = lcFlowControl.getFlowState(iFormID, iInfoID); 
    
	boolean hasSend = lcFlowPopedomInfo.isHasSend();
	boolean isLastStep = lcFlowPopedomInfo.isLastStep();
	boolean canSend = lcFlowPopedomInfo.isCanSend();
	boolean canFinish = lcFlowPopedomInfo.isCanFinish();
	boolean canDeny = lcFlowPopedomInfo.isCanDeny();
	boolean canUntread = lcFlowPopedomInfo.isCanUntread();
	boolean canSkip = lcFlowPopedomInfo.isCanSkip();
	boolean canModifyForm = lcFlowPopedomInfo.isCanModifyForm();
	boolean isSave = lcFlowPopedomInfo.isSave(); //指存档，2016-01-17增加
	if (bReadonly) {
		canModifyForm = false;		
	}
	if (canModifyForm || sOPERATOR.startsWith("add") || sOPERATOR.startsWith("update")) {
		 sReadonly = "";
	} else {
		 sReadonly = "readonly";		
	}
	
	boolean canDraftSave = false;
	boolean canDraftSend = false;
	boolean canTransactSave = false;
	if (hasFlow && !hasSend) {
		canDraftSave = true;
		canDraftSend = true;
		canSend = false;  //2016-03-17 增加。还没有发送，办理的发送按钮不出现。
	} else if (hasFlow && hasSend) {
		canTransactSave = true;
	} else if (!hasFlow) {
		canDraftSave = true;
	}
	boolean isTransact = false;
	if (sOPERATOR.startsWith("transact")) {
		isTransact = true;	
	}
	if (sOPERATOR.equals("updateWin")) {
		hasSend = false;
		isLastStep = false;
		canSend = false;
		canFinish = false;
		canDeny = false;
		canUntread = false;
		canSkip = false;
		
		canDraftSave = true;
		canDraftSend = false;
		canTransactSave = false;
		isTransact = false;
	}
	
	//EditType //// 0 显示  1 起草 2 批改 3 审核
	String sEditType = "0";
	boolean canSave = true;
	if (sOPERATOR.startsWith("add") || (sOPERATOR.startsWith("update") && hasFlow)) {
		sEditType = "1";
	} else if (sOPERATOR.startsWith("update") && !hasFlow) {
		sEditType = "2";
	} else if (sOPERATOR.startsWith("transact")) {
		sEditType = "3";
	} else {
		canSave = false;
	}
	//2016-04-15修改office的控制权限
	if (canSave && hasFlow) {
		//判断是否有修改权限：2016-03-16增加
		if (!lcFlowPopedomInfo.isWord() && !sOPERATOR.equals("update") && !sOPERATOR.equals("add")) {
			canSave = false;
			sEditType = "0";
		} 
	}	

	BdFormHelp bdFormHelp = new BdFormHelp();
	String sFromUrl = bdFormHelp.getFromUrl(from);
	
  SzReadForm szReadForm = new SzReadForm(iFormID); 
  szReadForm.read(Integer.parseInt(sKEY), sBMMC_SESSION, iDLID_SESSION, sDLXM_SESSION); 	
%>
<html>
<head>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript" src="../../share/js/formTool.js"></script>
<script language="javascript" src="../../share/js/annexTool.js"></script>
<%@ include file="/share/oa_title.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<% if (!sEditor.equals("")) {%>
<script language="javascript">
  //2015-01注释掉
  //function LoadContent1() {
     //this.focus();
     //window_onresize();
     //var vUrl = "http://<%=sServer_SESSION%>:<%=sPort_SESSION%><%=sContext_SESSION%>/share/formEngine2/load.jsp?FormID=<%=iFormID%>&KEY=<%=sKEY%>";
     //tbContentElement.LoadURL(vUrl);
  //}
</script>
<script type="text/javascript" src="<%=strLevel%>share/ckeditor/ckeditor.js"></script>
</head>
<body onload="javascript:this.focus();" >
<% } else {%>
</head>
<body onload="javascript:this.focus();" >
<% } %>

<!-----上面的工具栏------>
<% if (hasAnnex) { %>
<form name="formUpdate" method="post" ENCTYPE="multipart/form-data">
<% } else { %>
<form name="formUpdate" method="post">
<% } %>
  <!---使用流程的时候需要使用--->
  <input type="hidden" name="LCID_FLOW" value="0">
  <input type="hidden" name="BZID_FLOW" value="0">
  <input type="hidden" name="BZXH_FLOW" value="0">
  <input type="hidden" name="BZRYID_FLOW" value="0">  
  <input type="hidden" name="RYBLYJ_FLOW" value="">
  <input type="hidden" name="RYBLTP_FLOW" value="">
  
  <!-- 周报是需要用到 -->
  <input type="hidden" name="chkDate" value="-1">   
  <input type="hidden" name="datefield" value="<%=datefield%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">  
  <input type="hidden" name="txtSearchDepart" value="<%=sSearchDepart%>">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">  
  
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="OPERATOR_SOURCE" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" id="KEY" value="<%=sKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="from" value="<%=from%>">
  <input type="hidden" name="detailCount" value="0">
  <input type="hidden" name="detailCount1" value="0">
  <input type="hidden" name="detailCount2" value="0">
  <input type="hidden" name="detailCount3" value="0">
  <input type="hidden" name="detailCount4" value="0">
  <input type="hidden" name="FormID" value="<%=iFormID%>">
  <input type="hidden" name="loginID" value="<%=loginID%>">  
 <!--  <input type="hidden" name="szContent" value="">   -->
  <input type="hidden" name="RecordID" value="">    
  <input type="hidden" name="hasFlow" value="<%=hasFlow %>">
  <input type="hidden" name="hiddenSave" id="hiddenSave" value="not">
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% out.println(bdFormControl.printFormDesc(Integer.parseInt(sMKID_SESSION),iFormID));%>
    <% if (!bReadonly) { %>
      <%
    		out.println( LcHelp.saveCheckButton(isSave, false));
      
        //增加隐藏的按钮，保存时调用2016-03-17
      	out.println( LcHelp.saveButton(true, hasAnnex, "saveButtonUpdate", true));
        out.println( LcHelp.saveButton(canDraftSave, hasAnnex));
        out.println( LcHelp.draftSendButton(canDraftSend, hasAnnex));
        if (canModifyForm || ReadOaConfig.getSave_button().equals("1")) {
          out.println( LcHelp.transactSaveButton(canTransactSave, hasAnnex));
        }
      %>      
      <!-- 下面操作只在办理的过程中才会有 -->      
      <%
				//
        out.println( LcHelp.sendButton(canSend, hasAnnex));
        out.println( LcHelp.finishButton(canFinish, hasAnnex));
        out.println( LcHelp.denyButton(canDeny, hasAnnex));
        out.println( LcHelp.untreadButton(canUntread, iFlowID ));
        out.println( LcHelp.skipButton(canSkip, iFlowID));
      %>    
      <%
      if (canModifyForm || sOPERATOR.startsWith("add") || sOPERATOR.startsWith("update")) {
    	  out.println(bdValueControl.addDetailButton() );   	  
      }
      %>
      <%
        out.println(bdTrigger.triggerButton(sTriggerName, sOPERATOR, "重新获取", "triggerButton"));
      %>         
    <% } %>    
      <%
   
      if (!sWeboffice.equals("") && ((";" + assistant + ";").indexOf(";5;") <0) && sNavigator_SESSION.equals("MSIE")) {
      	 out.println( SzPageHelp.button("正文","javascript:OfficeDetailWin('" + sKEY + "');") );
      }  
      BdMonthStat monthStat = new BdMonthStat(iFormID);
      out.println(monthStat.statWinButton(loginID));
      
      if (ReadOaConfig.getTransact_button().indexOf("log")>=0 &&!sOPERATOR.startsWith("add") && isBarManager_SESSION) {
      	 out.println( SzPageHelp.button("操作日志","javascript:LogWin();") );
      }       
      //是否有word模板打印
      
      if (ReadOaConfig.getTransact_button().indexOf("word")>=0 && !sOPERATOR.startsWith("add") && !printTemp.equals("") && !sOPERATOR.startsWith("detailPass") && !sOPERATOR.startsWith("updateWin") && BdFormHelp.canPrint(assistant, hasFlow, iState)) {
    	  out.println( SzPageHelp.button("单据打印","javascript:PrintWinWord();") );
      }
      //2015-08-19对单据打印和打印分开判断
      if (ReadOaConfig.getTransact_button().indexOf("print")>=0 && !sOPERATOR.startsWith("add") && !sOPERATOR.startsWith("detailPass") && !sOPERATOR.startsWith("updateWin") && BdFormHelp.canPrint(assistant, hasFlow, iState)) {
    	  out.println( SzPageHelp.button("打印","javascript:PrintWin();") );
      }      
      if (ReadOaConfig.getTransact_button().indexOf("word")>=0 && !sOPERATOR.startsWith("add") && !printTempRelate.equals("") && !sOPERATOR.startsWith("detailPass") && !sOPERATOR.startsWith("updateWin")) {
    	  out.println( SzPageHelp.button("关联打印","javascript:PrintWinWordRelate();") );
      }  
      //2012-01-10调整顺序到最后。
      if (!sOPERATOR.startsWith("add") && !sOPERATOR.startsWith("updateWin")) {
    	  //out.println( SzPageHelp.button("打印","javascript:PrintWin();") );
      } 
      
      if (!sOPERATOR.startsWith("add")) {
    	  out.println( bdFormHelp.feedbackButton(assistant, iInfoID ) );
      }
   
      if (!sOPERATOR.startsWith("updateWin")) {
    	  //2014-11将formUpdate修改为formHidden，否则有附件时index.jsp获取不到参数
  	  	out.println( SzPageHelp.button("返回", "FormSubmit(formHidden, '" + sFromUrl + "?FormID=" + iFormID + "')") );
    	} else {
  	 		out.println( SzPageHelp.closeButton() ); 
    	}  
      
      BdAlert bdAlert = new BdAlert();
      out.println(bdAlert.alertInfo(moduleName, formName, iFormID, strLevel_SESSION, iInfoID, iDLID_SESSION, isBarManager_SESSION));      
      %>         
      
      <% out.println(SzEditLock.getInstance().getLockInfo(session, "formEngine", "" + iFormID, iInfoID)); %>
    </td>
  </tr>
</table>

<!-- 传阅反馈信息 -->
<% if (sOPERATOR.startsWith("detailPass")) { %>
<% } %>

<% if (allograph.startsWith("1")) { %>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0"> 
  <tr> 
    <td width="100">所属人员</td> 
    <td><input type="hidden" name="SZOA_BDDLID" class="txtClass" value="<%=loginID2%>">
        <input type="text" name="SZOA_BDDLXM" class="txtClass" value="<%=loginName2%>" readonly>
        <input type="button" value="选择" class="btnClassShort" onClick="javascript:OpenWin12('formUpdate.SZOA_BDDLID', 'formUpdate.SZOA_BDDLXM');">
    </td> 
  </tr> 
</table> 
<% } %>
 

<!-----信息维护------>
<div id="divForm">
<%=sHTML %>
</div>
<!-- 附件 -->
<% if (!sTableAnnex.equals("")) { %>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0"> 
  <tr> 
    <td class="tdClassTitle"><b>附件</b></td>  
    <td colspan="3">
    <%
    //if (bReadonly) {
    if (canModifyForm || sOPERATOR.startsWith("add") || sOPERATOR.startsWith("update")) {    	
    	 out.println(SzPageHelp.updateAnnexNew2(sTableAnnex, sKEY, strLevel_SESSION));    	
    } else {
    	out.println(SzPageHelp.detailAnnexNew2(sTableAnnex, sKEY, strLevel_SESSION));
    }
    %>
    </td> 
  </tr> 
</table> 
<% } %>
<% if (!sEditor.equals("")) {%>
<table width="750" border="0" cellpadding="1" cellspacing="0">
  <tr>
    <td>
      <%//@ include file="/share/editor/edit.jsp"%>
      <%
		szData = new SzData();
	  szData.setTableInfo(sTable, sFieldID, sEditor);
	  szDataInfo = (SzDataInfo)szData.getInfoByKey(iInfoID);		
	  String sValue = "";
	  if (szDataInfo != null) {
	        sValue = szDataInfo.getName();
	  }	      
      /*
			FCKeditor fckEditor = new FCKeditor(request, "szContent");
			fckEditor.setHeight("400");
			fckEditor.setWidth("750");

			fckEditor.setValue(sValue);		    
			out.println(fckEditor);
			*/
		%>  
		 <textarea id="szContent" name="szContent"><%=sValue %></textarea>       
    </td>
  </tr>
</table>
	<script type="text/javascript">
    CKEDITOR.replace( 'szContent');
   </script>
<% } %>


<!-- 传阅反馈信息 -->
<% if (sOPERATOR.startsWith("detailPass")) { %>
  <table width="750" border="0"  cellpadding="3" cellspacing="0"> 
  <tr>
    <td  valign="top">
     填写反馈意见
    </td>
    <td>
     <textarea rows="5" class="areaClass2" name="PassOpinion" id="PassOpinion"></textarea>
     <input type="button" class="btnClass" value="提交意见" name="PassOpinion" OnClick="SubmitPassOpinion();">
    </td>
  </tr>
  </table>
  <script language="javascript">
  function SubmitPassOpinion() {
      <% if (hasAnnex) { %>		  
	    formUpdate.action = "control2.jsp";
	  <% } else {%>
	    formUpdate.action = "control.jsp";
	  <% } %>  
    formUpdate.submit();
  }
  </script>
<% } %>
<!--反馈意见填写--->
<% 
/*
  if (hasFlow && !sOPERATOR.startsWith("updateWin") ) { 
	 //而且不是发文的传阅
	 if (!formName.equals("document2") || !moduleName.equals("document_new.xml") || !sOPERATOR.startsWith("detailPass")) {
	 %><%@ include file="../../flow/flow/draft_include.jsp"%><%
	 }
  } 
*/
%>
</form>
<% 

  if (hasFlow && !sOPERATOR.startsWith("updateWin") ) { 
	 //而且不是发文的传阅
	 if (!formName.equals("document2") || !moduleName.equals("document_new.xml") || !sOPERATOR.startsWith("detailPass")) {
		 out.println("<iframe id=\"flowDraft\" name=\"flowDraft\" src=\"../../flow/flow/draft.jsp?assistant=" + assistant + "&type=" + iFlowID + "&FormID=" + iFormID + "&InfoID=" + sKEY + "&OPERATOR=" + sOPERATOR + "\" frameborder=\"0\" scrolling=\"auto\" height='100%' width=\"750\"></iframe>");
	 }
  } 

%>

<% 
	
  if (!sWeboffice.equals("") && ((";" + assistant + ";").indexOf(";5;") >=0) && sNavigator_SESSION.equals("MSIE")) {
	  session.setAttribute("SzModuleType", "");
	  session.setAttribute("SzModuleID", "");
	  session.setAttribute("SzInfoID", "");
	   
		String FileType   = sWeboffice;
		String ModuleType = "formEngine";
		int    ModuleID   = iFormID;
		
	    //取得RecordID
	    OfficeRecordID officeRecordID = new OfficeRecordID();
	    String RecordID  = officeRecordID.loadRecordID(ModuleType,ModuleID,iInfoID);
	    session.setAttribute("SzModuleType", ModuleType);
	    session.setAttribute("SzModuleID", Integer.toString(ModuleID));
	    session.setAttribute("SzInfoID", sKEY);
%>
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td>
      <iframe id="webOffice" width="100%" height="1380" 
              frameborder="0"
              src="../../share/weboffice/DocumentEdit.jsp?InfoID=<%=sKEY%>&FileType=<%=FileType%>&ModuleType=<%=ModuleType %>&ModuleID=<%=ModuleID %>&RecordID=<%=RecordID%>&EditType=<%=sEditType%>&Template=<%=sTemplateSelect%>">
      </iframe>
    </td>
  </tr>
</table>
<% } else if (!sWeboffice.equals("") && !sNavigator_SESSION.equals("MSIE")) {
	OfficeRecordID officeRecordID = new OfficeRecordID();
	String sFileLink = officeRecordID.getFileLink("formEngine", iFormID, iInfoID, sWeboffice);
	
	out.println("<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">");
	out.println("<tr><td><font color='red'>提示：</font>您使用的不是IE浏览器,word、excel、ppt不能在线编辑。</td></tr>");
	if (!sFileLink.equals("")) {
  		out.println("<tr><td>" + sFileLink + "</td></tr>");
	}	
	out.println("</td></tr></table>");
	 
   }
%>
<%
  if (!sOPERATOR.equals("add") && !sOPERATOR.startsWith("updateWin")) {
			//BdRelateForm bdRelateForm = new BdRelateForm();
			//out.println(bdRelateForm.relateChildList(iFormID, SzConvert.toInt(sKEY), false, canModifyForm, sOPERATOR));
  }
%>
<%
  //2013-12-04增加，显示关联数据
 	BdViewRelate bdViewRelate = new BdViewRelate();
	ArrayList listViewRelate = bdViewRelate.getList(moduleName, formName);
  if (listViewRelate != null && listViewRelate.size() > 0 && sOPERATOR.equals("detail")) {
%>
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td>
      <iframe id="detailRelate" width="100%" height="350" 
              frameborder="0"
              src="viewRelate/index.jsp?KEYRelate=<%=sKEY%>&moduleNameRelate=<%=moduleName%>&formNameRelate=<%=formName%>">
      </iframe>
    </td>
  </tr>
</table>
<% } %>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="FormID" value="<%=iFormID%>"> 
  
  <!-- 周报是需要用到 -->
  <input type="hidden" name="chkDate" value="0">   
  <input type="hidden" name="datefield" value="<%=datefield%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">  
  <input type="hidden" name="txtSearchDepart" value="<%=sSearchDepart%>">
  <input type="hidden" name="txtSearchBegin" value="<%=sSearchBegin%>">
  <input type="hidden" name="txtSearchEnd" value="<%=sSearchEnd%>">     
</form>


<%=bdValueControl.detailCheckJs()%>


<%=bdValueControl.updateJs(iInfoID, session, sOPERATOR, canModifyForm, strDenyField, strDenyField2)%>
<%=bdValueControl.detailJs(iInfoID, sOPERATOR, canModifyForm)%>
<%=LcFlowControl.fieldPopedom(iFormID, iFlowID, iInfoID, canModifyForm, isTransact) %>
<%=bdValueControl.saveCheckJs()%>
<%=bdValueControl.saveJs()%>

<script language="javascript">
  //var odetailTableId  = document.getElementById("detailTableId");
  //AddDetailRow3Print(oTable, vCount, true, vDetailCount);

  <% if (sReadonly.equals("readonly")) {%>
    hideAll(formUpdate.btnSelect);
    hideAll(formUpdate.pop1);
  <% } %>

  function FormSave(formName, url, vOPERATOR) {
		if (!FormCheck(formName)) {
			return false;
		}

    //保存前把流程ID、流程步骤ID、表单ID、信息ID等写到信息里面
    //流程相关
    <% if (hasFlow && !sOPERATOR.startsWith("updateWin")) {%>

    if (flowDraft.formList.LCID) {
      formName.LCID_FLOW.value = flowDraft.formList.LCID.value;
    }
    formName.BZRYID_FLOW.value = ValueOfCheck(flowDraft.formList.BZRYID);
    formName.BZXH_FLOW.value = flowDraft.formList.BZXH.value;
    formName.RYBLYJ_FLOW.value = flowDraft.formList.RYBLYJ.value;
    formName.RYBLTP_FLOW.value = flowDraft.formList.selectSignature.value;

    <% } %>	


    <% if (!sEditor.equals("")) {%>
    //formName.szContent.value=tbContentElement.DocumentHTML;
    <% } %>	
    <% if (!sWeboffice.equals("") && ((";" + assistant + ";").indexOf(";5;") >=0) && sNavigator_SESSION.equals("MSIE")) { %>    
    	//weboffice
    	formName.RecordID.value = webOffice.webform.RecordID.value;    
    	//保存历史版本
    	webOffice.webform.saveVersion.click(); 
    	    	
    	webOffice.webform.save.click(); 

    <% } %>
		//增加附件判断
    <% if (!sTableAnnex.equals("") && ((";" + assistant + ";").indexOf(";" + BdFormHelp.Assistant_Annex_NoNull+ ";") >=0)) { %>
			if (!annexNotNull()) {
			  return false;
			}
		<% } %>
    if (vOPERATOR != "") {
    	formName.OPERATOR.value = vOPERATOR;
    }

    document.getElementById("divLine").style.display = "block";
    //document.getElementById("saveButtonUpdate").disabled = true;
		vBeforeFrameHtmlUnload = false;	
		FormJsBeforeSave(formName);		    
    formName.action = url;
    formName.submit();      

  }   
  
  
  function FormSaveConfirm(formName, url, vOPERATOR) {

    //保存前把流程ID、流程步骤ID、表单ID、信息ID等写到信息里面
    //流程相关
    if (flowDraft.formList.LCID) {
      formName.LCID_FLOW.value = flowDraft.formList.LCID.value;
    }
    formName.BZRYID_FLOW.value = ValueOfCheck(flowDraft.formList.BZRYID);
    formName.BZXH_FLOW.value = flowDraft.formList.BZXH.value;
    formName.BZID_FLOW.value = flowDraft.formList.BZID.value;
    
    formName.RYBLYJ_FLOW.value = flowDraft.formList.RYBLYJ.value;
    formName.RYBLTP_FLOW.value = flowDraft.formList.selectSignature.value;
    
    <% if (!sOPERATOR.equals("add") && !sOPERATOR.equals("update")) { %>  
    if (formName.RYBLYJ_FLOW.value == "") {
    	alert("办理意见不能为空");
    	return;
    }
    <% } %>

		    
    var vMessage = "";
    if (vOPERATOR == "transact" || vOPERATOR == "send") {
      vMessage = "确定要发送？";
      if (formName.BZRYID_FLOW.value == "0" || formName.BZRYID_FLOW.value == "") {
    	  alert("请至少选择一个办理人员！");
    	  return false;
      } 
      //当multipart/form-data时，request不到后面的值，所以补充了下面      
    } else if (vOPERATOR=="transactFinish") {
      vMessage = "确定要办结？";    
    } else if (vOPERATOR=="transactDeny") {
      vMessage = "确定要否决？";    
    }
    if (vOPERATOR != "") {
    	formName.OPERATOR.value = vOPERATOR;
    } 
    
		if (!FormCheck(formName)) {
			return false;
		}       

    //增加附件判断
    <% if (!sTableAnnex.equals("") && ((";" + assistant + ";").indexOf(";" + BdFormHelp.Assistant_Annex_NoNull+ ";") >=0)) { %>
			if (!annexNotNull()) {
			  return false;
			}
		<% } %>
		
    if (confirm(vMessage)) {
    	<% if (!sEditor.equals("")) {%>
    	//formName.szContent.value=tbContentElement.DocumentHTML;
    	<% } %>	
    	<% if (!sWeboffice.equals("") && ((";" + assistant + ";").indexOf(";5;") >=0) && sNavigator_SESSION.equals("MSIE")) { %>
    	//weboffice
    	formName.RecordID.value = webOffice.webform.RecordID.value;
    	//保存历史版本
    	webOffice.webform.saveVersion.click();     	
    	webOffice.webform.save.click(); 
    	<% } %>    
    	


				
				document.getElementById("divLine").style.display = "block";
				//document.getElementById("saveButtonUpdate").disabled = true;
				
			//2012-01-11增加
			vBeforeFrameHtmlUnload = false;	
			FormJsBeforeSave(formName);						
      	formName.action = url;
      	formName.submit();      
    }
  }
  
  //查看关联的提醒信息
  function OpenAlertInfoWin(keyValue,formId) {
    var vUrl = "../alert/detail_index.jsp?OPERATOR=detail&KEY=" + keyValue + "&FormID=" + formId;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=480");  
  }
    
  function OpenDetailWin(keyValue,formId) {
    var vUrl = "detail_win.jsp?OPERATOR=detail&KEY=" + keyValue + "&FormID=" + formId;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  }
  function OpenUserSelectWin(name) {
    var vUrl = "select_user.jsp?name=" + name;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=680,height=450");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=680px;dialogHeight=450px");  
  }
  
  function OpenUpdateWin(keyValue,formId) {
    var vUrl = "update.jsp?OPERATOR=updateWin&KEY=" + keyValue + "&FormID=" + formId;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  }
  
  function OpenRelateDetailWin(keyValue,formId, pKey, pFormId, relateId) {
    var vUrl = "relate_detail.jsp?OPERATOR=detail&KEY=" + keyValue + "&FormID=" + formId + "&PKEY=" + pKey + "&PFORM=" + pFormId + "&type=" + relateId;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  }     
  function OpenRelateUpdateWin(keyValue,formId, pKey, pFormId, relateId, vOPERATOR) {    
    var vUrl = "relate_update.jsp?OPERATOR=updateWin&OPERATOR_SOURCE=" + vOPERATOR +"&KEY=" + keyValue + "&FormID=" + formId + "&PKEY=" + pKey + "&PFORM=" + pFormId + "&type=" + relateId;
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  } 
  function LogWin() {
    var vUrl = "../../share/other/logList.jsp?LogType=FORM&ModuleID=<%=iFormID%>&InfoID=<%=sKEY%>";
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  }   
  
  function RelateWin(vTriggerName ,oObject) {     
  	//这里就要取得值
  	//var vTriggerName = formUpdate.TriggerName.value;
  	//var oObject = formUpdate.RelateObject.value;
  	var vValue = "";
  	if (oObject != "") {
  		vValue = eval("formUpdate." + oObject + ".value;");
  	}
    var vUrl = "relate_win.jsp?moduleName=<%=moduleName%>&formName=<%=formName%>&triggerName=" + vTriggerName + "&relateValue=" + vValue;
  	window.open(vUrl,"","left=1020,top=1020,width=1,height=1");
  	//window.open(vUrl,"","left=102,top=102,width=551,height=551,status=yes");
	
  }  
  
  function PrintWin() {
    var vUrl = "print.jsp?moduleName=<%=moduleName%>&formName=<%=formName%>&OPERATOR=detail&KEY=<%=sKEY%>";
  	window.open(vUrl,"","left=20,top=20,scrollbars=yes,resizable=yes,menubar=yes,width=780,height=550");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;dialogHeight=550px");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;");
  }
  
  function PrintWinWord() {
    var vUrl = "printTemp.jsp?FormID=<%=iFormID%>&KEY=<%=sKEY%>&type=0&printTemp=<%=printTemp%>&printTempRelate=<%=printTempRelate%>";
  	window.open(vUrl,"","left=20,top=20,width=600,height=600,resizable=yes");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;dialogHeight=550px");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;");
  }
  
  
  function PrintWinWordRelate() {
    var vUrl = "printTemp.jsp?FormID=<%=iFormID%>&KEY=<%=sKEY%>&type=1&printTemp=<%=printTemp%>&printTempRelate=<%=printTempRelate%>";
  	window.open(vUrl,"","left=20,top=20,width=600,height=600");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;dialogHeight=550px");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=720px;");
  }  

  function OfficeDetailWin(vKey) {
    //hideOperatorWin("div");
    var vRecordId = formUpdate.RecordID.value;
    var vUrl = "documentEdit.jsp?OPERATOR=<%=sOPERATOR%>&WebOffice=<%=sWeboffice%>&FormID=<%=iFormID%>&KEY=" + vKey + "&RecordId=" + vRecordId;
  	//window.open(vUrl,"","left=20,top=20,width=600,height=600");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=950px;dialogHeight=800px");
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=950,height=800");
  }   
  
  function StatWin(loginID, condObj) {
  	var condValue = "";
  	
  	if (condObj != "") {
  		condValue = eval("formUpdate." + condObj + ".value");
  	}     
    //alert(condObj + "==" + condValue);
    var vUrl = "stat_month_depart_user.jsp?FormID=<%=iFormID%>&loginID=" + loginID + "&condValue=" + encodeURIComponent(condValue) + "&win=1";
  	window.open(vUrl,"","left=102,top=102,width=851,height=251,status=yes,resize=yes");	
  }    
  
  //这里做退回、跳签需要传递的参数：流程ID，操作类型
  function transactWin(vFlowID, vOPERATOR) {
    var vUrl = "../../flow/flow/untread_win.jsp";
    if (vOPERATOR == "transactUntread") {
    
    } else if (vOPERATOR == "transactSkip") {
    
    }
    vUrl += "?OPERATOR=" + vOPERATOR + "&FlowID=" + vFlowID;
    //window.showModalDialog(vUrl,window,"status=no;dialogWidth=680px;dialogHeight=580px");  
    window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=680,height=580");
  }  
  
  function transactSubmit() {
		if (!FormCheck(formUpdate)) {
			return false;
		}
	  formUpdate.RYBLYJ_FLOW.value = flowDraft.formList.RYBLYJ.value;
	  formUpdate.RYBLTP_FLOW.value = flowDraft.formList.selectSignature.value;  
	  <% if (!sEditor.equals("")) {%>
		  //formUpdate.szContent.value=tbContentElement.DocumentHTML;
	  <% } %>	
	  <% if (!sWeboffice.equals("") && ((";" + assistant + ";").indexOf(";5;") >=0) && sNavigator_SESSION.equals("MSIE")) { %>
    	//weboffice
    	formUpdate.RecordID.value = webOffice.webform.RecordID.value;
    	//保存历史版本
    	webOffice.webform.saveVersion.click();     	
    	webOffice.webform.save.click(); 
	  <% } %> 	
      <% if (hasAnnex) { %>		  
	    formUpdate.action = "control2.jsp";
	  <% } else {%>
	    formUpdate.action = "control.jsp";
	  <% } %>
	  
	  
			//2012-01-11增加
			//vBeforeFrameHtmlUnload = true;		
			FormJsBeforeSave(formUpdate);		  
	    formUpdate.submit();  
  }
  
  function feedbackWin(vKey) {
    var vUrl = "feedback.jsp?FormID=<%=iFormID%>&KEY=" + vKey; 
  	window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=700");  
  }    
  
  //document.all.['flowDraft'].style.height = vHeight;  
  
  //只有"spdb.xml" "limit"才用到，暂时屏蔽
  //initialJs("<%=moduleName%>","<%=formName%>");

  //初始化后才能调用AJAX
  <% 
	//if (iFormID == 1341) {
		//out.println("	qingjiaLeixing();");
	//}
  	//自动触发2013-11-20
  	out.println(bdTrigger.autoTriggerJs(sTriggerName, sOPERATOR, "triggerButton"));  	
  	//自动编号2013-11-25
  	BdNumberRuler bdNumberRuler = new BdNumberRuler();
  	out.println(bdNumberRuler.autoNumberJs(sOPERATOR,moduleName,formName));
  %>
  
		//页面解除锁定
	window.onbeforeunload = function() {

		  var moduleType = "formEngine";
		  var moduleId = "<%=iFormID%>";
		  var infoId = formUpdate.KEY.value;
			var vUrl = "../../share/page/edit_unlock.jsp?moduleType=" + moduleType + "&moduleId=" + moduleId + "&infoId=" + infoId;

		  AJAX(vUrl, "", false);
	}    

</script>
<div id="divLine" class="divLine" align="center" style="position:absolute;width:450;height:150px;left:150px;top:150px;padding:60px 0 0 0; margin:0px;overflow:auto;overflow:hidden;display:none; background-color:#dbdbdb;">
	<img src="<%=strSkin_SESSION%>/bar.gif">
</div><!---------------------------------------------------------------20120112 ting----------------------------------------->

</body>
<%
out.println(SzPageHelp.calendarFrame2());
out.println(SzPageHelp.calendar2Frame2());
%>
</html>
