
<%@page import="kr.co.kihyun.beans.entity.ecross.IRemotePersistable"%>
<%@page import="kr.co.kihyun.beans.ecross.VCMCCMC2013"%>
<%@page import="kr.co.kihyun.beans.ecross.ECrossInterface"%>
<%@page import="kr.co.kihyun.beans.entity.MDept"%>
<%
    /***********************************************************
     * @@ Program Name : doc_list.jsp
     * @@ Description : /집계자/내문서함/진행함/문서 목록
     * @@ Author : 기현테크
     * @@ Create Date : 2010.11.18
     * @@ History : 2014.09.30 Update by KWON,HAN : 페이징 처리하여 페이지별로 불러오도록 쿼리 수정
     * @@*******************************************************
     */
%>
<%@ page contentType="text/html; charset=UTF-8"
         import="java.net.URLEncoder"
         import="java.net.URLDecoder"
         import="java.util.List"
         import="java.util.Map"
         import="java.util.HashMap"
         import="java.util.Date"
         import="java.util.Calendar"
         import="java.text.SimpleDateFormat"
         import="javax.jdo.PersistenceManager"
         import="javax.jdo.Transaction"
         import="kr.co.kihyun.beans.user.HttpSSOLogin"
         import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.lang.MInteger"
         import="kr.co.kihyun.lang.MString"
         import="kr.co.kihyun.moumi.MoumiConfig"
         import="kr.co.kihyun.moumi.Moumi"
         import="kr.co.kihyun.beans.entity.util.*"
         import="org.slf4j.Logger"
         import="org.slf4j.LoggerFactory"
         import="kr.co.kihyun.service.TotDocService"
         import="kr.co.kihyun.service.vo.TotDocVO"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%

    MPersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
    Transaction tx = pm.currentTransaction();
    try {

        Logger LOG  = LoggerFactory.getLogger(this.getClass());
        String usID = HttpSSOLogin.getLoginID(request);
        String dpID = HttpSSOLogin.getDeptID(request);
        int sysAuth = HttpSSOLogin.getSysAuth(request);
        String docType = clearXSS(request.getParameter("docType"), null);
        int strPage = MInteger.parseInt(request.getParameter("strPage"), 1);
        if(strPage <= 0) { strPage = 1; }

        String findOption = clearXSS(request.getParameter("findOption"), "");
        String findWord = clearXSS(Encoder.toJava(request.getParameter("findWord")), "");
        String method = clearXSS(request.getParameter("method"), "");

        if (method.equals("GET")) {
            findWord = clearXSS(request.getParameter("findWord"), "");
        }
        if(findWord != null){
            String[] filter_word= {"--", "\\(", "\\)", "\\'", "\\\""};
            for(int ii=0; ii< filter_word.length;ii++){
                findWord = findWord.replaceAll(filter_word[ii], "");
            }
        }
        String stDate = clearXSS(request.getParameter("stDate"),"");
        String edDate = clearXSS(request.getParameter("edDate"),"");


        MDept dpId =  pm.getObjectById(MDept.class, dpID);
        String dpNM = dpId.getRootDept(pm).getId();

        SimpleDateFormat dForomat = new SimpleDateFormat("yyyy-MM-dd");
        Calendar date = Calendar.getInstance();
        date.add(Calendar.MONTH, -12);
        Long prev_date = date.getTimeInMillis();
        Long now_today = new Date().getTime();
        if("".equals(stDate)) {
            stDate = dForomat.format(prev_date);
        }
        if("".equals(edDate)) {
            edDate = dForomat.format(now_today);
        }


        int wordLengthLimit = 50;

	/************ 리스트 페이지 구성 ************/
        int pageSize = 0;
        int currentPage = 0;
        int currentPageSetUp = 0;
        int recordSize = 15;

        currentPage = strPage;

        currentPageSetUp = (int) (currentPage / 10) * 10;
        if (currentPage % 10 == 0) {
            currentPageSetUp -= 10;
        }
		tx.begin();


        if (!"PRSS".equals(docType) && !"REG".equals(docType) && !"END".equals(docType)) {
            LOG.error("docType is not specified.");
        }

        //======================================================================
        TotDocService docService = new TotDocService(pm);
        //검색조건파라미터
        Map params = new HashMap();
        params.put("userId",        usID);
        params.put("deptId",        dpID);
        params.put("findOption",    findOption);
        params.put("filterValue",   findWord);
		if("END".equals(docType)) {
    		if(sysAuth == Moumi.SYSADM || sysAuth == Moumi.SUB_SYSADM || sysAuth == Moumi.SUB_TOTADM) {	//SUB_TOTADM:6 추가 by wonseok Lee 20171101
		        params.put("stDate",        stDate);
		        params.put("edDate",        edDate);
    		}
		}

        //검색메인쿼리와 레코드갯수조회쿼리를 생성 후 멤버변수로 저장
        docService.createDocListSearchQuery(params, docType);

        //레코드갯수조회쿼리를 실행하여 레코드갯수를 구함
        int count = docService.getCountFromMainQuery();

        if((count%recordSize) == 0){
                pageSize = (int)(count/recordSize);
        }else{
                pageSize = (int)(count/recordSize)+1;
        }

        if( currentPage > pageSize ) currentPage = pageSize;

        int startNo = (currentPage - 1) * recordSize + 1;
        int endNo = currentPage * recordSize;

        List list = null;

        //검색목록조회쿼리 실행
        if( count > 0 ) {
            //페이징처리를 위한 추가파라미터 설정
            docService.getParams().put("startNo", startNo);
            docService.getParams().put("endNo", endNo);

            //검색메인쿼리를 페이징처리를 위한 쿼리로 변환
            docService.convertToPagenatingQuery();

            //만족하는 레코드가 존재하면 조회
            list = docService.executeQuery(TotDocVO.class);
        }

        tx.rollback();
%>
<!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/SquareButtons.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/util.js"></script>
        <script src="/totsys/common/js/calendar.js"></script>
        <script src="/totsys/common/js/mouse.js"></script>
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>
        <script src="/totsys/common/js/jquery.custom.indicator.js"></script> <!-- 20160421 추가 -->
        <script>
        	var check;
			$(document).ready(function(){
				check = $("input:checkbox[name=check]");	
			});
			
            function isDateTrue(stDate, edDate) {
                if(stDate <= edDate) {
                        return true;
                }
                return false;
            }
            function fn_onFindSubmit(p_findForm) {
<% if(!"END".equals(docType)) { %>
                if( !findCheck(p_findForm) ) return false;
<% } %>
<% if("END".equals(docType)) { %>
                if( !isDateTrue(document.searchForm.stDate.value, document.searchForm.edDate.value) ) {
                    alert("<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.startEndDateCheck") %>");
                    document.searchForm.edDate.focus();
                    document.searchForm.edDate.select();
                    return false;
                }
<% } %>
                p_findForm.strPage.value = 1;
                return true;
            }

            /**
             * 페이지이동처리함수
             * @param {type} p_secu_yn
             * @returns {undefined}
             */
            function fn_goToPage(p_page) {
                document.searchForm.strPage.value = p_page;
                document.searchForm.submit();
            }


            /*
             * 현재페이지의 검색조건을 갖고 Relead하는 함수
             */
            function fn_reload() {
                document.searchForm.submit();
            }

            //부서공유지정(1), 부서공유취소(0)
            function openDocument(v) {
                var checkValue = 0;
                var docIDList = "";
                //var userIDList = "";
                var gubun = v;

                if (<%=count%> == 1 || <%=count%> == <%=((currentPage - 1) * recordSize) + 1%>) {
                    if (check.checked == true) {
                        if (docIDList.length == 0) {
                            if (typeof (checkDocID0) == 'undefined') {
                                docIDList += document.getElementById("checkDocID<%=((currentPage - 1) * recordSize)%>").value;

                            } else {
                                docIDList += document.getElementById("checkDocID0").value;
                            }
                        } else {
                            if (typeof (checkDocID0) == 'undefined') {
                                docIDList += "," + document.getElementById("checkDocID<%=((currentPage - 1) * recordSize)%>").value;
                            } else {
                                docIDList += "," + document.getElementById("checkDocID0").value;
                            }
                        }
                        checkValue++;
                    }
                } else if (<%=count%> != 0) {
                    tmp1 = eval(<%=((currentPage - 1) * recordSize)%>);
                    tmp2 = eval(<%=((currentPage - 1) * recordSize)%> + check.length);
                    tmp3 = 0;
                    for (i = tmp1; i < tmp2; i++) {
                        if (check[tmp3].checked == true) {
                            if (checkValue == 0) {
                                checkValue++;
                                //if(docIDList.length == 0 && userIDList.length == 0)
                                if (docIDList.length == 0)
                                    docIDList += document.getElementById("checkDocID" + i).value;
                                else
                                    docIDList += "," + document.getElementById("checkDocID" + i).value;
                                //userIDList +=","+ document.getElementById("userID"+i).value;
                            } else {
                                checkValue++;
                                if (docIDList.length == 0)
                                    docIDList += document.getElementById("checkDocID" + i).value;
                                else
                                    docIDList += "," + document.getElementById("checkDocID" + i).value;
                                //userIDList += ","+document.getElementById("userID"+i).value;
                            }
                        }
                        tmp3++;
                    }
                }

                var v_message = "";
                if( gubun == 1 ) {
                    v_message = "<%= MoumiConfig.getMessageBundle().getString("moumi.message.tot_report.approSet") %>";     //부서공유
                } else {
                    v_message = "<%= MoumiConfig.getMessageBundle().getString("moumi.message.tot_report.approCancel") %>";  //부서공유취소
                }

                if( checkValue <= 0 ) {
                    alert(v_message + "<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.docSelect") %>")   //하실 자료를 선택해주세요.
                    return;
                }

                if (confirm(checkValue + " <%= Moumi.getMessageBundle().getString("moumi.message.popup.docCounter")%>\n\n " + v_message + "를 실행 하시겠습니까?")) {   //개의 자료를 선택하였습니다.
                    document.approOpen.reportID.value = docIDList;
                    //document.approOpen.userID.value = userIDList;
                    document.approOpen.strGubun.value = gubun;
                    document.approOpen.submit();
                }
            }

            //서식삭제 버튼
            function docDelete() {
                var checkValue = 0;
                var docIDList = "";

                if (<%=count%> == 1 || <%=count%> == <%=((currentPage - 1) * recordSize) + 1%>) {
                    if (check.checked == true) {
                        if (docIDList.length == 0) {
                            if (typeof (checkDocID0) == 'undefined') {
                                docIDList += document.getElementById("checkDocID<%=((currentPage - 1) * recordSize)%>").value;
                            } else {
                                docIDList += document.getElementById("checkDocID0").value;
                            }
                        } else {
                            if (typeof (checkDocID0) == 'undefined') {
                                docIDList += "," + document.getElementById("checkDocID<%=((currentPage - 1) * recordSize)%>").value;
                            } else {
                                docIDList += "," + document.getElementById("checkDocID0").value;
                            }
                        }
                        checkValue++;
                    }
                } else if (<%=count%> != 0) {
                    tmp1 = eval(<%=((currentPage - 1) * recordSize)%>);
                    tmp2 = eval(<%=((currentPage - 1) * recordSize)%> + check.length);
                    tmp3 = 0;
                    for (i = tmp1; i < tmp2; i++) {
                        if (check[tmp3].checked == true) {
                            if (checkValue == 0) {
                                checkValue++;
                                if (docIDList.length == 0)
                                    docIDList += document.getElementById("checkDocID" + i).value;
                                else
                                    docIDList += "," + document.getElementById("checkDocID" + i).value;

                            } else {
                                checkValue++;
                                if (docIDList.length == 0)
                                    docIDList += document.getElementById("checkDocID" + i).value;
                                else
                                    docIDList += "," + document.getElementById("checkDocID" + i).value;
                            }
                        }
                        tmp3++;
                    }
                }

                if (checkValue > 0) {
                    if (confirm(checkValue + " <%= Moumi.getMessageBundle().getString("moumi.message.popup.docCounter")%>\n\n<%=Moumi.getMessageBundle().getString("moumi.message.popup.docDelete")%>")) {
                        document.Del.docID.value = docIDList;
                        document.Del.submit();
                    }
                } else {
                    alert("<%= Moumi.getMessageBundle().getString("moumi.message.popup.docDeleteSelect")%>");
                }
            }

            /*
             * 2014.08.28 Add by KWON,HAN : 사용자공유
             */
            function userShareSelect(sGubun, sReportID) {
                var $checked;
                var v_checkedCount;
                var reportID = new Array();

                if (sGubun === "check") {
                    $checked = $("input:checkbox[name=check]:checked");
                    v_checkedCount = $checked.length;

                    if (v_checkedCount === 0) {
                        alert('<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.user")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.share")%>' + ' ' + '<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.docSelect")%>');
                        return;
                    }

                    var val = '';
                    var usersharecount = 0;

                    for (var i = 0; i < v_checkedCount; i++) {
                        val = $checked[i].value;

                        usersharecount = document.getElementById("su" + val).value;
                        if (usersharecount > 0) {
                            //명의 사용자에게 공유되어 있습니다.
                            alert("이미 " + usersharecount + '<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.userShareCounter") %>' + "\n\n사용자 공유란의 공유된 사용자수를 클릭하여 수정하십시요. " );
                            return;
                        }
                    }

                    $checked.each(function() {
                        reportID.push($(this).val());
                    });
                } else if (sGubun === "select") {
                    reportID = sReportID;
                } else {
                    //[정상적인 접근방법으로 처리해주십시요]!
                    alert('<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.normalHandle")%>');
                    return;
                }

                var urlname = "";
                var height = screen.height;
                var width = screen.width;
                var leftpos = width / 2 - 350;
                var toppos = height / 2 - 350;

                //docReportType:문서 구분(D:집계문서, R:제출문서)
                urlname = "/totsys/common/web/report_dept/popup_user_share_select.jsp?docID=" + reportID + "&docReportType=D&userYN=Y&selfDeptYn=N&exeFlag=list";
                post = window.open(urlname, "post", "width=900, height=600, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + leftpos + ",top=" + toppos);
                post.focus();
            }

            function changeDam() {
                nnn = $("input:checkbox[name=check]:checked").length;
                if (nnn == 0) {
                    alert("선택을하신후 담당변경 버튼을 클릭하세요.");
                    return;
                }

                var res = new Array();
                $("input:checkbox[name=check]:checked").each(function() {
                    res.push($(this).val());
                });
                var height = screen.height;
                var width = screen.width;
                var leftpos = width / 2 - 350;
                var toppos = height / 2 - 350;
                frm = document.damdangForm;
                frm.docID.value = res;
                //2014.09.15 Update by KWON,HAN : 담당변경의 멀티선택 처리가 가능하도록 변경함.
                //frm.action="/totsys/repoper/mydocbox/returnbox/popup_rep_transfer4.jsp";
                frm.action = "/totsys/repoper/mydocbox/returnbox/popup_rep_transfer6.jsp";
                frm.target = 'damdangForm';
                frm.method = 'post';
                //2014.09.15 Update by KWON,HAN
                //win= window.open('',"damdangForm","width=607, height=541, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + leftpos + ",top=" + toppos);
                win = window.open('', "damdangForm", "width=572, height=680, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + leftpos + ",top=" + toppos);
                win.focus();
                frm.submit();
            }

            /**
             *체크박스 전체선택 해제 스크립트 추가
             **/
            function checkALL(checkYn) {
                frm = document.approOpen;
                var checklist = document.getElementsByName("check");
                if (checklist.length > 0) {
                    for (var i = 0; i < checklist.length; i++) {
                        checklist[i].checked = checkYn;
                    }
                }
            }

            /*
            * 상세보기페이지로 이동처리하는 함수
            * @param {type} p_docID
            * @param {type} p_deptID
            * @returns {undefined}
            */
           function fn_goToViewReport(p_docID, p_deptID) {
               document.viewFormReport.docID.value = p_docID;
               document.viewFormReport.deptID.value = p_deptID;
               document.viewFormReport.submit();
           }

           function fn_goToViewTotal(p_docID, p_deptID) {
        	   //미진행자료일경우 기본정보 페이지로 가게
        	   if('<%=docType%>'=='REG'){
        		   document.viewFormTotal.action='/totsys/totper/mydocbox/prssbox/doc_modify.jsp';
        	   }
               document.viewFormTotal.docID.value = p_docID;
               document.viewFormTotal.deptID.value = p_deptID;
               document.viewFormTotal.submit();
           }

            //calendar.js 에서 날짜를 선택하면 실행되는 콜백함수
            function fn_CalSetValue(obj, value) {
                if( !isDateTrue(document.searchForm.stDate.value, document.searchForm.edDate.value) ) {
                    alert("<%= MoumiConfig.getMessageBundle().getString("moumi.message.popup.startEndDateCheck") %>");
                    document.searchForm.edDate.focus();
                    document.searchForm.edDate.select();
                    return false;
                }

                fn_onFindSubmit(document.searchForm);
                document.searchForm.submit();
            }

            //20160415 시도 DB IR 테이블의 교육부 자료 조회후 시도 DB 업무 테이블에 INSERT
            function fn_irDataSave(){
                <%if( "REG".equals(docType)){%>
                    try {
                       $.customIndicator.show(window.self);
                    } catch(e) {
                       alert(e);
                    }
                    var form1 = document.irDataForm;
                    form1.target = "hiddenIframe";
                    form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.CheckIRTable";
                    form1.submit();
                    //alert("교육부에서 요청한 자료가 없습니다.");
                    //return;
                <%}%>
             }

            function fn_irDataSaveExe(){
                if( confirm("시도DB 연계 테이블의 교육부 자료 조회후 시도DB 업무 테이블에\r저장하시겠습니까?") ){
                    try {
                        $.customIndicator.show(window.self);// 20160421 loading indicator 추가
                    } catch(e) {
                        alert(e);
                    }
                    document.irDataForm.target = "hiddenIframe";
                    document.irDataForm.action = "./irData_insert.jsp";
                    document.irDataForm.submit();
                }//end if
                }

            //20160415 추가
            function fn_indiClose(){
                $.customIndicator.hide(window.self);
                this.location.reload();
            }
        </script>
    </head>
    <body>

<form name="viewFormReport" method="post" action="./reports/report_list.jsp">
    <input type="hidden" name="docID" value="">
    <input type="hidden" name="deptID" value="">
    <input type="hidden" name="docType" value="<%= docType %>">
    <input type="hidden" name="strPage" value="<%= strPage %>">
    <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
    <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
    <input type="hidden" name="stDate" value="<%=stDate%>">
    <input type="hidden" name="edDate" value="<%=edDate%>">
</form>
<form name="viewFormTotal" method="post" action="./tot_reports/total_reports.jsp">
    <input type="hidden" name="docID" value="">
    <input type="hidden" name="deptID" value="">
    <input type="hidden" name="docType" value="<%= docType %>">
    <input type="hidden" name="strPage" value="<%= strPage %>">
    <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
    <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
    <input type="hidden" name="stDate" value="<%=stDate%>">
    <input type="hidden" name="edDate" value="<%=edDate%>">
</form>


        <form name="damdangForm" method="post" >
            <input type="hidden" name="reportID" value="">
            <input type="hidden" name="docID" value="">
            <input type="hidden" name="boxName" value="returnbox">
            <input type="hidden" name="hideUser" value="false">
            <input type="hidden" name="docReportType" value="D">
            <input type="hidden" name="exeFlag" value="list">
            <input type="hidden" name="docType" value="<%=docType%>">
            <input type="hidden" name="strPage" value="<%= currentPage %>">
            <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
            <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
            <input type="hidden" name="stDate" value="<%=stDate%>">
            <input type="hidden" name="edDate" value="<%=edDate%>">
        </form>
        <FORM name="approOpen" action="/servlet/kr.co.kihyun.beans.user.HttpApproSet" method="post">
            <input type="hidden" name="reportID" value="">
            <input type="hidden" name="docType" value="<%=docType%>">
            <input type="hidden" name="userID">
            <input type="hidden" name="strGubun">
            <input type="hidden" name="strPage" value="<%= currentPage %>">
            <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
            <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
            <input type="hidden" name="stDate" value="<%=stDate%>">
            <input type="hidden" name="edDate" value="<%=edDate%>">
        </FORM>

        <!-- 20160415 교육부 IR 자료 조회후 저장 관련 추가 시작-->
        <form name="irDataForm" method="post" action="./irData_insert.jsp">
            <input type="hidden" name="docType" value="<%=docType%>">
            <input type="hidden" name="strPage" value="<%= currentPage %>">
            <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
            <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
            <input type="hidden" name="stDate" value="<%=stDate%>">
            <input type="hidden" name="edDate" value="<%=edDate%>">
        </form>
        <iframe  title="hiddenIframe" name="hiddenIframe" width="0" height="0" src="about:blank" style="display: none;"></iframe>
        <!-- 20160415 교육부 IR 자료 조회후 저장 관련  추가 끝-->

        <table>
            <jsp:include page="/totsys/common/inc/totper/top/top.jsp" flush="true" />
            <tr>
                <td></td>
                <td>
                    <table>
                        <jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />

                        <!-- // Begin : 검색 & 버튼영역 -->
                        <tr class="toolbar">
                            <td>
                                <table>
                                    <tr>
                                        <!--// 검색 시작 -->
                                        <td>
                                            <form name="searchForm" method="post" action="./doc_list.jsp" onsubmit="return fn_onFindSubmit(this);" style="margin: 0px">
         <% if ("END".equals(docType)) { %>
                    <%if(sysAuth == Moumi.SYSADM || sysAuth == Moumi.SUB_SYSADM  || sysAuth == Moumi.SUB_TOTADM){%>
                                                <span style="width: 640px;">
                    <% } else { %>
                                                <span style="width: 340px;">
                    <% } %>
        <% } else { %>
                                                <span style="width: 340px;">
        <% } %>
                                                    <input type="hidden" name="strPage" value="<%= currentPage %>">
                                                    <input type="hidden" name="accAuth">
                                                    <select id="findOption" name="findOption" class="inputtxt" onchange="showMSG(this.options[this.selectedIndex].value, msg)">
                                                        <option value="name"<%= "name".equals(findOption) ? " selected" : ""%>><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.doc")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.name")%></option>
                                                        <option value="executionCode"<%= "executionCode".equals(findOption) ? " selected" : ""%>><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.executionCode")%></option>
                                                        <option value="totDoc.mUser.name"<%= "totDoc.mUser.name".equals(findOption) ? " selected" : ""%>>요청자</option>
                                                    </select>
                                                    <label for="findOption" class="blind">검색옵션</label>
                                                    <input id="findWord" name="findWord" value="<%=MString.checkNull(findWord)%>" type="text" class="inputtxt" size="30" maxlength="30" style="ime-mode: active;" />
                                                    <label for="findWord" class="blind">검색창</label>
                                                    <input name="docType" value="<%=MString.checkNull(docType)%>" type="hidden" />
                                                    <input alt="검색" type="image"  src="/totsys/common/images/bt_search_inquiry2.gif" />

                <% if ("END".equals(docType)) { %>
                    <%if(sysAuth == Moumi.SYSADM || sysAuth == Moumi.SUB_SYSADM || sysAuth == Moumi.SUB_TOTADM){%>
                                            &nbsp;&nbsp;
                                            <label for="" style="vertical-align: middle;">
                                                <strong>시작일</strong>
                                            </label>
                                            &nbsp;
                                            <!--// 검색 시작일 -->
                                            <input name="stDate" type="text" size="10" value="<%=stDate%>" onclick="showSetWin('searchForm.stDate');" style="cursor: pointer;  vertical-align: middle;" class="inputtxt">
                                            <a href="#" onclick="showSetWin('searchForm.stDate');">
                                                <img alt="글머리" src="/totsys/common/images/date.gif" align="middle">
                                            </a><!-- 검색 시작일 //-->
                                            ~
                                            <!--// 검색 종료일 -->
                                            <input name="edDate" type="text" size="10" value="<%=edDate%>" readonly onclick="showSetWin('searchForm.edDate');" style="cursor: pointer;  vertical-align: middle;" class="inputtxt">
                                            <a href="#" onclick="showSetWin('searchForm.edDate');">
                                                <img alt="달력" src="/totsys/common/images/date.gif" align="middle">
                                            </a><!-- 검색 종료일 //-->
                    <% } %>
                <% } %>
                                                </span>
                                            <!-- 20160415 교육부 자료 조회 버튼 추가 시작-->
                                            <% if( "REQ".equals(docType)){ %>
                                                <a href="#" onclick="javascript:fn_irDataSave();">
                                                 <img alt="교육부 자료조회" src="/totsys/common/images/bt_receiveMoe.GIF" alt="연계 자료를 조회한 후 업무 DB에 적용" />
                                                </a>
                                            <%}%>
                                            <!-- 20160415 교육부 자료 조회 버튼 추가 끝-->
                                            </form>
                                        </td><!-- 검색 끝 //-->
                                        <td>
                                            <span id="msg" class="kecttep_date_search" style='display: none; width: 210px'>&nbsp;&nbsp;&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.daySearchForm")%></span>
                                        </td>
                                        <%
                                            if (!"PRSS".equals(docType)) {
                                        %>
                                        <td class="kecttep_button_td tar">
                                            <!-- 부서공유지정 -->
                                            <a href="javascript:openDocument(1);">
                                                <img src="/totsys/common/images/bt_deptselect.jpg" alt="<%=Moumi.getMessageBundle().getString("moumi.message.tot_report.approSet")%>" />
                                            </a>
                                            <!-- 부서공유취소 -->
                                            <a href="javascript:openDocument(0);">
                                                <img src="/totsys/common/images/bt_deptcancel.jpg" alt="<%=Moumi.getMessageBundle().getString("moumi.message.tot_report.approCancel")%>" />
                                            </a>

                                            <%
                                                // 종료자료인 경우
                                                if (docType.equals("END")) {
                                            %>
                                            <!-- 2014.08.28 Add by KWON,HAN : 사용자공유 -->
                                            <a href="javascript:userShareSelect('check','');" >
                                                <img src="/totsys/common/images/bt_user_share.jpg" alt='<%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.user")%><%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.share")%>' />
                                            </a>
                                            <!-- --------------- -->

                                            <!-- 담당변경 -->
                                            <a href="javascript:changeDam();" >
                                                <img src="/totsys/common/images/bt_damdang.gif" alt="<%=Moumi.getMessageBundle().getString("moumi.message.button.trans")%>" />
                                            </a>
                                            <%
                                                }
                                            %>

                                            <!-- 서식삭제 -->
                                            <a href="javascript:docDelete();">
                                                <img src="/totsys/common/images/bt_formdel.gif" alt="<%=Moumi.getMessageBundle().getString("moumi.message.button_small.formRemove")%>" />
                                            </a>
                                        </td>

                                        <%
                                            }
                                        %>
                                    </tr>
                                </table>
                            </td>
                        </tr><!-- // End : 검색 & 버튼영역 -->
                        <tr>
                            <td><!--  내용 -->
                                <table border="1px" class="kecttep_list_table">
                                    <tr valign="middle" style="padding-top: 3">
                                        <%if (!"PRSS".equals(docType)) {%>
                                        <td align="center" class="kecttep_tdmenu" width="35">
                                            <input type="checkbox" name="check0" onclick="javascript:checkALL(this.checked)"/>
                                        </td>
                                        <%}%>
                                        <td width="65"  align="center"  class="kecttep_tdmenu" ><%=Moumi.getMessageBundle().getString("moumi.message.tot_report.section")%></td>
                                        <td width="135" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.executionCode")%></td>
                                        <td width="*" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.doc")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.name")%></td>
                                        <td width="110" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.request")%><%=Moumi.getMessageBundle().getString("moumi.message.totsys.sysadm.part.part_list_jsp")%></td>
                                        <td width="97" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.request")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.person")%></td>
                                        <td width="100" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.startDate")%></td>
                                        <td width="135" align="center"  class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.endDate")%></td>
                                        <td width="125" align="center"  class="kecttep_tdmenu"><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_report.compSnd")%>/<%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.all")%>(<%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.noteRecall")%>)</td>
                                        <td width="100" align="center"  class="kecttep_tdmenu" ><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.remark")%></td>
                                        <!-- 2014.08.29 Add by KWON,HAN -->
                                        <td width="70" align="center"  class="kecttep_last_tdmenu">
                                            <%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.user")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.share")%>
                                        </td>
                                    </tr>
                                    <%

                                        int index = 0;     //배열에서 값을 꺼내오는 키값
                                        int nextCount = 0; //

                                        if (currentPage > 1) {
                                            nextCount = ((currentPage - 1) * recordSize);
                                        }

                                    if( count > 0 ) {
                                        int listCount = list.size();

                                        for(int i = 0; i < listCount; i++){
                                            index = nextCount + i;
                                            TotDocVO docVO = (TotDocVO)list.get(i);
                                    %>
                                    <tr style="padding-top: 3" valign="middle">
                                        <%
                                            if (!"PRSS".equals(docType)) {
                                        %>
                                        <td  class="kecttep_graytd" height="25" align="center" width="35">
                                            <input type="checkbox" name="check" id="checkBox" value=<%=docVO.getId()%> <%if (docVO.getUserId() != null && !docVO.getUserId().equals(usID) && sysAuth == Moumi.TOTPER) {%>disabled<%}%> />
                                            <!-- ie10,11 호환성 에러 id 값 추가 -->
                                            <input type="hidden"  id="checkDocID<%=index%>" name="checkDocID<%=index%>" value="<%=docVO.getId()%>" />
                                            <input type="hidden" id="su<%=docVO.getId()%>" name="shareUserCount<%=index%>" value="<%=docVO.getShareUserCount()%>">
                                        </td>
                                        <%
                                            }
                                        %>
                                        <!-- 구분 -->
                                        <td width="65" align="center" class="kecttep_graytd" >
                                         	<%-- =docVO.getId()%> --%>
                                            <%
                                            if (docVO.isPeriodicalDoc() && docVO.isDocCollection()) {%>
                                            <span class="kecttep_doc_append_type kecttep_doc_append_type_periodical_collection"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.create.periodical") + "/" + Moumi.getMessageBundle().getString("moumi.message.tot_doc.collection")%></span>  <!-- 정기/취합 -->
                                            <%} else if (docVO.isPeriodicalDoc() && !docVO.isDocCollection()) { %>
                                            <span class="kecttep_doc_append_type kecttep_doc_append_type_periodical_file"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.create.periodical") + "/" + Moumi.getMessageBundle().getString("moumi.message.tot_doc.file")%></span>  <!-- 정기/파일 -->
                                            <%} else if (!docVO.isPeriodicalDoc() && docVO.isDocCollection()) { %>
                                            <span class="kecttep_doc_append_type kecttep_doc_append_type_random_collection"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.create.random") + "/" + Moumi.getMessageBundle().getString("moumi.message.tot_doc.collection")%></span>   <!-- 수시/취합 -->
                                            <%} else if (!docVO.isPeriodicalDoc() && !docVO.isDocCollection()) { %>
                                            <span class="kecttep_doc_append_type kecttep_doc_append_type_random_file"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.create.random") + "/" + Moumi.getMessageBundle().getString("moumi.message.tot_doc.file")%></span>   <!-- 수시/파일 -->
                                            <%}%>
                                        </td>
                                        <!-- 시행번호 -->
                                        <td width="135" align="center"  class="kecttep_graytd"><%= docVO.getExecCode()%>&nbsp;</td>
                                        <!-- 자료명 -->
                                        <td width="*" id="div_name"  class="kecttep_graytd">
                                            <%--
                                                if ("PRSS".equals(docType)) {
                                            --%>
                                            &nbsp;&nbsp;<a onmouseover="balloon_on('<%= MString.getEllipsis(docVO.getName(), wordLengthLimit)%>', this, 10, 4)"  onmouseout="balloon_off()"
                                                           href="javascript:fn_goToViewReport('<%=docVO.getId()%>', '<%=docVO.getDeptId()%>');">
                                                          <%= MString.getEllipsis(docVO.getName(), wordLengthLimit)%></a>


                                            <%--
                                            } else {
                                            %>
                                            &nbsp;&nbsp;<a onmouseover="balloon_on('<%= MString.getEllipsis(docVO.getName(), wordLengthLimit)%>', this, 10, 4)"  onmouseout="balloon_off()"
                                                      href="javascript:fn_goToViewTotal('<%=docVO.getId()%>', '<%=docVO.getDeptId()%>');">
                                                      <%= MString.getEllipsis(docVO.getName(), wordLengthLimit)%></a>
                                            <%
                                                }
                                            --%>
                                        </td>
                                        <!-- 요청기관  -->
                                        <td width="110" align="center"  class="kecttep_graytd"><%= MString.checkNull(docVO.getDeptName())%>&nbsp;</td>
                                        <!-- 요청자  -->
                                        <td width="97" align="center"  class="kecttep_graytd"><%= docVO.getOwnerName()%></td>
                                        <!-- 시작일  -->
                                        <td width="100" align="center"  class="kecttep_graytd"><%= docType.equals("REG") ? new SimpleDateFormat("yyyy-MM-dd HH:mm").format(docVO.getStartDate()) : new SimpleDateFormat("yyyy-MM-dd").format(docVO.getStartDate())%></td>
                                        <td width="135" align="center"  class="kecttep_graytd"
                                            <%
                                                String tmpMoumiAcptLimitStrategy = Integer.toString(docVO.getSubmitLimitCnt());
                                                String tmp2 = null;
                                                String tstr = "시";
                                                String tcnt;
                                                tcnt = "(" + Integer.toString(docVO.getSubmitLimitCnt()) + "개 기관)";
                                                if (tmpMoumiAcptLimitStrategy.equals("0")) {
                                                    tmp2 = new SimpleDateFormat("yyyy-MM-dd HH").format(docVO.getEndDate());
                                                    tcnt = "";
                                                } else {
                                                    tmp2 = Moumi.getMessageBundle().getString("moumi.message.tot_doc.endBySubmitTotal");
                                                    tstr = "";
                                                }
                                                if (tmp2.contains("9999-12-30")) {
                                                    tmp2 = Moumi.getMessageBundle().getString("moumi.message.tot_doc.docGethering");
                                                }
                                                if (tmp2.equals(Moumi.getMessageBundle().getString("moumi.message.tot_doc.docGethering"))) {
                                                    tstr = "";
                                                }
                                            %>>
                                            <%
                                                out.write(tmp2 + tstr + tcnt);
                                            %>
                                        </td>
                                        <td  width="125" align="center"  class="kecttep_graytd">
                                            <%
                                              //String tmpAllcnt = Long.toString(docVO.getAllCnt());
                                              //String tmpSndcnt = Long.toString(docVO.getSndCnt());
                                              //String tmpNotCcnt = Long.toString(docVO.getNoteCnt());
                                              //out.write(tmpAllcnt + "/" + tmpSndcnt + "(" + tmpNotCcnt + ")");

                                              out.write(docVO.getSndCnt() + "/" + docVO.getAllCnt() + "(" + docVO.getNoteCnt() + ")");
                                            %>
                                        </td>
                                        <td width="100"  class="kecttep_graytd" align="center">
                                            <span style="padding-left:inherit">
                                                <%if (docVO.getRepId() != null && docVO.getRepId() != 0) {
                                                        out.print(Moumi.getMessageBundle().getString("moumi.message.tot_doc.subDoc")); //연계등록자료 표시
                                                    }%>&nbsp;
                                            </span>
                                        </td>
                                        <!-- 2014.08.29 Add by KWON,HAN -->
                                        <td width="70" align="center"  valign="middle"  class="kecttep_last_graytd">
                                            <%if (docVO.getShareUserCount() > 0) {
                                            %>
                                            <%if (docVO.getShareDocRegId() != null && usID.equals(docVO.getShareDocRegId())) {%>
                                            <a href="javascript:userShareSelect('select','<%= docVO.getId()%>');">
                                                <%}%>
                                                <%=docVO.getShareUserCount()%><%=Moumi.getMessageBundle().getString("moumi.message.doc.Name")%>
                                                <%if (usID.equals(docVO.getShareDocRegId())) {%>
                                            </a>
                                            <%}%>
                                            <%
                                            } else {%>
                                            &nbsp;
                                            <%}%>
                                        </td>
                                        <!-- -------------- -->
                                    </tr>
                                    <%
                                        }       //end of for list
                                    }       //end of if( count > 0)
                                        //tx.rollback();
                                    %>
                                    <!--  내용 끝 -->
                                </table>
                            </td>
                        </tr>

                        <tr>
                            <td></td>
                        </tr>
                        <%if (count > 0) {%>
                        <tr style="padding-top: 3" valign="middle">
                            <td colspan="8" class="kecttep_board">
                                <!----------------- 페이지수 나오는 부분 시작 ----------------->
                                <%--
                                <jsp:include page="/totsys/common/inc/board/page.jsp" flush="true">
                                    <jsp:param name="uri" value="<%= uri%>" />
                                    <jsp:param name="pageSize" value="<%= pageSize%>" />
                                    <jsp:param name="currentPage" value="<%= currentPage%>" />
                                    <jsp:param name="currentPageSetUp" value="<%= currentPageSetUp%>" />
                                    <jsp:param name="findWord" value='<%=URLEncoder.encode(MString.checkNull(findWord), "UTF-8")%>' />
                                </jsp:include>
                            --%>
                                    <jsp:include page="/totsys/common/inc/board/page_module.jsp" flush="true">
                                        <jsp:param name="pageFunction" value="fn_goToPage" />
                                        <jsp:param name="pageSize" value="<%= pageSize %>" />
                                        <jsp:param name="currentPage" value="<%= currentPage %>" />
                                        <jsp:param name="currentPageSetUp" value="<%= currentPageSetUp %>" />
                                     </jsp:include>
                                <!----------------- 페이지수 나오는 부분 끝 ---------------->
                            </td>
                        </tr>
                        <%} else {%>
                        <tr>
                            <td class="kecttep_none_tdmenu" colspan="14" height="25" align="center"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.notDoc")%></td>
                            <%}%>
                        </tr>
                        <input type="hidden" id="tmpFind" name="tmpFind" value="<%=MString.checkNull(findOption)%>">
                        <FORM name="Del" action="/servlet/kr.co.kihyun.beans.totsys.totper.HttpDocDel" method="post">
                            <INPUT type="hidden" name="docID" value="">
                            <INPUT type="hidden" name="url" value="endDoc">
                            <INPUT type="hidden" name="docType" value="<%= docType%>">
                            <input type="hidden" name="strPage" value="<%= currentPage %>">
                            <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
                            <input type="hidden" name="findWord" value="<%=MString.checkNull(findWord)%>">
                            <input type="hidden" name="stDate" value="<%=stDate%>">
                            <input type="hidden" name="edDate" value="<%=edDate%>">
                        </FORM>
                        <script>
                            if (tmpFind.value == "name") {
                                searchForm.findOption.selectedIndex = 0;
                            //} else if (tmpFind.value == "startDate") {
                            //    searchForm.findOption.selectedIndex = 1;
                            //} else if (tmpFind.value == "endDate") {
                            //    searchForm.findOption.selectedIndex = 2;
                            } else if (tmpFind.value == "totDoc.mUser.name") {
                                searchForm.findOption.selectedIndex = 2;
                            }
                        </script>
                    </table>
                </td>
                <td></td>
            </tr>
            <!----------------- top menu start ----------------->
            <%@ include file="/totsys/common/inc/buttom/buttom.jsp"%>
            <!----------------- top menu end ----------------->
        </table>
<div id="SetWin" style="position: absolute; z-index: 10; visibility: hidden; width: 100px; background: silver; border: 1px #333333 solid; line-height: 1.4em; padding: 3px 3px; v"></div>
    </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();
    }
%>

