
<%
/************************************************************@@
  * Program Name	: doc_view.jsp
  * Description		: /집계자/진행함/보고자료 보기
  * Author				: 강원중
  * Create Date		: 2004.10.11
  * History				:
@@************************************************************/
%>

<%@ page contentType="text/html; charset=UTF-8"
	import="java.net.URLEncoder"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.moumi.Moumi" import="kr.co.kihyun.lang.MLong"
	import="kr.co.kihyun.lang.Encoder" import="kr.co.kihyun.moumi.doc.MDoc"
	import="kr.co.kihyun.beans.totsys.doc.Doc"
	import="kr.co.kihyun.moumi.report.MReport"
	import="kr.co.kihyun.beans.totsys.memo.MemoList"
	import="kr.co.kihyun.beans.totsys.menu.MenuBean"
	import="kr.co.kihyun.beans.totsys.report.Report"
	import="javax.jdo.PersistenceManager" import="javax.jdo.Transaction"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@page import="kr.co.kihyun.beans.entity.TotReport"%>
<%@page import="kr.co.kihyun.beans.entity.TotReportProcess"%>

<%@ 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 docType = clearXSS(request.getParameter("docType"),null);
	
	String url = "prss";
	String groupID = "999";
	int prss = 1;

	tx.begin();

	TotReport totReport = pm.getObjectById(TotReport.class, reportID);

	String docName = totReport.getTotDoc().getName();
	String regID = totReport.getTotDoc().getUser(pm).getId();
	
	Report report = new Report();
	int recog = report.getRecog(totReport.getTotDoc().getId(), totReport.getDept(pm).getId(), totReport.getUser(pm).getId());

	MenuBean viewMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/doc_modify.jsp?docID="+totReport.getTotDoc().getId()+"&docType="+docType);
	MenuBean reportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/reports/report_list.jsp?docID="+totReport.getTotDoc().getId()+"&docType="+docType);
	MenuBean totReportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_reports/total_reports.jsp?docID="+totReport.getTotDoc().getId()+"&docType="+docType);
	MenuBean totReportMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_report/total_report.jsp?docID="+totReport.getTotDoc().getId()+"&docType="+docType);
%>

<%	session.setAttribute("reReportURI","opener.location='/totsys/totper/mydocbox/prssbox/reports/report_list.jsp?docID="+totReport.getTotDoc().getId()+"'");	%>

<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/tabs.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>
<script language="javascript">
			function cancle(){
				if("<%=regID%>" == "<%=usID%>"){
					reReportCan.submit();
				}else{
					alert("자신이 등록한 <%= Moumi.getMessageBundle().getString("moumi.message.doc")%>만 재입력취소 가능합니다.");
				}
			}
	
			function returnReport(){
				if("<%=regID%>" == "<%=usID%>"){
				<%if(Moumi.getUseRecog()){ %>
					if("<%=recog%>" == "<%=MReport.NOT_RECOG%>" || "<%=recog%>" == "<%=MReport.RETURN_RECOG%>")
						window.open('/totsys/memo/rereport/pop_rereport.jsp?docID=<%= totReport.getTotDoc().getId()%>&deptID=<%=totReport.getDept(pm).getId()%>&userID=<%= totReport.getUser(pm).getId() %>','rereport','width=601, height=300,toolbar=no, directories=no, status=no, menubar=no, resizable=no');
					else
						alert("결재가 완료된 <%= Moumi.getMessageBundle().getString("moumi.message.doc")%>는 <%=TotReportProcess.RETURN%> 하실수 없습니다");
				<%}else{%>
					window.open('/totsys/memo/rereport/pop_rereport.jsp?docID=<%= totReport.getTotDoc().getId()%>&deptID=<%=totReport.getDept(pm).getId()%>&userID=<%= totReport.getUser(pm).getId() %>','rereport','width=601, height=300,toolbar=no, directories=no, status=no, menubar=no, resizable=no');
				<%}%>
				
				}else{
					alert("자신이 등록한 <%= Moumi.getMessageBundle().getString("moumi.message.doc")%>만 <%=TotReportProcess.RETURN%> 가능합니다.");
				}
			}

			function printReport() {
				var uri = '/totsys/common/inc/documents/report/report_view_print.jsp?reportID=<%=reportID%>';
				sendReport = getOpener(uri, 'sendReport', 600, 650, 'center', 'middle', 'yes', 'yes');
				sendReport.focus();
			}

			function modify(){
				if("<%=regID%>" == "<%=usID%>" || <%=sysAuth%> == "<%=Moumi.SYSADM%>"){
					location.href="<%= viewMenu.getUrl() %>";
				}else{
					alert("자신이 등록한 <%=Moumi.getMessageBundle().getString("moumi.message.doc")%>만 정보수정이 가능합니다.");
				}
			}
		</SCRIPT>
