
<%
/************************************************************@@
  * Program Name	: report_view.jsp
  * Description		: /보고자/내문서함/재보고함/보고자료 모기
  * Author			: 기현테크
  * Create Date		: 2010.11.26
  * History			:
@@************************************************************/
%>

<%@ page contentType="text/html; charset=UTF-8"
	import="javax.jdo.PersistenceManager" import="java.util.*"
	import="java.net.URLEncoder" import="java.net.URLEncoder"
	import="java.net.URLDecoder"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.lang.MLong" import="kr.co.kihyun.lang.MInteger"
	import="kr.co.kihyun.moumi.Moumi"
	import="kr.co.kihyun.moumi.report.MReport"
	import="kr.co.kihyun.lang.Encoder" import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.entity.*"
	import="kr.co.kihyun.text.html.TagFilter"%>
<%@ page import="java.util.Map.Entry"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try{
	/********** session내의 userId **********/
	String usID = HttpSSOLogin.getLoginID(request);
	int sysAuth = HttpSSOLogin.getSysAuth(request);
	
	/********** Parameter **********/
	Long reportID = MLong.parseLong(request.getParameter("reportID"),null);
	String strPage = clearXSS(request.getParameter("strPage"),"");
	//String boxName = "returnbox";
	String boxName = MString.checkNull(request.getParameter("boxName"));

	tx.begin();
	
	Long downDocID = MLong.parseLong(request.getParameter("downDocID"),null);
	TotReport totReport = (TotReport)pm.getObjectById(TotReport.class, reportID);
	String boardGroupID = Category.ID_TOT_DOC_COMMENT;
	TotDoc.TotRange totRange = totReport.getTotDoc().getTotRange();

	tx.rollback();
	
	String boardTitle = "";
	String boardContents = "";	
	String usrFilenames = "";
	String svrFilenames = "";
	int visit = 0;

	Board totperComment = totReport.getTotDoc().getBoard();

	if(totperComment != null){
		tx.begin();
		boardTitle = totperComment.getTitle();
		boardContents=TagFilter.convertSpace(totperComment.getContents());
		for (Entry<String, List<Byte>> entry : totperComment.getAttachments().entrySet()) {
			usrFilenames += entry.getKey() + ";";
			svrFilenames += entry.getKey() + ";";
		}
		visit = totperComment.getVisit();
		totperComment.setVisit(visit+1);
		pm.makePersistent(totperComment);
		tx.commit();
	}
	
	String[] usrFilenameList = usrFilenames.split(";");
	String[] svrFilenameList = svrFilenames.split(";");
%>


<%@page import="javax.jdo.Transaction"%><HTML>
<HEAD>
<TITLE><%=Moumi.getTitle()%></TITLE>
<link rel="stylesheet" href="/totsys/common/css/text.css"
	type="text/css">
<link rel="stylesheet" href="/totsys/common/css/kecttep.css"
	type="text/css">
<link rel="stylesheet" href="/totsys/common/css/SquareButtons.css"
	type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script src="/totsys/common/js/popup.js"></script>
<link rel="stylesheet" href="/totsys/common/css/tabs.css"
	type="text/css">
<script>
			function NotDocGO(){
				var bool = confirm('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notTrans")%>');
				if(bool){
					NotDoc.submit();
				}else return;
			}
			function subRegGO(){
				subReg.submit();
			}
			function showMsgAlert(){
				location.href="../tempbox/<%if(totReport.getSlaveTotDoc() == null){%>report_regist.jsp<%}else{%>tot_report_regist.jsp<%}%>?reportID=<%= reportID %>";
			}
			function showAlert(){
				location.href="../tempbox/<%if(totReport.getSlaveTotDoc() == null){%>report_regist.jsp<%}else{%>tot_report_regist.jsp<%}%>?reportID=<%= reportID %>";
			}
			function pageMove(){
				location.href="./return_report_modify.jsp?reportID=<%= reportID %>&type=returndoc";
			}
		</script>

</HEAD>

<body style='' BGCOLOR="#FFFFFF" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0
	MARGINHEIGHT=0 " onload="scrollObjectContent('formDiv');">

<form name="NotDoc" method="post"
	action="/servlet/kr.co.kihyun.beans.totsys.repoper.HttpNotUpdate">
<input type="hidden" name="reportID" value="<%= reportID %>"></form>

<form name="subReg"
	action="/totsys/totper/mydocbox/regbox/sub_doc_regist.jsp"
	method="post"><input type="hidden" name="reportID"
	value="<%= reportID %>"> <input type="hidden" name="boxName"
	value="<%= boxName %>"></form>

<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />
	<jsp:include page="/totsys/common/inc/repoper/top/top.jsp" flush="true" />
</table>
</div>

<div id="header">
<ul id="primary">
	<li><span class="kecttep_menu_focous"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.information")%></span></li>
	<%if("acceptbox".equals(boxName)){%>
	<li><a href="#" <%if(totRange==TotDoc.TotRange.INTERNAL){%>
		onClick='showMsgAlert()' ;<%}else{%> onClick='showAlert()';<%}%>"><%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.doc") %><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.input")%></a></li>
	<%if(Moumi.is2Step()){ %>
	<li>
	<% if(sysAuth == Moumi.SUB_TOTPER || sysAuth == Moumi.TOTPER){%><a
		href="#" onclick="subRegGO();"><%= TotDocType.SUB_DOC%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.registrition")%></a>
	<%
	}
	%>
	</li>
	<%
	}
	%>
	<%
	}else{
		if (totReport.getSlaveTotDoc() == null) {%>
	<li><a href="#" onclick="pageMove();"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.doc")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.modify")%></a></li>
	<%
		}
	}
	%>
