<%@ 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.tool.*" %>
<%@ page import="net.sz600.docEngine.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.online.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%@ include file="/docEngine/docEngineSession.jsp"%>
<%
  String strLevel = "../../";
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="<%=strSkin_SESSION%>/css2007detail.css" rel="stylesheet" type="text/css">
<style type=text/css>
.detailTitle {
    height:30px;
    font-size:13pt;
}
</style>
</head>
<%
	//获取信息 以权限设置
	int DLID = Integer.parseInt(szDLID_SESSION);
	String DLXM = szLoginInfo_SESSION.getDLXM();
    //获取提交的参数
    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 sTable_type = "SZKC_CPFL";
    boolean canSeeAnnex = false;
    
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.equals("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    //读取数据
    WdyqDocInfo wdyqDocInfo = null;
    WdyqDoc wdyqDoc = new WdyqDoc(moduleId);
    if (!sKEY.equals("0")) {
        wdyqDocInfo = (WdyqDocInfo)wdyqDoc.getInfoByKey(SzConvert.toInt(sKEY));
        
				//读取相关的提醒。2016-04-13增加
				OlMessageControl olMessageControl = new OlMessageControl();
				olMessageControl.readMessage(SzConvert.toInt(moduleId), SzConvert.toInt(sKEY), iDLID_SESSION, 1);
		
        //增加阅读记录        
        if (docEngineInfo.getHasReadRecord().equals("1")) {
            wdyqDoc.read(Integer.parseInt(sKEY), sBMMC_SESSION, iDLID_SESSION, sDLXM_SESSION);
        }
    }
    
    //String sContent = wdyqDocInfo.getXXNR();
    String sContent = "";

%>
<body  onload="javascript:ResizeFrame();">
<!-----上面的工具栏------>
<form name="formUpdate" method="post"  ENCTYPE="multipart/form-data">
  <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%>">
<%@ include file="/docEngine/title.jsp"%>
<table width="100%">
  <tr>
    <td>
      <%=SzPageHelp.backButton()%>
      <%//=SzPageHelp.button("写进日程","javascript:WriteTask();")%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="750" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" class="detailTitle"><font size="5"><b><%=wdyqDocInfo.getXXBT()%></b></font></td>
  </tr>

  <tr>
    <td align="center" class="detailTitle">
     <%  
       out.println("" + wdyqDocInfo.getXXDLXM());
       if (!wdyqDocInfo.getXXBMMC().equals("")) {
       	out.println("(" + wdyqDocInfo.getXXBMMC() + ")");
       }       
       out.println("&nbsp;" + wdyqDocInfo.getXXSJ());
     %>
   </td>    
  </tr>  
  <tr>
    <td>
      <table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">

    
<%  //文档是否带有word?
	if (docEngineInfo.getEditor().equals(".doc")
			|| docEngineInfo.getEditor().equals(".xls")
			|| docEngineInfo.getEditor().equals(".ppt")) {  		
	} else {
%>
        <tr>
          <td colspan="3" width="100%">
<table width="100%" height="200" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td><%out.println(wdyqDocInfo.getXXNR()); %>
    </td>
  </tr>
</table>
          </td>
        </tr>
<%		
	}
%>	                    

      </table>
    </td>
  </tr>
</table>
<%  //文档是否带有word?
	if (docEngineInfo.getEditor().equals(".doc")) {  
		String FileType   = docEngineInfo.getEditor();
		String ModuleType = "docEngine";
		int    ModuleID   = SzConvert.toInt( moduleId );
		
	    //取得RecordID
	    OfficeRecordID officeRecordID = new OfficeRecordID();
	    String RecordID  = officeRecordID.loadRecordID(ModuleType,ModuleID,Integer.parseInt(sKEY));	
	    
	    //20120621增加判断,文件是否存在
	    //String strPath = "/HTML/" + RecordID + ".htm";
	    //2015-01
	    //String strPath = iWebOfficeNew.IMG_PATH + RecordID + ".htm";
	    //String strPath = iWebOfficeNew.HTML_PATH + RecordID + ".htm";
	    String strPath = iWebOfficeNew.HTML_PATH_UTF8 + RecordID + ".htm";
	    boolean flag = SzFile.isExist(SzProperties.getRootPath() + strPath );
	    if (!flag) {
	    	strPath = "";
	    } else {
	    	strPath = "../../" + strPath;
	    	
	    }

%>
<table width="750" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td>

      <table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
        <tr>
          <td>

      		<iframe id="docDetail" width="100%"  height="100%"
              frameborder="0" charset="UTF-8"
              src="<%=strPath%>">
      		</iframe>

          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<% 		
	} 
%>	

<% if (docEngineInfo.getHasAnnex().equals("1")) {%>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td>
    <%
    canSeeAnnex = true;
    String canSeeStr = SzPageHelp.detailAnnexNew2(readDocEngineXml.getAnnexTable(moduleId), sKEY, docEngineInfo.getPicture(),strLevel_SESSION);
    String cannotSeeStr = canSeeStr;
    //System.out.println(docEngineInfo.getAnnexHasUserLimit() + "======" + wdyqDocInfo.getXXFJCKDLID());
    if (isBarManager_SESSION){
    	canSeeAnnex = true;
    } else if(docEngineInfo.getUploadUserCanSeeAnnex().equals("1") && wdyqDocInfo.getXXDLID()==DLID){
    	canSeeAnnex = true;
    } else if(docEngineInfo.getAnnexHasUserLimit().equals("1")) {
		if ( (","+wdyqDocInfo.getXXFJCKDLID()+",").indexOf(","+DLID+",")>0
    	  || ("，"+wdyqDocInfo.getXXFJCKDLID()+"，").indexOf("，"+DLID+"，")>0) {
    		canSeeAnnex = true;
    	} else {
    		canSeeAnnex = false;
    	}
    }
    if (!canSeeAnnex) {
    	cannotSeeStr = cannotSeeStr.replaceAll("(?i)<a([^>]+)>","");
    	cannotSeeStr = cannotSeeStr.replaceAll("</a>", "");
    }

    %>
    <%=canSeeAnnex?canSeeStr:cannotSeeStr%>
    
    </td>
  </tr>
</table>
<% } %>
</form>
<%
	if (docEngineInfo.getEditor().equals(".xls")
			|| docEngineInfo.getEditor().equals(".ppt")
			) {
		
		String FileType   = docEngineInfo.getEditor();
		String ModuleType = "docEngine";
		int    ModuleID   = SzConvert.toInt( moduleId );
		
	    //取得RecordID
	    OfficeRecordID officeRecordID = new OfficeRecordID();
	    String RecordID  = officeRecordID.loadRecordID(ModuleType,ModuleID,Integer.parseInt(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?FileType=<%=FileType%>&ModuleType=<%=ModuleType %>&ModuleID=<%=ModuleID %>&RecordID=<%=RecordID%>&EditType=0">
      </iframe>
    </td>
  </tr>
</table>
<% } %>

<!-- 检查是否有归档 
--找到moduleName,formName,infoID

-->
<% 
  if (moduleId.equals("99910") || moduleId.equals("23")) { 
		LcPigonhole pigonhole = new LcPigonhole();
		out.println(pigonhole.printPigonholeDetail(moduleId, Integer.parseInt(sKEY)));
  } 
%>
<!-----这里包含要提交的内容--->
<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%>">
</form>
</body>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //弹出窗口，选择人员。这里特定是流程里某个步骤的选择人员。
  function PrintWin(moduleName, formName, key) {
    var vUrl = "../../share/formEngine2/detail_win.jsp?moduleName=" + moduleName 
             + "&formName=" + formName 
             + "&from=22&OPERATOR=detail&KEY=" + key;
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=900px;dialogHeight=550px");
  	//2015-03
		window.open(vUrl,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=800,height=550");			
  }
  
  function ResizeFrame() {
  	var oFrame = document.getElementById("docDetail");
	if (oFrame != null) {
          var vHeight2 = oFrame.document.body.scrollHeight;
   	  var vHeight= document.frames("docDetail").document.body.scrollHeight + 20;  
	  //alert(vHeight2 + "==" + vHeight);
	  if (vHeight < 200) {
	    vheight = 200;
	  }
	
	  oFrame.height = vHeight;  
	}
  }
  
</script>
<script language="javascript"  defer>
  function ResizeFrame1() {
  	var oFrame = document.getElementById("docDetail");
  	var vHeight= document.frames("docDetail").document.body.scrollHeight;  	
	oFrame.height = vHeight;  
  }  
  
  function WriteTask() {
    formUpdate.action = "control.jsp";
	formUpdate.OPERATOR.value = "task";
	formUpdate.submit();
  }

  //ResizeFrame1();
</script>

