
<%  /**
     * **********************************************************
     * @@ Program Name  : doc_list.jsp
     * @@ Description	: /집계자/내문서함/진행함/보고문서 목록
     * @@ Author	: 기현테크 Create
     * @@ Date	        : 2010.11.21
     * @@ History	: 2014.10.07 Update by KWON,HAN :
     * @@***********************************************************
     */
%>
<%@ page contentType="text/html; charset=UTF-8"
         import="java.util.*"
         import="java.net.URLEncoder"
         import="java.net.URLDecoder"
         import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.moumi.Moumi"
         import="kr.co.kihyun.lang.MInteger"
         import="kr.co.kihyun.lang.MLong"
         import="kr.co.kihyun.lang.MString"
         import="kr.co.kihyun.moumi.doc.MDoc"
         import="kr.co.kihyun.beans.totsys.menu.MenuBean"
         import="kr.co.kihyun.moumi.report.MReport"
         import="kr.co.kihyun.beans.entity.*"
         import="kr.co.kihyun.beans.ecross.*"
         import="kr.co.kihyun.beans.entity.ecross.*"
         import="kr.co.kihyun.beans.entity.util.*"
         import="org.slf4j.Logger"
         import="org.slf4j.LoggerFactory"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="javax.jdo.Transaction"%>
<%@page import="kr.co.kihyun.beans.entity.util.*"%>
<%@page import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@page import="kr.co.kihyun.beans.user.HttpSSOLogin"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%    MPersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
    Transaction tx = pm.currentTransaction();
    MPersistenceManager eCrossPm = new MPersistenceManager(PMF.get("ECROSS").getPersistenceManager());
    Transaction eCrossTx = eCrossPm.currentTransaction();

    try {
        String usID = HttpSSOLogin.getLoginID(request);
        int sysAuth = HttpSSOLogin.getSysAuth(request);
        /**
         * **** Parameter *****
         */
        Logger LOG = LoggerFactory.getLogger("jsp");
        Long docID = MLong.parseLong(request.getParameter("docID"), null);
        int listType = MReport.ALL_LIST;

        if (!(clearXSS(request.getParameter("listType"), "").equals(""))) {
            listType = MInteger.parseInt(request.getParameter("listType"));
        }


        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 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");
        }

        String accAuth = clearXSS(request.getParameter("accAuth"), "");
        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=" + URLEncoder.encode(MString.checkNull(findWord),"UTF-8"));
        MenuBean reportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/reports/report_list.jsp?docID=" + docID + "&docType=" + docType + "&strPage=" + strPage + "&method=GET&findOption=" + findOption + "&findWord=" + URLEncoder.encode(MString.checkNull(findWord),"UTF-8"));
        //MenuBean totReportsMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_reports/total_reports.jsp?docID="+docID+"&docType="+docType);
        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=" + URLEncoder.encode(MString.checkNull(findWord),"UTF-8"));
        MenuBean totReportMenu = new MenuBean(request, "/totsys/totper/mydocbox/prssbox/tot_report/total_report.jsp?docID=" + docID + "&docType=" + docType);
%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="UTF-8">
        <title><%=Moumi.getTitle()%></title>
        <!--스타일시트-->
        <link rel="stylesheet" href="/totsys/common/css/kecttep.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/text.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 src="/totsys/common/js/popup.js"></script>
        <script src="/totsys/common/js/find.js"></script>
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>

        <script>
            function find2() {
                var word = document.searchForm.innerFindWord.value.length;
                var option = document.searchForm.innerFindOption.options[document.searchForm.innerFindOption.selectedIndex].value;

                document.searchForm.innerFindOption.value = option;
                if (document.searchForm.innerFindWord.value == "") {
                    alert("검색 단어를 입력해 주세요");
                    return;
                }
                if (document.searchForm.innerFindOption.value != "id" && word < 2) {
                    alert("검색어는 2글자 이상이어야 합니다.!");
                    return;
                }
                document.searchForm.submit();
            }

            function showMSG() {
                if (searchForm.innerFindOption.value == "regDate") {
                    msg.style.display = "block";
                } else {
                    msg.style.display = "none";
                }
            }

            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")%>');
                }
            }
            //ie10,11 호환성 보기 에러 수정
            $().ready(function(){
            	$('[name^="checkSlaveTotDoc"],[name^="checkReportID"]').each(function(){
            		$(this).attr('id',$(this).attr('name'));
            	});
            });
        </script>
    </HEAD>
    <body>
        <div>
            <table>
                <jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" >
                    <jsp:param value='<%= URLEncoder.encode(docName, "UTF-8")%>' name="desc" />
                </jsp:include>
            </table>
        </div>
        <!--tap 시작-->
        <div id="header">
            <ul id="primary">
            <!-- ie10,11 에서 호환성 보기 문제 수정 a 태그에 스타일 추가 -->
                <li><a href="#" onclick="modify();" style="padding: 0px; line-height: 25px;"><%= modifyMenu.getMenuName()%></a></li>
                <li><span class="kecttep_menu_focous" style="padding: 0px; line-height: 25px;"><%= reportsMenu%></span></li>
                <li><a href="<%= totReportsMenu.getUrl()%>" style="padding: 0px; line-height: 25px;"><%= totReportsMenu%></a></li>
                <!--li><a href="<%= totReportMenu.getUrl()%>"><%= totReportMenu%></a></li-->
            </ul>
        </div>
        <!--tap 끝-->
        <div id="main">
            <div id="contents">
                    <!--  문서 내용 -->
                    <jsp:include page="/totsys/common/inc/documents/report/report_list.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="<%= findWord%>" />
                        <jsp:param name="searchDepth" value="<%= searchDepth%>" />
                        <jsp:param name="innerStrPage" value="<%= innerStrPage%>" />
                        <jsp:param name="innerFindOption" value="<%= innerFindOption%>" />
                        <jsp:param name="innerFindWord" value="<%= innerFindWord%>" />
                        <jsp:param name="listType" value="<%= listType%>" />
                        <jsp:param name="docType" value="<%= docType%>" />
                        <jsp:param name="stDate" value="<%= stDate%>" />
                        <jsp:param name="edDate" value="<%= edDate%>" />
                    </jsp:include>
                    <!--  문서 내용 끝 -->
            </div>
        </div>
        <input id="tmpFind" type="hidden" name="tmpFind" value="<%=findOption%>">
        <script>
            if (tmpFind.value == "mDept.name") {
                searchForm.findOption.selectedIndex = 0;
            } else if (tmpFind.value == "mUser.name") {
                searchForm.findOption.selectedIndex = 1;
            } else if (tmpFind.value == "regDate") {
                searchForm.findOption.selectedIndex = 2;
            }
        </script>
    </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();
    }
%>