</HEAD>

<body style='' BGCOLOR="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0"
	MARGINWIDTH="0" MARGINHEIGHT="0"
	onload="scrollObjectContent('formDiv');">
<FORM name="reReportCan"
	action="/servlet/kr.co.kihyun.beans.totsys.totper.HttpReReportCancle"
	method="post"><INPUT type="hidden" name="reportID"
	value="<%= reportID %>"></FORM>

<form name="prssChange" method="post"
	action="/servlet/kr.co.kihyun.beans.totsys.totper.HttpReportPrssChange">
<input type="hidden" name="docID"
	value="<%=totReport.getTotDoc().getId()%>"> <input
	type="hidden" name="url" value="report_view"> <input
	type="hidden" name="changePrss" value="return"> <input
	type="hidden" name="changeReportID" value="<%=reportID%>"> <input
	type="hidden" name="contents" value=""> <input type="hidden"
	name="docType" value="<%=docType %>"></form>

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

<div id="header">
<ul id="primary">
	<li><a href="<%= viewMenu.getUrl() %>"><%= viewMenu %></a></li>
	<li><span class="kecttep_menu_focous"><%= reportsMenu %></span></li>
	<li><a href="<%= totReportsMenu.getUrl() %>"><%= totReportsMenu %></a></li>
	<!--			<li><a href="<%= totReportMenu.getUrl() %>"><%= totReportMenu %></a></li>-->
</ul>
</div>

<div id="main">
<div id="contents">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr valign="bottom" class="toolbar">
		<td align="left">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>

				<%if("PRSS".equals(docType)){%>
				<%
							MemoList ml = new MemoList();
							int cnt = ml.contentsNull("555",totReport.getTotDoc().getId(),totReport.getDept(pm).getId(),MReport.RETURN,totReport.getUser(pm).getId());
							if( cnt == 0 ){
						%>
				<td><a class="simplebutton" onclick="returnReport()"
					style="cursor: hand"><span class="pencil"><%= Moumi.getMessageBundle().getString("moumi.message.button.return") %></span></a>
				</td>
				<%}else{%>
				<td><a class="simplebutton" onclick="cancle()"
					style="cursor: hand"><span class="recall"><%= Moumi.getMessageBundle().getString("moumi.message.button.returnCancel") %></span></a>
				</td>
				<%}%>
				<%}%>
				<td class="kecttep_button_td"><a class="simplebutton"
					href="/totsys/common/inc/documents/report/report_view_excel.jsp?reportID=<%= reportID %>"
					target="_parent"><span class="excel"><%= Moumi.getMessageBundle().getString("moumi.message.button.excel") %></span></a>
				</td>
				<td class="kecttep_button_td"><a class="simplebutton"
					onclick="printReport();" style="cursor: hand"><span
					class="print"><%= Moumi.getMessageBundle().getString("moumi.message.button.print") %></span></a>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr height="10">
		<td height="10"></td>
		<td></td>
		<td width="149"></td>
		<td width="331"></td>
	</tr>

	<jsp:include page="/totsys/common/inc/memo/reReport_Contents.jsp"
		flush="true">
		<jsp:param name="docID" value="<%= totReport.getTotDoc().getId() %>" />
		<jsp:param name="groupID" value="555" />
		<jsp:param name="prss" value="<%=MReport.RETURN%>" />
		<jsp:param name="deptID" value="<%=totReport.getDept(pm).getId()%>" />
		<jsp:param name="userID" value="<%= totReport.getUser(pm).getId() %>" />
	</jsp:include>

	<jsp:include page="/totsys/common/inc/documents/report/report_view.jsp"
		flush="true">
		<jsp:param name="reportID" value="<%= reportID %>" />
	</jsp:include>
</table>
</div>
</div>
<!------------------------------- top menu start ------------------------------->
<%@ include file="/totsys/common/inc/buttom/buttom.jsp"%>
<!------------------------------- top menu end ------------------------------->
</BODY>
</HTML>
<%
	tx.rollback();
}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();
}
%>
