
<%    /**
     * **********************************************************
     * @@ Program Name  : doc_view.jsp
     * @@ Description	: /집계자/내문서함/진행함/집계현황
     * @@ Author	: 기현테크
     * @@ Create Date   : 2010.11.24
     * @@ History	:
     * @@***********************************************************
     */
%>

<%@ page contentType="text/html; charset=UTF-8"
         import="java.net.URLDecoder"
         import="kr.co.kihyun.beans.user.HttpSSOLogin"
         import="kr.co.kihyun.lang.MLong"
         import="kr.co.kihyun.moumi.Moumi"
         import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.lang.MInteger"
         import="kr.co.kihyun.lang.MString"
         import="kr.co.kihyun.moumi.doc.MDoc"
         import="kr.co.kihyun.beans.totsys.menu.MenuBean"
         import="javax.jdo.PersistenceManager"
         import="javax.jdo.Transaction"
         import="kr.co.kihyun.beans.entity.util.*"
         import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@ 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 docID = MLong.parseLong(request.getParameter("docID"), null);
        String docType = clearXSS(request.getParameter("docType"), null);
        int strPage = MInteger.parseInt(request.getParameter("strPage"), 1);
        String findOption = clearXSS(request.getParameter("findOption"), "");
        String findWord = clearXSS(Encoder.toJava(request.getParameter("findWord")), "");
        String stDate = clearXSS(request.getParameter("stDate"),"");
        String edDate = clearXSS(request.getParameter("edDate"),"");

        String method = clearXSS(request.getParameter("method"), "");
        if (method.equals("GET")) {
            findWord = URLDecoder.decode(MString.checkNull(request.getParameter("findWord")), "UTF-8");
        }

        Long reportID = MLong.parseLong(request.getParameter("reportID"));
        String searchDepth = clearXSS(request.getParameter("searchDepth"), "");
        int innerStrPage = MInteger.parseInt(request.getParameter("innerStrPage"), 1);;
        String innerFindOption = clearXSS(request.getParameter("innerFindOption"), "");
        String innerFindWord = clearXSS(Encoder.toJava(request.getParameter("innerFindWord")), "");

        if(findWord != null || innerFindWord != null){
            String[] filter_word= {"--", "\\(", "\\)", "\\'", "\\\""};
            for(int ii=0; ii< filter_word.length;ii++){
                findWord = findWord.replaceAll(filter_word[ii], "");
                innerFindWord = innerFindWord.replaceAll(filter_word[ii], "");
            }
        }

        tx.begin();

        TotDoc totDoc = pm.getObjectById(TotDoc.class, docID);
        String regID = totDoc.getUser(pm).getId();
        String docName = totDoc.getName();

        tx.rollback();

        MenuBean modifyMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/doc_modify.jsp?docID=" + docID + "&docType=" + docType + "&strPage=" + strPage + "&method=GET&findOption=" + findOption + "&findWord=" + MString.checkNull(findWord));
        MenuBean reportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/reports/report_list.jsp?docID=" + docID + "&docType=" + docType + "&strPage=" + strPage + "&method=GET&findOption=" + findOption + "&findWord=" + MString.checkNull(findWord));
        MenuBean totReportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_reports/total_reports.jsp?docID=" + docID + "&docType=" + docType + "&reportID=" + reportID + "&strPage=" + strPage + "&method=GET&findOption=" + findOption + "&findWord=" + MString.checkNull(findWord));
        MenuBean totReportMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_report/total_report.jsp?docID=" + docID + "&docType=" + docType);
        if(innerFindWord.startsWith("%")){
        	innerFindWord=URLDecoder.decode(innerFindWord, "UTF-8");
        }
%>
<!DOCTYPE html>
<html lang="ko">
		<head>
        <title><%=Moumi.getTitle()%></title>
		<meta charset="UTF-8">
        <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/contentStyle.css" type="text/css">
		<link rel="stylesheet" href="/totsys/common/css/basic.css" type="text/css">
        <script src="/totsys/common/js/rollover.js"></script>
        <script>
            function modify() {
            	//연계문서일경우 기본정보로 갈수 있게
            	//부서관리자 수정가능하게 SUB_TOTADM 추가  by wonseok Lee 20171108
                if ("<%=regID%>" == "<%=usID%>" || <%=sysAuth%> == "<%=Moumi.SYSADM%>" || <%=sysAuth%> == "<%=Moumi.SUB_SYSADM%>" || <%=sysAuth%> == "<%=Moumi.SUB_TOTADM%>"||<%=docID%>>=1700000000) {
                    location.href = "<%= modifyMenu.getUrl()%>";
                } else {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.docModify")%>');
                }
            }
        </script>
    </HEAD>
    <body>
        <div>
            <table>
                 <jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" >
                    <jsp:param value='<%= docName%>' name="desc" />
                </jsp:include>
                <!--jsp:include page="/totsys/common/inc/totper/top/top.jsp" flush="true" /-->
            </table>
        </div>
        <div id="header">
            <ul id="primary">
             <!-- ie10,11 에서 호환성 보기 문제 수정 a 태그에 스타일 추가 -->
                <li><a href="#" onclick="modify();" style="padding: 0px; line-height: 25px;"><%= modifyMenu%></a></li>
                <li><a href="<%= reportsMenu.getUrl()%>" style="padding: 0px; line-height: 25px;"><%= reportsMenu%></a></li>
                <li><span class="kecttep_menu_focous" style="padding: 0px; line-height: 25px;"><%= totReportsMenu%></span></li>
                <!--li><a href="<%= totReportMenu.getUrl()%>" style="padding: 0px; line-height: 25px;"><%= totReportMenu%></a></li-->
            </ul>
        </div>
        <div id="main">
            <div id="contents">
                    <jsp:include page="/totsys/common/inc/documents/tot_reports/total_reports.jsp" flush="true">
                        <jsp:param name="docID" value="<%= docID%>" />
                        <jsp:param name="strPage" value="<%= strPage%>" />
                        <jsp:param name="findOption" value="<%= findOption%>" />
                        <jsp:param name="findWord" value="<%= MString.checkNull(findWord)%>" />
                        <jsp:param name="searchDepth" value="<%= searchDepth%>" />
                        <jsp:param name="innerStrPage" value="<%= innerStrPage%>" />
                        <jsp:param name="innerFindOption" value="<%= innerFindOption%>" />
                        <jsp:param name="innerFindWord" value="<%= MString.checkNull(innerFindWord)%>" />
                        <jsp:param name="listType" value="" />
                        <jsp:param name="docType" value="<%= docType%>" />
                        <jsp:param name="reportID" value="<%= reportID%>" />
                        <jsp:param name="stDate" value="<%= stDate%>" />
                        <jsp:param name="edDate" value="<%= edDate%>" />
                    </jsp:include>
            </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();
    }
%>
