<%@page import="java.util.Enumeration"%>
<%@page import="kr.co.kihyun.db.CommonDBManager"%>
<%@page import="java.util.Arrays"%>
<%@page import="com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="kr.co.kihyun.db.DBManager"%>
<%  /**
     * **********************************************************
     * @@ Program Name : total_reports.jsp
     * @@ Description : /집계자/내문서함/진행함/집계현황
     * @@ Author : 강원중
     * @@ Create Date : 2004.10.11
     * @@ History : 2014.10.07 Update by KWON,HAN :
     * @@***********************************************************
     */
%>
<%@ page contentType="text/html; charset=UTF-8"
         import="java.text.SimpleDateFormat"
         import="java.util.List"
         import="java.util.ArrayList"
         import="java.util.Map"
         import="java.util.HashMap"
         import="java.net.URLEncoder"
         import="java.net.URLDecoder"
         import="kr.co.kihyun.lang.MString"
         import="kr.co.kihyun.lang.MLong"
         import="kr.co.kihyun.lang.MInteger"
         import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.text.html.TagFilter"
         import="kr.co.kihyun.beans.user.HttpSSOLogin"
         import="kr.co.kihyun.moumi.doc.MDoc"
         import="kr.co.kihyun.moumi.report.MReport"
         import="kr.co.kihyun.moumi.Moumi"
         import="kr.co.kihyun.moumi.MoumiConfig"
         import="javax.jdo.PersistenceManager"
         import="javax.jdo.Transaction"
         import="kr.co.kihyun.beans.entity.util.*"
         import="kr.co.kihyun.beans.entity.*"
         import="kr.co.kihyun.beans.totsys.doc.table.Table"
         import="kr.co.kihyun.beans.totsys.doc.table.item.Item"
         import="kr.co.kihyun.beans.entity.TotDoc2"
         import="kr.co.kihyun.beans.entity.MDept"
         import="kr.co.kihyun.service.PrssReportsService"
         import="kr.co.kihyun.service.vo.PrssReportsVO"
         import="kr.co.kihyun.service.vo.ReportTotalVO"
         import="javax.jdo.Query"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%
//레이지로딩 플래그
boolean reqlist=false;
if(request.getParameter("reqlist")!=null){
	try{
		reqlist=Boolean.parseBoolean(request.getParameter("reqlist"));
	}catch(Exception e){}
}
    PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
    Transaction tx = pm.currentTransaction();

    try {

        String usID = HttpSSOLogin.getLoginID(request);
        int sysAuth = HttpSSOLogin.getSysAuth(request);
        String dpID = HttpSSOLogin.getDeptID(request);
//        String dpNM = HttpSSOLogin.getDeptName(request);//20160421 추가 - 부서명

        /**
         * **** Parameter *****
         */
        Long docID = MLong.parseLong(request.getParameter("docID"), null);
//        int tableNum = MInteger.parseInt(request.getParameter("tableNum"), 0); //전체내용이 우선적으로 보여지도록 할 때 적용
        int tableNum = MInteger.parseInt(request.getParameter("tableNum"), 1);  //1번표가 우선적으로 보여지도록 할 때 적용
        String docType = clearXSS(request.getParameter("docType"), null);
        Long reportID = MLong.parseLong(request.getParameter("reportID"));

        int searchType = MInteger.parseInt(request.getParameter("searchType"), -1);
        String prssSelected = request.getParameter("prssSelect");
        boolean prssSelect = prssSelected != null;
//        System.out.println(" -------------- " + prssSelect);
        String[] displaySummaryValues = request.getParameterValues("displaySummary");
        boolean displaySummary = displaySummaryValues != null;
        int gradeCode = MInteger.parseInt(request.getParameter("gradeCode"), -1);
        String type = clearXSS(request.getParameter("type"), "");
        int rowDelType = MInteger.parseInt(request.getParameter("rowDelType"), 0);
        String tableval = clearXSS(request.getParameter("tableval"), "0");


        String strPage = clearXSS(request.getParameter("strPage"), "");
        String findOption = clearXSS(request.getParameter("findOption"), "");
        String findWord = URLDecoder.decode(MString.checkNull(request.getParameter("findWord")), "UTF-8");
        String stDate = clearXSS(request.getParameter("stDate"), "");
        String edDate = clearXSS(request.getParameter("edDate"), "");



        String searchDepth = clearXSS(request.getParameter("searchDepth"), "");
        String innerStrPage = "";
        String innerFindOption = "";
        String innerFindWord = "";

        if ("inner".equals(searchDepth)) {
            innerStrPage = clearXSS(request.getParameter("innerStrPage"), "");
            innerFindOption = clearXSS(request.getParameter("innerFindOption"), "");
            innerFindWord = URLDecoder.decode(MString.checkNull(request.getParameter("innerFindWord")), "UTF-8");
        } else {
            innerStrPage = clearXSS(request.getParameter("innerStrPage"), "");
            innerFindOption = clearXSS(request.getParameter("innerFindOption"), "");
            //검색어 깨어짐 해결
            innerFindWord = URLDecoder.decode(MString.checkNull(request.getParameter("innerFindWord")), "UTF-8");
        }
        String sort = clearXSS(request.getParameter("sort"), "");
        int listType = searchType;
        String howSort = clearXSS(request.getParameter("howSort"), "");

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

        String mngcode = clearXSS(request.getParameter("mngcode"), "");//20160509 추가
        if( "PRSS".equals(docType) && dpID.contains("A00") && docID > 1700000000){
        mngcode = "".equals(mngcode) ? "": mngcode ;//20160509 추가
        }
        tx.begin();

        TotDoc totDoc = pm.getObjectById(TotDoc.class, docID);
        String userId = totDoc.getUser();
        AccessAuth docAccAuth = totDoc.getAccessAuth();
        String docName = totDoc.getName();
        String regID = totDoc.getUser(pm).getId();
        String deptID = totDoc.getDept(pm).getId();

        //======================================================================
        int count = 0;

        PrssReportsService prssService = new PrssReportsService(pm);
        //검색조건파라미터
        Map params = new HashMap();
        params.put("docId", docID);
        params.put("listType", listType);
        params.put("findOption", innerFindOption);
        params.put("filterValue", innerFindWord);
        params.put("howSort", howSort);
        params.put("sort", sort);

        params.put("mngcode", mngcode);//20160509 추가 교육청 코드
        params.put("dpId", dpID);//20160509 추가 교육청 코드
//        System.out.println("params ------------- " + params);

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

        List<PrssReportsVO> list = null;
//System.out.println(prssService.getSearchQuery());
        //만족하는 레코드가 존재하면 조회
        list = prssService.executeQuery(PrssReportsVO.class);


        count = list.size();
        //======================================================================

        List<TotReport> compReportList = null;  //전체
        List<TotReport> organReportList = null; //기관
        List<TotReport> gradeReportList1 = null; //학교
        List<TotReport> gradeReportList2 = null; //학교
        List<TotReport> gradeReportList3 = null; //학교
        List<TotReport> gradeReportList4 = null; //학교
        List<TotReport> gradeReportList5 = null; //학교

        int allReportCount = 0;          //전체-전체
        int organReportCount_all = 0;    //기관-전체
        int gradeReport1Count_all = 0;   //유치원-전체
        int gradeReport2Count_all = 0;   //초등학교-전체
        int gradeReport3Count_all = 0;   //중학교-전체
        int gradeReport4Count_all = 0;   //고등학교-전체
        int gradeReport5Count_all = 0;   //기타학교-전체

        int totReportCount = 0;          //전체-제출완료
        int organReportCount = 0;        //기관-제출완료
        int gradeReport1Count = 0;       //유치원-제출완료
        int gradeReport2Count = 0;       //초등학교-제출완료
        int gradeReport3Count = 0;       //중학교-제출완료
        int gradeReport4Count = 0;       //고등학교-제출완료
        int gradeReport5Count = 0;       //기타학교-제출완료

        if (displaySummary) {
            List totalList = null;
            totalList = prssService.getReportTotalByDocId(docID);

            if (totalList != null && totalList.size() > 0) {
                for (Object obj : totalList) {
                    ReportTotalVO totalVO = (ReportTotalVO) obj;

                    allReportCount = MInteger.parseInt(totalVO.getAllCnt().toString(), 0);
                    organReportCount_all = MInteger.parseInt(totalVO.getAllOrganCnt().toString(), 0);
                    gradeReport1Count_all = MInteger.parseInt(totalVO.getAllGrade1Cnt().toString(), 0);
                    gradeReport2Count_all = MInteger.parseInt(totalVO.getAllGrade2Cnt().toString(), 0);
                    gradeReport3Count_all = MInteger.parseInt(totalVO.getAllGrade3Cnt().toString(), 0);
                    gradeReport4Count_all = MInteger.parseInt(totalVO.getAllGrade4Cnt().toString(), 0);
                    gradeReport5Count_all = MInteger.parseInt(totalVO.getAllGrade5Cnt().toString(), 0);

                    totReportCount = MInteger.parseInt(totalVO.getTotReportCnt().toString(), 0);
                    organReportCount = MInteger.parseInt(totalVO.getOrganReportCnt().toString(), 0);
                    gradeReport1Count = MInteger.parseInt(totalVO.getGrade1ReportCnt().toString(), 0);
                    gradeReport2Count = MInteger.parseInt(totalVO.getGrade2ReportCnt().toString(), 0);
                    gradeReport3Count = MInteger.parseInt(totalVO.getGrade3ReportCnt().toString(), 0);
                    gradeReport4Count = MInteger.parseInt(totalVO.getGrade4ReportCnt().toString(), 0);
                    gradeReport5Count = MInteger.parseInt(totalVO.getGrade5ReportCnt().toString(), 0);
                }
            }

            if (totReportCount > 0) {
                compReportList = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "");       //전체-제출완료
            }
            if (organReportCount > 0) {
                organReportList = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "organ");  //기관-제출완료
            }
            if (gradeReport1Count > 0) {
                gradeReportList1 = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "1");      //1 유치원-제출완료
            }
            if (gradeReport2Count > 0) {
                gradeReportList2 = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "2");      //2 초등학교-제출완료
            }
            if (gradeReport3Count > 0) {
                gradeReportList3 = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "3");      //3 중학교-제출완료
            }
            if (gradeReport4Count > 0) {
                gradeReportList4 = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "4");      //4 고등학교-제출완료
            }
            if (gradeReport5Count > 0) {
                gradeReportList5 = prssService.getRecursiveAllReports(docID, TotReportProcess.COMP, "5");      //4 기타학교-제출완료
            }

        }

        tx.commit();

        /**
         * ********* HTML Form values **********
         */
        int tableCount = new Table().getCount(docID);
        int[] lineNum = new int[tableCount];
        String[] delSelect = new String[tableCount];
        StringBuffer queryBuff = new StringBuffer();
        if (rowDelType == 1) {
            for (int i = 0; i < tableCount; i++) {
                if (type.equals("first")) {
                    if (i == 0) {
                        lineNum[i] = 1;
                    } else {
                        lineNum[i] = MInteger.parseInt(request.getParameter("table" + i + ""), -1);
                    }
                } else {
                    lineNum[i] = MInteger.parseInt(request.getParameter("table" + i + ""), 0);
                }

                queryBuff.append("&table" + i + "=" + lineNum[i]);
            }
        }
        //String tmpStr = totDoc.getName() + "_" + edDate;
        //날짜 삭제함 by wonseok Lee 20170911
        String tmpStr = totDoc.getName();
