<%@ 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.database.*" %>
<%@ 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.*" %>
<%@ include file="/sessionInfoWeixin.jsp"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<%@ include file="/share/oa_app_title.jsp"%>
 <link href="<%=strLevel_SESSION%>app/images/soarwell_css.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript" src="<%=strLevel_SESSION%>share/js/commonTool.js"></script>
 <script language="javascript">
   function OfficeDetail() {
     document.location.href.target="_blank";
     document.location.href="../../HTMLIMAGE/1403494709890.htm";
   }
 </script>
</head>

<%
    //获取提交的参数
    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 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;
    }   
    BdFormControl bdFormControl = new BdFormControl();

    
    String sHTML = "";    
	BdValueControl bdValueControl = new BdValueControl(moduleName, formName);	
	sHTML = bdValueControl.getHTML();
	
	String assistant = bdValueControl.getAssistant();  
	String sTableAnnex = bdValueControl.getTableAnnex();
	String sEditor    = bdValueControl.getEditor();
	String sWeboffice = bdValueControl.getWebOffice();
	String sTemplateSelect = bdValueControl.getTemplateSelect();
	
	boolean hasFlow   = bdValueControl.getHasFlow();
	boolean hasAnnex  = false;
	if (!sTableAnnex.equals("")) {
		hasAnnex = true;
	}


    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.startsWith("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    if (sOPERATOR.equals("detailPass")) {
    	LcFlowControl.readPass(iFormID, iDLID_SESSION, Integer.parseInt(sKEY));
        sReadonly = "readonly";
        bReadonly = true;    	
    }
    //读取数据
	String value_str[] = null;
    if (!sKEY.equals("0")) {
    	value_str = (String[])bdValueControl.getInfoByKey(Integer.parseInt(sKEY));
    	//System.out.println("value_str==aaaa=============" + value_str);
    }    
    String loginID = SzConvert.toSpaceStr(bdValueControl.getLoginID(value_str));
    if (loginID.equals("")) {
    	loginID = Integer.toString(iDLID_SESSION);
    }
    
    //检查是否有权利办理，如果没有就进入待办列表中
    if (from.equals(BdFormHelp.s_FROM_TRANSACT)) {
    	
    	LcFlowControl lcFlowControl = new LcFlowControl();
    	if (value_str == null || value_str[0] == null) {
    	} else {
			//读取相关的提醒。
    		OlMessageControl olMessageControl = new OlMessageControl();
    		olMessageControl.readMessage(iFormID, SzConvert.toInt(sKEY), iDLID_SESSION);
    		
    		//2011-07-12 该文设置为已读
    		lcFlowControl.readTransact(iFormID, SzConvert.toInt(sKEY), iDLID_SESSION);    		
    	}
    }     
    
    //2010-2-21
    BdPopedom bdPopedom = new BdPopedom();        
    String strDenyField = bdPopedom.getDenyField(iFormID, 0, iDLID_SESSION);
    String strDenyField2 = bdPopedom.getDenyField(iFormID, Integer.parseInt(sKEY), iDLID_SESSION); 
%>
<%    
    //流程相关
    //根据已经有的信息ID，读取流程ID
    LcFlowControl lcFlowControl = new LcFlowControl();
    //取得流程权限信息
    LcFlowPopedomInfo lcFlowPopedomInfo = lcFlowControl.getFlowPopedomInfo(iFormID, Integer.parseInt(sKEY));
    
    int iFlowID = lcFlowPopedomInfo.getFlowID();
	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();
	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;
	} else if (hasFlow && hasSend) {
		canTransactSave = true;
	} else if (!hasFlow) {
		canDraftSave = true;
	}
	boolean isTransact = false;
	if (sOPERATOR.startsWith("transact")) {
		isTransact = true;	
	}
	
	BdFormHelp bdFormHelp = new BdFormHelp();
	String sFromUrl = bdFormHelp.getFromUrl(from);

    SzReadForm szReadForm = new SzReadForm(iFormID); 
    szReadForm.read(iInfoID, sBMMC_SESSION, iDLID_SESSION, sDLXM_SESSION); 	


%>
  <form name="formUpdate" method="post">
<%@ include file="title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% 
    out.println( SzPageHelp.button("返回", "FormSubmit(formUpdate, '" + sFromUrl + "?FormID=" + iFormID + "')") );     
    %>         
    </td>
  </tr>
</table>
<table height="100" width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">

  <input type="hidden" name="LCID_FLOW" value="0">
  <input type="hidden" name="BZID_FLOW" value="0">
  <input type="hidden" name="BZRYID_FLOW" value="0">  
  <input type="hidden" name="RYBLYJ_FLOW" value="">   
  
  <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="KEY" value="<%=sKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <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="">    
      

<%
	bdValueControl.getDetailTitleApp();
	out.println(bdValueControl.printDetailValueApp(value_str, strDenyField, strDenyField2, 0, sType, iInfoID, "detail"));
%>   

<!-- 附件 -->
<% 
  if (!sEditor.equals("") && iInfoID>0) {
	out.println("	<tr>");
	out.println("	<td height=\"5\" align=\"left\" background=\"../images/line.gif\"></td>");
	out.println("	</tr>\n"); 
	out.println("<tr><td><a href='editor.jsp?FormID=" + iFormID + "&KEY=" + iInfoID + "' target='_blank'>编辑器正文</a></td></tr>");
  } 
  if (!sWeboffice.equals("")) {
  	OfficeRecordID officeRecordID = new OfficeRecordID();
  	String sFileLink = officeRecordID.getFileLink("formEngine", iFormID, iInfoID, sWeboffice);
  	if (!sFileLink.equals("")) {
    	out.println("	<tr>");
    	out.println("	<td height=\"5\" align=\"left\" background=\"../images/line.gif\"></td>");
    	out.println("	</tr>\n"); 
    	out.println("<tr><td>" + sFileLink + "</td></tr>");
  	}
  } 
  if (!sTableAnnex.equals("")) {
	out.println("	<tr>");
	out.println("	<td height=\"5\" align=\"left\" background=\"../images/line.gif\"></td>");
	out.println("	</tr>\n"); 
  	out.println("<tr><td>");

    if (bReadonly) {
    	out.println(SzPageHelp.detailAnnexNew2(sTableAnnex, sKEY, strLevel_SESSION));
    } else {
    	out.println(SzPageHelp.updateAnnexNew2(sTableAnnex, sKEY, strLevel_SESSION));
    }
    out.println("<td><tr>");
  } 
%>
</table>
<% 
  if (hasFlow) { 
%>  	
<table width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">
  <%@ include file="draft_app.jsp"%>  
</table>
<%
  } 
%>

<table width="100%">
  <tr>
    <td>
    <% 
        out.println( SzPageHelp.button("返回", "FormSubmit(formUpdate, '" + sFromUrl + "?FormID=" + iFormID + "')") );        
    %>         
    </td>
  </tr>
</table>
  </form>