</ul>
</div>

<div id="main">
<div id="contents">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr class="toolbar">
		<td align="left">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<%if(!"acceptbox".equals(boxName)){%>
				<%if(Moumi.getUseAssign()){%>
				<td><a href="#"
					onclick="window.open('/totsys/memo/reassign/pop_reassign.jsp?docID=<%=totReport.getTotDoc().getId()%>','reassgin','width=601, height=450,toolbar=no, directories=no, status=no, menubar=no, resizable=no');"><img
					src="/totsys/common/images/bt_reassign.gif" border="0"></a></td>
				<%}%>
				<td><a class="simplebutton" href="#" onclick="NotDocGO();"><span
					class="no"><%= Moumi.getMessageBundle().getString("moumi.message.button_small.not") %></span></a>
				</td>
				<td class="kecttep_button_td"><a class="simplebutton" href="#"
					onclick="window.open('./popup_rep_transfer.jsp?reportID=<%=reportID%>&boxName=<%=boxName%>','','width=607, height=541,toolbar=no, directories=no, status=no, menubar=no, resizable=no');"><span
					class="modify"><%= Moumi.getMessageBundle().getString("moumi.message.button_small.trans") %></span></a>
				</td>
				<%}%>
				<%if(!MString.isNull(boardContents) || !MString.isNull(svrFilenames)){%>
				<td class="kecttep_button_td"><a class="simplebutton" href="#"
					onclick="totperInfo('<%= totReport.getTotDoc().getId() %>','<%= boardGroupID%>');"><span
					class="info"><font color="red"><strong><%= Moumi.getMessageBundle().getString("moumi.message.button_small.totperInfo") %></strong></font></span></a>
				</td>
				<%}%>
			</tr>
		</table>
		</td>
	</tr>

	<tr>
		<!---- 내용---->
		<td height="31" valign="top">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr height="10">
				<td height="10"></td>
				<td height="10"></td>
				<td height="10"></td>
				<td height="10"></td>
			</tr>

			<!------------------------------- 집계자 정보 시작 ------------------------------->
			<jsp:include page="/totsys/common/inc/totper/totper.jsp" flush="true">
				<jsp:param name="docID" value="<%= totReport.getTotDoc().getId() %>" />
			</jsp:include>
			<!------------------------------- 집계자 정보 끝 --------------------------------->

			<tr nowrap height="10">
				<td nowrap width="149" height="10"></td>
				<td height="10"></td>
				<td nowrap width="149" height="10"></td>
				<td height="10"></td>
			</tr>
			<%if("acceptbox".equals(boxName)){%>
			<!------------------------------- form view start ------------------------------->
			<jsp:include
				page="/totsys/common/inc/documents/tot_doc/form_view.jsp"
				flush="true">
				<jsp:param name="docID" value="<%= totReport.getTotDoc().getId() %>" />
				<jsp:param name="type" value="repoper" />
			</jsp:include>
			<!------------------------------- form view end ------------------------------->
			<%}%>

			<%if(!"acceptbox".equals(boxName)){%>
			<!---- 재입력요청내용 ---->
			<jsp:include page="/totsys/common/inc/memo/reReport_Contents.jsp"
				flush="true">
				<jsp:param name="reportID" value="<%= reportID %>" />
				<jsp:param name="groupID" value='<%= "555" %>' />
			</jsp:include>
			<!------ 재보고 사유 끝 ----->

			<tr>
				<td>&nbsp;</td>
				<td colspan="3">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="4" valign="top"><!------------------------------- 문서 내용 시작 ------------------------------->
				<jsp:include
					page="/totsys/common/inc/documents/report/report_view.jsp"
					flush="true">
					<jsp:param name="reportID" value="<%= reportID %>" />
				</jsp:include> <!------------------------------- 문서 내용 시작 ------------------------------->
				</td>
			</tr>
			<%}%>
		</table>
		</td>
	</tr>
</table>
</div>
</div>
<!------------------------------- top menu start ------------------------------->
<%@ include file="/totsys/common/inc/buttom/buttom.jsp"%>
<!------------------------------- top menu end ------------------------------->
</BODY>
</HTML>
<%
}catch(Exception ex){
	ex.printStackTrace();
	out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
}finally{
	if(tx.isActive())
		tx.rollback();
	pm.close();
}
%>