%>
        <link rel="stylesheet" href="/totsys/common/css/kecttep.css" type="text/css"> <!-- 20160428 추가 -->
        <link rel="stylesheet" href="/totsys/common/css/SquareButtons.css" type="text/css"> <!-- 20160428 추가 -->
        <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/popup.js"></script>
        <script src="/totsys/common/js/rollover.js"></script>
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>
        <script src="/totsys/common/js/jquery.fixFormTable.js"></script>
        <script src="/totsys/common/js/jquery.custom.indicator.js"></script>
        <script>
        	$(document).ready(function(){
        		setupTableVal();
        	});
            //body onload 시에 호출된다.
            function setupTableVal() {
                if ("<%=tableNum%>" == "0") {
                    delTR.tableval.value = "alltitle";
                } else {
                    delTR.tableval.selectedIndex = "<%=tableNum%>";
                }
            }

             //첨부파일다운로드
            function fileDownLoad() {

                    //압축가능한 모든 첨부문서를 압축하시겠습니까?
                    if (confirm('<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.allDocPress")%>')) {
                        location.href = "/servlet/kr.co.kihyun.beans.totsys.totper.HttpFileDownLoad?saveAs=<%=URLEncoder.encode(tmpStr, "UTF-8")%>.zip&docID=<%=docID%>&listType=<%=listType%>&docType=<%=docType%>";
                    }

            }

            //검색 버튼
            function find2() {
                var word = document.searchForm.innerFindWord.value.length;
                var option = document.searchForm.innerFindOption.options[document.searchForm.innerFindOption.selectedIndex].value;

                //document.searchForm.findOption.value = option;
                document.searchForm.innerFindOption.value = option;

                if (document.searchForm.innerFindWord.value == "") {
                    alert("검색 단어를 입력해 주세요");
                    document.searchForm.innerFindWord.focus();
                    return false;
                }

                if (document.searchForm.innerFindOption.value != "id" && word < 2) {
                    alert("검색어는 2글자 이상이어야 합니다.!");
                    document.searchForm.innerFindWord.focus();
                    return false;
                }

                document.searchForm.action = "./total_reports.jsp";
                document.searchForm.submit();
            }

            function repoExcelSave(saveType) {
                var form1 = document.excelSaveForm;
                if (form1.isNotReport.value == "true") {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notReport")%>');
                    return;
                }
                form1.saveExprType.value = "no";
                form1.action = "/totsys/common/inc/documents/tot_reports/sub_total_reports_excel.jsp?&docName=<%=URLEncoder.encode(docName, "UTF-8")%>&saveType=" + saveType;
                form1.submit();
            }

            function excelSave(saveType) {
            	//////////체크된 항목만 엑셀다운 시작
            	var seqs=[];
                $('[name=check]').each(function(){
					var idx=$(this).attr('id').replace('check','');
					if(this.checked){
						var seq=$(this).parent().find('#checkReportID'+idx).val();
						seqs.push(seq);
					}
                });
                seqs=seqs.join(',');
                var form1 = document.excelSaveForm;
				form1.seqs.value=seqs;
				///////////////체크된 항목만 엑셀다운 끝
                if (form1.isNotReport.value == "true") {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notReport")%>');
                    return;
                }
                form1.saveExprType.value = "yes";
                form1.action = "/totsys/common/inc/documents/tot_reports/total_reports_excel.jsp?gradeCode=<%=gradeCode%>&searchType=<%=searchType%>&displaySummary=<%=displaySummary%>&prssSelect=<%=prssSelect%>&docName=<%=URLEncoder.encode(docName, "UTF-8")%>&docID=<%=docID%>&tableNum=<%=tableNum%>&sort=<%=sort%>&mngcode=<%=mngcode%>";//20160506 수정
                form1.submit();
            }

            function printReport() {
                var form1 = document.excelSaveForm;
                if (form1.isNotReport.value == "true") {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notPrintReport")%>');
                    return;
                }
                //기존
                //window.open("/totsys/common/inc/documents/tot_reports/total_reports_print.jsp?gradeCode=<%=gradeCode%>&searchType=<%=searchType%>&tableNum=<%=tableNum%>&docID=<%=docID%>&displaySummary=<%=displaySummary%>");

                var uri = "/totsys/common/inc/documents/tot_reports/total_reports_print.jsp?gradeCode=<%=gradeCode%>&searchType=<%=searchType%>&tableNum=<%=tableNum%>&docID=<%=docID%>&displaySummary=<%=displaySummary%>&prssSelect=<%=prssSelect%>&innerFindOption=<%= MString.checkNull(innerFindOption)%>&innerFindWord=<%= URLEncoder.encode(MString.checkNull(innerFindWord), "UTF-8")%>&mngcode=<%=mngcode%>";
                sendReport = getOpener(uri, 'sendReport', 600, 650, 'center', 'middle', 'yes', 'yes');
                sendReport.focus();
                //document.f_print.target = "printFrame";
                //document.f_print.submit();
            }

            function submitValue() {
                if (delTR.tableval.value != "alltitle") {
                    delTR.tableNum.value = delTR.tableval.selectedIndex;
                    var i = document.delTR.tableval.options.selectedIndex;
                    //ie10,11 호환성 수정
                    document.delTR["table" + (i - 1)].value = delTR.tableval.value;
                }
                delTR.submit();
            }



            function changePrssMore(pp) {
                if (pp != 1 && pp != 2) {
                    alert("처리할 수 없는 구분자입니다.")
                    return false;
                }

                //초기화는 필수이다.
                //ie10,11 호환성 수정 - document.ready 전 호출시 에러발생 처리
                try{
	                prssChange.changeReportID.value = "";
                }catch(e){
	                alert('로딩이 완료되지 않았습니다');
	                return;
                }
                //자신이 등록한 자료만 재입력요청/부서초기화 기능이 가능합니다.
                if (("<%=regID%>" == "<%=usID%>") || ("<%=deptID%>" == "<%=dpID%>" && ("<%=sysAuth%>" == "<%=MoumiConfig.SUB_TOTADM%>") || ("<%=sysAuth%>" == "<%=MoumiConfig.SUB_SYSADM%>")) || ("<%=sysAuth%>" == "<%=MoumiConfig.TOTADM%>" || "<%=sysAuth%>" == "<%=MoumiConfig.SYSADM%>"))
                {
                    checkValue = 0;
                    var check = $("input:checkbox[name=check]"); 
                    jj = check.length;

                    if (jj == undefined) {
                        jj = document.getElementsByName("check").length;
                        if (jj != 1) {
                            return;
                        }
                        var tmp = document.getElementsByName("check");
                        if (tmp[0].checked) {
                            prssChange.changeReportID.value += document.getElementById("checkReportID0").value;
                            checkValue++;
                        }

                    } else {
                        for (ii = 0; ii < jj; ii++) {
                            if (check[ii].checked == true) {
                                if (prssChange.changeReportID.value.length == 0) {
                                    prssChange.changeReportID.value += document.getElementById("checkReportID" + ii).value;
                                } else {
                                    prssChange.changeReportID.value += "," + document.getElementById("checkReportID" + ii).value;
                                }
                                checkValue++;
                            }
                        }
                    }

                    if (checkValue > 0) {

                        var exitFlag = false;
                        var $checked = $("input:checkbox[name=check]:checked");
                        var chkVal = "";
                        var okCnt = 0;

                        //재입력요청
                        if (pp == 1) {
                            for (var i = 0; i < checkValue; i++) {
                                chkVal = $checked[i].value;

                                if ($("#checkPrss" + chkVal).val() == '<%= TotReportProcess.COMP.ordinal()%>'        //제출완료 6,
                                        || $("#checkPrss" + chkVal).val() == '<%= TotReportProcess.NOTE.ordinal()%>'     //자료회수요청 14
                                        || $("#checkPrss" + chkVal).val() == '<%= TotReportProcess.NOT.ordinal()%>') {   //해당없음 12
                                    okCnt = okCnt + 1;
                                } else {
                                    document.getElementById("check" + chkVal).checked = false;
                                    exitFlag = true;
                                    //break;
                                }
                            }

                            //부서초기화
                        } else if (pp == 2) {
                            for (var i = 0; i < checkValue; i++) {
                                chkVal = $checked[i].value;

                                if ($("#checkPrss" + chkVal).val() == '<%= TotReportProcess.APPROVE.ordinal()%>') {         //결재진행 5
                                    document.getElementById("check" + chkVal).checked = false;
                                    exitFlag = true;
                                    //break;
                                } else {
                                    okCnt = okCnt + 1;
                                }
                            }
                        }

                        if (exitFlag == true) {
                            if (pp == 1) {
                                alert("진행상태가 [제출완료, 자료회수요청, 해당없음]의 경우에 \n재입력요청을 할 수 있습니다.");
                            } else if (pp == 2) {
                                alert("진행상태가 [결재진행]이면 부서초기화를 할 수 없습니다.");
                            }
                            return false;
                        }


                        if (pp == 1) {
                            if (confirm(checkValue + "<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.deptSelectReturn")%>")) {
                                document.prssChange.changePrss.value = "return";
                                window.open('/totsys/memo/rereport/pop_rereport.jsp', 'rereport', 'width=601, height=300,toolbar=no, directories=no, status=no, menubar=no, resizable=no');
                            }
                        } else if (pp == 2) {
                            if (confirm(checkValue + "<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.deptSelectInt")%>")) {
                                document.prssChange.changePrss.value = "accept";
                                prssChange.submit();
                            }
                        }

                    } else {
                        alert("부서를 선택하셔야 합니다");
                    }
                } else {
                    alert("<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.docModify")%>");   //자신이 등록한 자료만 수정이 가능합니다.
                }
            }

            /*
             * 목록페이지로 이동처리하는 함수
             */
            function fn_goToList() {
                document.listForm.submit();
            }

            /*
             * 테이블 각 셀 garbage 요소를 제거하여, 레이아웃을 정돈한다.
             * 2014.09.19 by YoungJun Cho.
             */
             //ie10,11 재입력 요청,부서초기화 문제 수정
             var prssChange;

            $(document).ready(function() {
            	//테두리 수정
				
				//제출부서 리스트 레이지로딩
				$.customIndicator.show(window.self);
				var xhr;
				//로딩 3분 이상 걸리면 엑셀로 다운할지 질의
				/* setTimeout(function(){
					if(xhr.readyState!=4&&confirm('처리시간이 지연되어 화면에 표시할 수 없습니다.\r\n\r\n엑셀로 데이터를 저장하시겠습니까?')){
						xhr.abort();
						$('#formDiv div:first').text('리스트 로딩 취소');
						$.customIndicator.hide(window.self);
						$('[src="/totsys/common/images/bt_excel.gif"]').trigger('click');
					}
				},1000*60*3); */
				if(confirm('취합한 자료를 저장하시겠습니까?\r\n[확인]을 누르면 엑셀로 저장합니다.\r\n[취소]를 누르면 화면에 보여줍니다.')){
					$('#formDiv div:first').text('리스트 로딩 취소');
					$.customIndicator.hide(window.self);
					$('[alt=엑셀저장]').trigger('click');
				}else{
					xhr=$.post('',$('#reqlistform').serialize(),function(data){
						$('#formDiv').html($(data).find('#formDiv').html());
						//var reportID=$(data).find('[name=Trans] [name=reportID]').val();
						//alert(reportID);
						//$('[name=reportID]').val(reportID);
						$.customIndicator.hide(window.self);
						$('[name="formheader"] > table').attr({'border':'1','bo':'true'}).css('border','1px solid #000').find('td').each(function(i,o){
							if($(o).closest('table').attr('bo')=='true'){
								$(this).css('border','1px solid #000');
							}
		          		});
	            	// 글자가리는거 수정
						$('[name="formheader"] *').css('line-height','2').css('height','');
					},'html');
				}

            if(!prssChange){
            	prssChange=$('[name="prssChange"]')[0];
            	$('[name^="checkReportID"]').each(function(){
            		$(this).attr('id',$(this).attr('name'));
            	});
            }
            <%if (displaySummary) {%>
                // 전체 집계표 보기 체크시 표의 레이아웃을 정돈.

                // 대상 테이블 : 전체집계표, 기관별집계현황표, 유치원별집계현황표, 초등학교별집계현황표, 중학교별집계현황표, 기타학교별집계현황표
                $.fixViewFormTableForXMLNameSpace($("#formDiv").find("table").find("table").find("table td").children(), {});

                // 대상 테이블 : 집계현황표 아래에 각 부서별로 제출한 테이블표
                $.fixViewFormTableForXMLNameSpace($(".fixTarget").find("table td").children(), {});
            <%} else {%>
                // 전체 집계표 보기 체크해제시 표의 레이아웃을 정돈.
                $.fixViewFormTableForXMLNameSpace($("#formDiv").find("table").find("table td").children(), {});
            <%}%>
            });
            /* 자료입력 테이블 input element 뒤에 font, span 등의 불필요한 element 를 삭제처리. 끝 */

            var gEventY = 0;
            var gEventX = 0;
            /**
             * Ajax기능을 사용하여 서버에 첨부파일 리스트을 요청하는 함수
             * @param {type} p_deptId
             * @param {type} p_lov_type
             * @returns {undefined}
             */
            function popupViewInner(p_index, obj_id, p_reportID) {
                gEventY = window.event.y;
                gEventX = window.event.x;

                $.ajax({
                    url: "/servlet/kr.co.kihyun.service.servlet.AjaxProcessServlet",
                    type: "POST",
                    dataType: "json",
                    data: {
                        proc_type: "attatch_file",
                        index: p_index,
                        file_index: obj_id,
                        report_id: p_reportID
                    },
                    success: function(data) {
                        fn_callBackForSuccess(data);
                    },
                    error: function(e) {
                        alert("error=" + e);
                    },
                    beforeSend: function() {
                        $.customIndicator.show(window.self);
                    },
                    complete: function() {
                        $.customIndicator.hide(window.self);
                    }
                });
            }

            /**
             * fn_getDeptLOV함수의 성공 시 호출되는 함수
             * @param {type} data
             * @returns {undefined}
             */
            function fn_callBackForSuccess(data) {
                var fileList = "";

                var index = "";
                var fileIndex = "";
                var reportID = "";
                var docID = "";
                var deptID = "";
                var fileName = "";
                var fileNameEncode = "";

                if (data != null) {
                    for (var i = 0; i < data.length; i++) {
                        index = data[i].index;
                        fileIndex = data[i].fileIndex;
                        reportID = data[i].reportID;
                        docID = data[i].docID;
                        deptID = data[i].deptID;
                        fileName = data[i].fileName;
                        fileNameEncode = data[i].fileNameEncode;
                        fileList += "<span style='color: #FF9C1B; font-weight: bold;'>+첨부파일 " + (i + 1) + " : </span><a style='white-space: nowrap;' onclick=\"popupClose(\'" + fileIndex + "\');\" href=\'/servlet/kr.co.kihyun.text.html.HttpViewer?saveAs=" + fileNameEncode + "\&fileName=" + fileNameEncode + "\&docID=" + docID + "&deptID=" + deptID + "\&reportID=" + reportID + "\' target=\'hiddenIframe\'>" + fileName + "</a><br/>\n";
                    }
                    document.getElementById("fileNameList" + index).innerHTML = fileList;
                }

                $(".ajdxjdrnfl").hide();
                /*
                 //+++++++++++++++++++++++++++++++++++++
                 //그외 첨부파일은 모두 클로즈한다.
                 var tempIndex = "";
                 $(".ajdxjdrnfl").each(function() {
                 tempIndex = $(this).attr("id")
                 if(fileIndex != tempIndex) {
                 cpt_layer = document.getElementById(tempIndex);
                 cpt_layer.style.display='none';
                 }
                 });
                 */

                //cpt_layer = document.getElementById(fileIndex);
                cpt_layer = $("#" + fileIndex);

                //gEventY = cpt_layer.offsetTop;
                //gEventX = cpt_layer.offsetLeft;
                if (cpt_layer.css("display") === "none") {
                    cpt_layer.css({
                        "top": function() {
                            return gEventY + 50;
                        },
                        "left": function() {
                            return gEventX - 100;
                        },
                        "width": 200
                    });
                    //cpt_layer.style.top = gEventY + 50; //window.event.y - 10;
                    //cpt_layer.style.left = gEventX - 100; //window.event.x - 130;
                    //cpt_layer.style.display='';
                    //cpt_layer.style.width = 200;

                    cpt_layer.show();
                }
            }

            function loadKWD() {
                <%if( tableCount == 0 ){ %>
                    alert("교육부로 연계 전송할 자료가 없습니다.");
                    return;
                <%}%>
                if( confirm("교육부로 연계 전송 하시겠습니까?") ){
                try {
                   $.customIndicator.show(window.self);// 20160421 loading indicator 추가
                } catch(e) {
                   alert(e);
                }
                var form1 = document.Trans;
                    form1.target = "hiddenIframe";
                form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.HttpVCMCCMC2016Send";//20160419 수정
                form1.submit();
            }
            }
            // 20160421 추가
            function fn_indiClose(){
                $.customIndicator.hide(window.self);
            }

            //20160421 IR 테이블의 교육청 자료 조회후 교육부 DB 업무 테이블에 INSERT
            function fn_irOfcDataSave(){
                try {
                   $.customIndicator.show(window.self);
                } catch(e) {
                   alert(e);
                }
                var form1 = document.Trans;
                form1.target = "hiddenIframe";
                form1.callFn.value = "parent.fn_irOfcDataSaveExe()";
                form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.CheckIrReportTable";
                form1.submit();
            }

            function fn_irOfcDataSaveExe(){
                if( confirm("연계전송된 교육청 자료를 조회하여 저장하시겠습니까?") ){

                    try {
                       $.customIndicator.show(window.self);// 20160421 loading indicator 추가
                    } catch(e) {
                       alert(e);
                    }
                    var form1 = document.Trans;
                    form1.target = "hiddenIframe";
                    form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.HttpVCMCCMC2016Receive";//20160419 수정
                    form1.submit();

                }//end if
            }

            //20160428 IR 테이블의 교육청 연계 자료 초기화
            function fn_irDataInit(){
                try {
                   $.customIndicator.show(window.self);
                } catch(e) {
                   alert(e);
                }
                var form1 = document.Trans;
                form1.target = "hiddenIframe";
                form1.callFn.value = "parent.fn_irDataInitExe()";
                form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.CheckIrReportTable";
                form1.submit();
            }

            function fn_irDataInitExe(){

                if( confirm("연계 전송된 교육청 자료를 초기화 하시겠습니까?") ){
                    try {
                       $.customIndicator.show(window.self);
                    } catch(e) {
                        alert(e);
                    }
                    var form1 = document.Trans;
                    form1.target = "hiddenIframe";
                    form1.action = "/servlet/kr.co.kihyun.beans.totsys.report.HttpVCMCCMC2016Init";
                    form1.submit();
                }//end if

            }

        </script>
    <div>
        <form name="listForm" method="post" action="/totsys/totper/mydocbox/prssbox/doc_list.jsp">
            <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="f_print" action="/totsys/common/inc/documents/tot_reports/total_reports_print.jsp" method="post">
            <input type="hidden" name="gradeCode" value="<%=gradeCode%>">
            <input type="hidden" name="searchType" value="<%=searchType%>">
            <input type="hidden" name="tableNum" value="<%=tableNum%>">
            <input type="hidden" name="docID" value="<%=docID%>">
            <input type="hidden" name="displaySummary" value="<%=displaySummary%>">
            <input type="hidden" name="prssSelect" value="<%=prssSelect%>">
        </form>
        <iframe name="printFrame" width="0" height="0" style="display:none;"></iframe>

        <!-- 20160421 IR 테이블의 교육청 자료 조회후 저장 관련 추가 시작-->
        <iframe name="hiddenIframe" width="0" height="0" style="display: none;"></iframe>
        <!-- 20160421 IR 테이블의 교육청 자료 조회후 저장 관련  추가 끝-->

        <span id="SetWin" style="position: absolute; z-index: 10; Visibility: hidden; height: 65px; width: 210px; background: silver; border: 1px #333333 solid; line-height: 1.4em; padding: 3px 3px"></span>
        <table>
    	<tr class="toolbar">
        <td>
            <table>
                <tr>
                    <td style="padding-left: 5px; padding-top: 10px;">
                        <form name="delTR" action="./total_reports.jsp" method="post" style="width: 38px;">
                            <input type="hidden" name="docID" value=<%=docID%>>
                            <input type="hidden" name="gradeCode" value=<%=gradeCode%>>
                            <input type="hidden" name="docType" value=<%=docType%>>
                            <input type="hidden" name="rowDelType" value="1">
                            <input type="hidden" name="searchType" value="<%=searchType%>">
                            <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="searchDepth" value="none">
                            <input type="hidden" name="innerStrPage" value="<%= innerStrPage%>">
                            <input type="hidden" name="innerFindOption" value="<%= MString.checkNull(innerFindOption)%>">
                            <input type="hidden" name="innerFindWord" value="<%= URLEncoder.encode(MString.checkNull(innerFindWord),"UTF-8")%>">

                            <% if (displaySummary) {%>
                            <input type="hidden" name="displaySummary" value="<%= displaySummary%>">
                            <% }%>
                            <% if (prssSelect) {%>
                            <input type="hidden" name="prssSelect" value="<%= prssSelect%>">
                            <% }%>
                            <%
                                for (int i = 0; i < tableCount; i++) {
                            %>
                            <input type="hidden" name="table<%=i%>" value="-1"> <%
                                }%>
                            <select name="tableval" onchange="submitValue()" class="inputtxt">
                                <!-- 전체내용 -->
                                <option value="alltitle"><%=TotReportProcess.ALL%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.content")%></option>
                                <%
                                    Item item = new Item();
                                    int[] titleCount = item.getTitleRowCountList(docID);

                                    for (int i = 0; i < titleCount.length; i++) {
                                %>
                                <!-- 1번표 -->
                                <option value="<%=titleCount[i]%>"><%=(i + 1)%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.numTable")%></option>
                                <%
                                    }
                                %>
                            </select>
                            <!-- 전체내용이 우선적으로 보여지도록 할 때 적용 -->
                            <!--input type="hidden" name="tableNum" value=""-->
                            <!-- 1번표가 우선적으로 보여지도록 할 때 적용 -->
                            <input type="hidden" name="tableNum" value="0">
                        </form>
                    </td>
                    <td style="padding-left: 5px; padding-top: 10px;width: 110px;">
                        <form name="searchselect" action="./total_reports.jsp" method="post">
                            <input type="hidden" name="docID" value=<%=docID%>>
                            <input type="hidden" name="docType" value=<%=docType%>>
                            <input type="hidden" name="gradeCode" value=<%=gradeCode%>>
                            <input type="hidden" name="rowDelType" value="1">
                            <input type="hidden" name="tableval" value="<%=tableval%>">
                            <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="searchDepth" value="none">
                            <input type="hidden" name="innerStrPage" value="<%= innerStrPage%>">
                            <input type="hidden" name="innerFindOption" value="<%= MString.checkNull(innerFindOption)%>">
                            <input type="hidden" name="innerFindWord" value="<%= URLEncoder.encode(MString.checkNull(innerFindWord),"UTF-8")%>">


                            <% if (displaySummary) {%>
                            <input type="hidden" name="displaySummary" value="<%= displaySummary%>"> <% }%>
                            <% if (prssSelect) {%>
                            <input type="hidden" name="prssSelect" value="<%= prssSelect%>"> <% }%>
                            <input type="hidden" name="tableNum" value="<%=tableNum%>">
                            <%for (int i = 0; i < tableCount; i++) {%>
                            <input type="hidden" name="table<%=i%>" value="<%= lineNum[i]%>">
                            <%}%>
                            <!-- 모든 제출상태(-1), 제출완료(6), 접수(0) -->
                            <select name="searchType" onchange="javascript:submit();" class="inputtxt">
                                <option value="-1" <%= searchType == -1 ? " selected" : ""%>><%=Moumi.getMessageBundle().getString("moumi.message.tot_report.allReportStatus")%></option>
                                <option value="<%=TotReportProcess.COMP.ordinal()%>" <%= searchType == TotReportProcess.COMP.ordinal() ? " selected" : ""%>><%=TotReportProcess.COMP%></option>
                                <option value="<%=TotReportProcess.ACCEPT.ordinal()%>" <%= searchType == TotReportProcess.ACCEPT.ordinal() ? " selected" : ""%>><%=TotReportProcess.ACCEPT%></option>
                            </select>
                            <!-- 기관정렬(#), 기관별(1), 학교별(2) -->
                            <%if( !dpID.contains("A00")){%>
                            <select name="sort" onchange="javascript:submit();" class="inputtxt">
                                <option value="#"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.sortKind")%></option>
                                <option value="1" <%if (sort.equals("1")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.perOrgan")%></option>
                                <option value="2" <%if (sort.equals("2")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.perSchool")%></option>
                                <option value="3" <%if (sort.equals("3")) {%> selected <%}%>>제출일시</option>
                            </select>
                            <%}%>
                            <!-- 20160509 교육청 리스트 추가 시작 -->
                            <%if( dpID.contains("A00") && docID > 1700000000){%>
                            <select name="mngcode" onchange="javascript:submit();" class="inputtxt">
                                <option value="" <%if (mngcode.equals("")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.a00")%></option>
                                <option value="b10" <%if (mngcode.equals("b10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.b10")%></option>
                                <option value="c10" <%if (mngcode.equals("c10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.c10")%></option>
                                <option value="d10" <%if (mngcode.equals("d10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.d10")%></option>
                                <option value="e10" <%if (mngcode.equals("e10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.e10")%></option>
                                <option value="f10" <%if (mngcode.equals("f10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.f10")%></option>
                                <option value="g10" <%if (mngcode.equals("g10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.g10")%></option>
                                <option value="h10" <%if (mngcode.equals("h10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.h10")%></option>
                                <option value="i10" <%if (mngcode.equals("i10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.i10")%></option>
                                <option value="j10" <%if (mngcode.equals("j10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.j10")%></option>
                                <option value="k10" <%if (mngcode.equals("k10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.k10")%></option>
                                <option value="m10" <%if (mngcode.equals("m10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.m10")%></option>
                                <option value="n10" <%if (mngcode.equals("n10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.n10")%></option>
                                <option value="p10" <%if (mngcode.equals("p10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.p10")%></option>
                                <option value="q10" <%if (mngcode.equals("q10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.q10")%></option>
                                <option value="r10" <%if (mngcode.equals("r10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.r10")%></option>
                                <option value="s10" <%if (mngcode.equals("s10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.s10")%></option>
                                <option value="t10" <%if (mngcode.equals("t10")) {%> selected <%}%>><%=Moumi.getMessageBundle().getString("moumi.message.neisParty.t10")%></option>
                            </select>
                            <%}%>
                            <!-- 20160509 교육청 리스트 추가 끝-->
                        </form>
                    </td>
                    <td style="padding-left: 5px; padding-top: 10px;">
                        <form name="checksummary" action="./total_reports.jsp" method="post">
                            <input type="hidden" name="docID" value=<%=docID%>>
                            <input type="hidden" name="docType" value=<%=docType%>>
                            <input type="hidden" name="gradeCode" value=<%=gradeCode%>>
                            <input type="hidden" name="rowDelType" value="1">
                            <input type="hidden" name="tableval" value="<%=tableval%>">
                            <input type="hidden" name="searchType" value="<%=searchType%>">
                            <input type="hidden" name="tableNum" value="<%=tableNum%>">
                            <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="searchDepth" value="none">
                            <input type="hidden" name="innerStrPage" value="<%= innerStrPage%>">
                            <input type="hidden" name="innerFindOption" value="<%= MString.checkNull(innerFindOption)%>">
                            <input type="hidden" name="innerFindWord" value="<%= URLEncoder.encode(MString.checkNull(innerFindWord),"UTF-8")%>">

                            <%for (int i = 0; i < tableCount; i++) {%>
                            <input type="hidden" name="table<%=i%>" value="<%= lineNum[i]%>">
                            <%}%>
                             <!-- 전체(진행자료포함) 자료보기 -->
<!--                            <label for="">
                                <input type="checkbox" onclick="javascript:submit();" name="prssSelect" value="prssSelect" <%--= prssSelect ? "checked" : ""--%> style="border: 0;" />
                                <span class="f_12_p_Black_L">전체(진행자료 포함) 자료 보기</span>
                            </label>-->
                            <!-- 전체 집계표 보기 -->
                            <label>
                                <input type="checkbox" onclick="javascript:submit();" name="displaySummary" value="displaySummary" <%= displaySummary ? "checked" : ""%> style="border: 0;" />
                                <span class="f_12_p_Black_L"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.allTotdocTableView")%></span>
                            </label>
                        </form>
                    </td>
                    <td style="padding-left: 5px;  padding-top: 10px; vertical-align: top;">
                        <table>
                            <tr>
                                <td style="padding-left: 20px;">
                                <!-- 첨부파일다운로드 button -->
                                    <a href="javascript:void(0);" onclick="fileDownLoad();"><img src="/totsys/common/images/bt_disk.gif" title="부서를 선택하지 않고 버튼을  클릭 시 전체 부서의 자료가 저장됩니다" /></a>
                                    <a href="javascript:void(0);" onclick="excelSave('part');"><img src="/totsys/common/images/bt_excel.gif" alt="<%= Moumi.getMessageBundle().getString("moumi.message.button_small.excel")%>" /></a>
                                    <a href="javascript:void(0);" onclick="printReport();"><img src="/totsys/common/images/bt_print2.gif" alt="<%= Moumi.getMessageBundle().getString("moumi.message.button_small.print")%>" /></a>
                                        <%
                                            if (!docType.equals("END")) {
                                                if (!(sysAuth == 2 && !usID.equals(userId) && docAccAuth == AccessAuth.ALL)) {
                                        %>
                                    <a href="javascript:void(0);" onclick="changePrssMore(1)"><img src="/totsys/common/images/bt_return2.gif" alt="<%= Moumi.getMessageBundle().getString("moumi.message.button.return")%>" /></a>
                                    <a href="javascript:void(0);" onclick="changePrssMore(2)"><img src="/totsys/common/images/bt_accept.gif" alt="<%= Moumi.getMessageBundle().getString("moumi.message.button.deptInit")%>" /></a>
                                        <%
                                                }
                                            }
                                        %>
	                                <!-- 목록 -->
                                    <a href="javascript:void(0);" onclick="javascript:fn_goToList();">
                                     <img src="/totsys/common/images/bt_list.gif" alt="<%= Moumi.getMessageBundle().getString("moumi.message.button.boardList")%>" />
                                    </a>
                                </td>
                               <!-- 20160426 교육부 전송 버튼 조건 추가-->
                                <%if( "PRSS".equals(docType) && !dpID.contains("A00") && docID > 1700000000){%>
                                <td class="kecttep_button_td">
                                        <a href="#" onclick="loadKWD();">
                                            <img src="/totsys/common/images/bt_sendMoe.gif" alt="<%= MoumiConfig.getMessageBundle().getString("moumi.message.button_small.edu") %>" />
                                        </a>
                                </td>
                               <%}%>
                               <!-- 20160426 교육청 자료 조회 버튼 추가 시작-->
                               <%if( "PRSS".equals(docType) && dpID.contains("A00") && docID > 1700000000){%>
                                <td class="kecttep_button_td">
                                    <a href="#" onclick="javascript:fn_irOfcDataSave();">
                                     <img src="/totsys/common/images/bt_receiveEdu.GIF" alt="연계 자료를 조회한 후 업무 DB에 적용" />
                                    </a>
                                </td>
                                <td class="kecttep_button_td">
                                    <a class="" href="#" onclick="javascript:fn_irDataInit();">
                                         <img src="/totsys/common/images/bt_esbDataInit.GIF" alt="연계 테이블의 자료를 삭제" />
                                    </a>
                                </td>
                                <%}%>
                                            <!-- 20160426 교육청 자료 조회 버튼 추가 끝-->
                            </tr>
                        </table>
                        <!--  엑셀저장/인쇄버튼 좌측정렬 끝 -->
                    </td>
                </tr>
                <!--  sub topbar  끝 -->


                <tr>
                    <td colspan="4" style="width: 100%">
                        <div class="red padding_10">
                        * 복수의 서식을 취합하는 경우는 취합결과를 표별로 엑셀 저장할 수 있습니다.
                        </div>
                        <form name="searchForm" method="post" style="margin: 0 0 10px 0;" >
                            <input type="hidden" name="docID" value=<%=docID%>>
                            <input type="hidden" name="docType" value=<%=docType%>>
                            <input type="hidden" name="gradeCode" value=<%=gradeCode%>>
                            <input type="hidden" name="rowDelType" value="1">
                            <input type="hidden" name="tableval" value="<%=tableval%>">
                            <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="searchDepth" value="inner">

                            <% if (displaySummary) {%>
                            <input type="hidden" name="displaySummary" value="<%= displaySummary%>">
                            <% }%>
                            <% if (prssSelect) {%>
                            <input type="hidden" name="prssSelect" value="<%= prssSelect%>">
                            <% }%>
                            <input type="hidden" name="tableNum" value="<%=tableNum%>">
                            <%for (int i = 0; i < tableCount; i++) {%>
                            <input type="hidden" name="table<%=i%>" value="<%= lineNum[i]%>">
                            <%}%>

                            <span style="width: 100%">
                                <input type="hidden" name="docType" value="<%=docType%>">
                                <input type="hidden" name="docID" value="<%= docID%>">
                                <input type="hidden" name="innerStrPage" value="<%= innerStrPage%>">
                                <select name="innerFindOption" class="inputtxt" onchange="showMSG(this.options[this.selectedIndex].value, msg)">
                                    <option value="mDept.name"<%= "mDept.name".equals(innerFindOption) ? "selected" : ""%>><%= Moumi.getMessageBundle().getString("moumi.message.tot_doc.process.submit")%><%= Moumi.getMessageBundle().getString("moumi.message.doc.Devision")%></option>
                                    <option value="mOrgan.name"<%= "mOrgan.name".equals(innerFindOption) ? "selected" : ""%>>제출기관</option>
                                </select>
                                <input name="innerFindWord" value="<%=MString.checkNull(innerFindWord)%>" type="text" class="inputtxt" size="30" maxlength="30" style="ime-mode: active;" />
                                <img alt="검색" onclick="find2()" src="/totsys/common/images/bt_search_inquiry2.gif" />
                                <span id="msg" class="kecttep_date_search" style='display: none;'>&nbsp;&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.daySearchForm")%></span>
                            </span>
                        </form>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <!-- 내용 시작 -->
    <tr>
        <td style="padding-top: 12px; padding-left: 12px; padding-right: 12px; height: 31px;">
            <div id="formDiv" style="overflow-x: auto; overflow-y: auto;">
            <%=reqlist?"":"<div>"+count+" 개의 부서 로딩중...</div>" %>
                <table>

                    <% if (displaySummary && totReportCount > 0) {%>

                    <!-- 전체집계표 -->
                    <tr>
                        <td>
                            <table>
                            
			                    <% if (tableNum != 0 && (searchType == TotReportProcess.COMP.ordinal() || searchType == -1)) {%>
			                    <tr>
			                        <td id="formheader" name="formheader"><%=TagFilter.removeTableHeight(MDoc.getTitleForm(totDoc, tableNum))%></td>
			                    </tr>
			                    <%} else {%>
			                    <!--td align="center"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.submit")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.content")%></td-->
			                    <%}%>
                                <tr>
                                    <td style="width: 14"><img src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
                                    	<%=TotReportProcess.ALL%><%=TotDocType.TOT_DOC%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%= totReportCount%></span>&nbsp;&nbsp;
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= allReportCount%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (totReportCount != 0) { //if (compReportList.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, compReportList, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>  <!-- 접수된 제출자료가 없습니다. -->
                                        <%}%>

                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14px"><img src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
                                    	기관별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=organReportCount%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= organReportCount_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (organReportCount != 0) { //if (organReportList.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, organReportList, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>

                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14"><img alt="말머리" src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
                                    	유치원별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=gradeReport1Count%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= gradeReport1Count_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (gradeReport1Count != 0) { //if (gradeReportList1.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, gradeReportList1, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>

                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14"><img alt="말머리" src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
                                    	초등학교별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=gradeReport2Count%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= gradeReport2Count_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (gradeReport2Count != 0) { //if (gradeReportList2.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, gradeReportList2, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>

                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14"><img src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
										중학교별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=gradeReport3Count%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= gradeReport3Count_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (gradeReport3Count != 0) { //if (gradeReportList3.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, gradeReportList3, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>

                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14px;"><img alt="말머리" src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1">
                                                                                고등학교별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=gradeReport4Count%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= gradeReport4Count_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (gradeReport4Count != 0) { //if (gradeReportList4.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, gradeReportList4, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;"></td>
                    </tr>

                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td style="width: 14px;"><img alt="말머리" src="/totsys/common/images/ico_3.gif"></td>
                                    <td class="kecttep_title td_style1"> 
										기타학교별집계현황<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.table")%>&nbsp;&nbsp;
                                        <%=TotReportProcess.COMP%>:<span style="color: #ff6600"><%=gradeReport5Count%></span>
                                        <%=TotReportProcess.ALL%>:<span style="color: #ff6600"><%= gradeReport5Count_all%></span></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td id="formheader" name="formheader">
                                        <%if (gradeReport5Count != 0) { //if (gradeReportList5.size() != 0) {%>
                                        <%= TotReportUtil.toHTML(totDoc, gradeReportList5, tableNum, tableNum > 0)%>
                                        <%} else {%>
                                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_report.notSubmitDoc")%>
                                        <%}%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr><td style="height: 10px;"></td></tr>
                    <tr>
                        <td style="height: 10px;">--------------------------------------------------------------------------------</td>
                    </tr>
                    <tr><td style="height: 10px;"></td></tr>

                    <%} else if (displaySummary && totReportCount <= 0) {%>
                    <tr><!-- 현재까지 제출된 자료로는 집계표를 생성할수 없습니다. -->
                        <td><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.notTotdocTable")%></td>
                    </tr>
                    <tr><td style="height: 10px;"></td></tr>
                    <tr>
                        <td style="height: 10px;">--------------------------------------------------------------------------------</td>
                    </tr>
                    <tr><td style="height: 10px;"></td></tr>
                        <%}%>               
			       <% if (tableNum != 0 && (searchType == TotReportProcess.COMP.ordinal() || searchType == -1)) {%>
			                    <tr>
			                        <td id="formheader" name="formheader"><%=TagFilter.removeTableHeight(MDoc.getTitleForm(totDoc, tableNum))%></td>
			                    </tr>
			                    <%} else {%>
			                    <!--td align="center"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.submit")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.content")%></td-->
			                    <%}%>


                    <%
                        int index = -1;
                        int slavePaddingLeft = 0;
                        //tx.begin();
                        String reportIds = ""; //20160419 추가

                        //아작스 호출 아닐 시 표시안함
                        if (count > 0&&reqlist) {
                            int listCount = list.size();

                            for (int i = 0; i < listCount; i++) {
                            	//if(i>100)continue;
                                index = i;

                                PrssReportsVO prssVO = (PrssReportsVO) list.get(i);
                                TotReportProcess process = (TotReportProcess) prssVO.getProcess();

                                if ("2".equals(prssVO.getDeptNo())) {
                                    slavePaddingLeft = 30;
                                } else {
                                    slavePaddingLeft = 0;
                                }

                                int kkkk = prssVO.getProcess().ordinal();
                                String html = null;
                                if ((process == TotReportProcess.COMP || process == TotReportProcess.TEMP || process == TotReportProcess.APPROVE) && prssVO.getDownDocId() == null) {
                                    //html = prssVO.getToHTML(pm, tableNum, tableNum > 0, true); //표를 만들어 찍어주는 부분
                                    TotReport report = pm.getObjectById(TotReport.class, prssVO.getId());
                                    html = TotReportUtil.toHTML(report, tableNum, tableNum > 0, true); //표를 만들어 찍어주는 부분
                                }

                    %>             
              <tr>
                  <td style="padding-left: <%= slavePaddingLeft%>px;">
                      <table>
                          <tr>
                              <td style="width: 14px;"><input type=checkbox name='check' id="check<%=index%>" value="<%=index%>">
                            <input type="hidden" name="checkPrss<%=index%>" id="checkPrss<%=index%>" value="<%=prssVO.getProcess().ordinal()%>">
                            <input type='hidden' id='checkReportID<%=index%>' name='checkReportID<%=index%>' value='<%=prssVO.getId()%>'>
                              </td>
	                          <td class="kecttep_title td_style1">
	                              <%= prssVO.getUpperDeptName() == null ? "" : prssVO.getOrganName() + " - " + prssVO.getUpperDeptName() + " - "%>
	                              <%= prssVO.getDeptName()%>&nbsp;&nbsp;
	                              <%= MString.checkNull(prssVO.getOwnerName())%>
	                              <!-- 제출날짜추가 2015.04.29 진승환-->
	                              &nbsp;<%= prssVO.getSubmitDate() == null ? "" : new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(prssVO.getSubmitDate())%>
	                              <% if (prssVO.getDownDocId() != null) {
	                                      out.write("   [" + MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.subdoc") + "]");
	                                  }%>
	                              [<%=process%>]
	                          </td>
	                          <td></td>
                 			</tr>
             			</table>
        			  </td>
    			</tr>
    <tr>
        <!--<td align="left">-->
        <!--// 2014.10.16 by youngjun cho. jquery 로 테이블표의 레이아웃을 정리하기 위한 class명("fixTarget") 추가 -->
		<td align="left" name="formheader" style="padding-left: <%= slavePaddingLeft%>px;" class="fixTarget"><!--//도표 나오는 부분//-->

            <%if(prssSelect){%>
            <%= ((process == TotReportProcess.COMP || process == TotReportProcess.TEMP || process == TotReportProcess.APPROVE) && prssVO.getDownDocId() == null) ? (html == null ? "" : html) : ""%>
            <%}else{%>
            <%= ((process == TotReportProcess.COMP) && prssVO.getDownDocId() == null) ? (html == null ? "" : html) : ""%>
            <%}%>
            <input type='hidden' id='kkkk<%=index%>' value='<%= kkkk%>'>
        </td>
    </tr>
    <tr>
        <td style="padding-left: <%= slavePaddingLeft%>px;">
            <table>

                <% if ("Y".equals(prssVO.getIsAttachments()) || (null != prssVO.getAttachmentsPath() && !"".equals(prssVO.getAttachmentsPath()))) { %>
                <!-- 2014.10.08 Add by KWON,HAN : 제출완료 -> 제출완료, 회수요청 -->
                <%if (process == TotReportProcess.COMP || process == TotReportProcess.NOTE) {%>
                <tr><!-- 첨부파일 -->
                    <td class="kecttep_title td_style1">
                        <%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.add")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.file")%>
                        <a href="javascript:void(0);" onclick="popupViewInner('<%=index%>', 'file<%=index%>', '<%=prssVO.getId()%>');" title="첨부파일을 확인하시려면 클릭해주세요."><img src="/totsys/totper/mydocbox/prssbox/reports/images/disk2.gif"></a>

                    </td>
                </tr>
                <div class="ajdxjdrnfl" id="file<%=index%>" style="display: none; position: absolute; z-index: 2px;">
                    <tr><td style="height: 10px;"></td></tr>
                    <tr>
                        <td style="padding-left: 10px; text-align: left;">
                            <div id="fileNameList<%=index%>"></div>
                        </td>
                    </tr>
                </div>
                <%} else {%> &nbsp; <%}%>
                <%}%>
            </table>
        </td>
    </tr>
    <%
    //System.out.println("-----------------------------"+(listCount-i-1));
                //20160419  추가
                if(i == 0){
                    reportIds = String.valueOf( prssVO.getId() );
                }else{
                    reportIds = reportIds + "|" + String.valueOf( prssVO.getId() );
                }

            }  //end of for list
        }   //end of if( count > 0)

    %>

    <!-- 해당자료가 없습니다. -->
    <%if (count <= 0) { //if (reportList.size() <= 0) {%>
    <tr style="padding-top: 3px;">
        <td class="kecttep_none_tdmenu" colspan="15" style="height: 25px; text-align: center;"><%= MoumiConfig.getMessageBundle().getString("moumi.message.tot_report.reportDocNot")%></td>
    </tr>
    <%}%>

    <tr>
    <td>
    </td>
    </tr>
</table>
<form id="reqlistform" style="display: none;">
<%
Enumeration nenum= request.getParameterNames();
while(nenum.hasMoreElements()){
	String nm=nenum.nextElement()+"";
	String val=request.getParameter(nm);
%>
<input type="hidden" name="<%=nm%>" value="<%=val%>"/>
<%} %>
<input type="hidden" name="reqlist" value="true"/>
</form>
<FORM name="Trans" action="/servlet/kr.co.kihyun.beans.totsys.repoper.HttpReportTrans" method="post">
            <INPUT type="hidden" name="reportID" value="<%= reportIds %>"> <!-- 20160419 수정 -->
            <input type="hidden" name="docID" value="<%=docID%>">
            <input type="hidden" name="callFn" value="">
        </FORM>
</div>
</td>
</tr>

<!--1픽셀 띄우기-->
<tr>
    <td style="height: 10px;"></td>
</tr>
</table>

<form name="excelSaveForm" target="_parent" action="/totsys/common/inc/documents/tot_reports/total_reports_excel.jsp" method="post">
    <input type="hidden" name="docID" value="<%=docID%>">
    <input type="hidden" name="rowDelType" value="<%=rowDelType%>">
    <input type="hidden" name="isNotReport" value="<%=list.size() <= 0%>">
    <input type="hidden" name="saveExprType">
    <input type="hidden" name="tableval" value="<%=tableval%>">
    <input type="hidden" name="findOption" value="<%=MString.checkNull(findOption)%>">
    <input type="hidden" name="findWord"   value="<%=MString.checkNull(findWord)%>">
    <input type="hidden" name="innerFindOption" value="<%= MString.checkNull(innerFindOption)%>">
    <input type="hidden" name="innerFindWord" value="<%= URLEncoder.encode(MString.checkNull(innerFindWord),"UTF-8")%>">
    <input type="hidden" name="rowDelType" value="<%=rowDelType%>">
    <% for (int i = 0; lineNum != null && i < lineNum.length; i++) {%>
    <input type="hidden" name="table<%=i%>" value="<%=lineNum[i]%>">
    <% }%>
    <input type="hidden" name="seqs" value="">
</form>

<form name="prssChange" method="post" action="/servlet/kr.co.kihyun.beans.totsys.totper.HttpReportPrssChange2">
    <input type="hidden" name="docID" value="<%=docID%>">
    <input type="hidden" name="changePrss" value="accept">
    <input type="hidden" name="changeReportID" value="">
    <input type="hidden" name="contents" value="">
    <input type="hidden" name="docType" value="<%=docType%>">
</form>
<iframe name='hiddenFrame' width=0 height=0 style='display:none;'></iframe>
<!-- 리스트호출용form -->
</div>
<%
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
%>
