<%    /**
     * **********************************************************
     * @@ Program Name  : popup_form_list.jsp
     * @@ Description	: 집계문서 등록 이전 집계문서 재사용
     * @@ Author	: 기현테크
     * @@ Create Date	: 2010-11-28
     * @@ History	: 2014-12-08 Update by KWONM,HAN : 서식함활용 리스트 조회 속도 개선
     * @@***********************************************************
     */
%>
<%@ page contentType="text/html; charset=UTF-8"
         import="java.util.List"
         import="java.util.ArrayList"
         import="java.net.URLEncoder"
         import="java.net.URLDecoder"
         import="java.util.Date"
         import="java.util.Calendar"
         import="java.util.List"
         import="java.util.Map"
         import="java.util.HashMap"
         import="javax.jdo.*"
         import="java.text.SimpleDateFormat"
         import="kr.co.kihyun.beans.entity.*"
         import="kr.co.kihyun.beans.entity.util.*"
         import="kr.co.kihyun.beans.user.HttpSSOLogin"
         import="kr.co.kihyun.moumi.Moumi"
         import="kr.co.kihyun.moumi.MoumiConfig"
         import="kr.co.kihyun.util.MDate"
         import="kr.co.kihyun.lang.MInteger"
         import="kr.co.kihyun.text.html.ServletUtil"
         import="kr.co.kihyun.moumi.doc.MDoc"
         import="kr.co.kihyun.moumi.doc.table.MTable"
         import="kr.co.kihyun.lang.MString"
         import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.moumi.report.MReport"
         import="kr.co.kihyun.service.FormService"
         import="kr.co.kihyun.service.vo.FormVO"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%    PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
    Transaction tx = pm.currentTransaction();
    try {
//        tx.begin();

        /**
         * ******** session내의 userId *********
         */
        String usID = HttpSSOLogin.getLoginID(request);
        String dpID = HttpSSOLogin.getDeptID(request);
        int sysAuth = HttpSSOLogin.getSysAuth(request);

//        MUser mUser = pm.getObjectById(MUser.class, usID);

        /**
         * **** Parameter values *****
         */
        String findOption = "";
        String findWord = "";
        String viewRange = "";
        int accAuth = 0;
        int strPage = 0;

        strPage = MInteger.parseInt(request.getParameter("strPage"), 1);
        if(strPage <= 0) { strPage = 1; }
        findOption = clearXSS(MString.checkNull(request.getParameter("findOption")), "name");
        //28.크로스사이트 스크립트(Reflected)_CWE-80 : Add by KWON,HAN
        if (findOption != null) {
            findOption = findOption.replaceAll("<", "&lt");
            findOption = findOption.replaceAll(">", "&gt");
        }
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //clearXSS(URLDecoder.decode(request.getParameter("findOption"), "UTF-8"),"");
        findWord = clearXSS(Encoder.toJava(request.getParameter("findWord")), "");
        accAuth = MInteger.parseInt(request.getParameter("accAuth"));
        viewRange = Encoder.toJava(request.getParameter("viewRange"));
        String stDate = clearXSS(request.getParameter("stDate"),"");
        String edDate = clearXSS(request.getParameter("edDate"),"");

        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 = 30;

        if (MString.isNull(viewRange)) {
            viewRange = "OWN";
        }

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

        currentPage = strPage;

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

        tx.begin();

        //======================================================================
        FormService formService = new FormService(pm);
        //검색조건파라미터
        Map params = new HashMap();
        params.put("userId",        usID);
        params.put("deptId",        dpID);
        params.put("sysAuth",       sysAuth);
        params.put("findOption",    findOption);
        params.put("filterValue",   findWord);
        params.put("stDate",        stDate);
        params.put("edDate",        edDate);

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

        //레코드갯수조회쿼리를 실행하여 레코드갯수를 구함
        int count = formService.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 ) {
            //페이징처리를 위한 추가파라미터 설정
            formService.getParams().put("startNo", startNo);
            formService.getParams().put("endNo", endNo);

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

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

        tx.rollback();

//        List<TotDoc> totDocs = null;
//        //List<TotDoc> totDocs = mUser.getForms(pm,findOption,findWord);//나중에 자바단의 sql부분을 수정이 되었을때 사용한다.
//        if (mUser.getSysAuth() == SysAuth.SYSADM) {
//
//            Object filterValue = findWord;
//            if (findOption != null && findOption.endsWith("Date")) {
//                filterValue = new SimpleDateFormat("yy-MM-dd").parse(findWord);
//            }
//
//            Map<String, Object> filterMap = new HashMap<String, Object>(1);
//            filterMap.put(findOption, filterValue);
//
//            QueryImpl q = new QueryImpl(pm, TotDoc.class);
//            //q = new QueryImpl(pm, TotDoc.class, (List<TotDoc>) q.execute());
//            q = new QueryImpl(pm, TotDoc.class);
//
//            StringBuilder filter = new StringBuilder(110).append("isDeleted == false && type == kr.co.kihyun.beans.entity.TotDocType.FORM_DOC");
//            q.setFilter(filter.toString());
//            q.setSearchFilter(filterMap);
//            q.setOrdering("id DESC");
//            totDocs = (List<TotDoc>) q.execute();
//
//        } else {
//            Object filterValue = findWord;
//            if (findOption != null && findOption.endsWith("Date")) {
//                filterValue = new SimpleDateFormat("yy-MM-dd").parse(findWord);
//            }
//            totDocs = mUser.getForms(pm, findOption, filterValue);
//        }
//        count = totDocs.size();
//        currentPage = strPage;
//
//        List<TotDoc> totDocs2 = new ArrayList<TotDoc>();
//        if (count > 0 && findOption != null && findOption.equals("totDoc.mUser.name") && findWord != null && findWord.length() > 1) {
//            for (int index = 0; index < count; index++) {
//                String tmp = totDocs.get(index).getUser(pm).getName(pm);
//                if (tmp == null) {
//                    continue;
//                }
//                if (tmp.indexOf(findWord) >= 0) {
//                    totDocs2.add(totDocs.get(index));
//                }
//            }
//            totDocs = totDocs2;
//            count = totDocs.size();
//        }
//
//        if ((count % recordSize) == 0) {
//            pageSize = (int) (count / recordSize);
//        } else {
//            pageSize = (int) (count / recordSize) + 1;
//        }
//
//        currentPageSetUp = (int) (currentPage / 10) * 10;
//        if (currentPage % 10 == 0) {
//            currentPageSetUp -= 10;
//        }
//
//        String uri = URLEncoder.encode("./popup_form_list.jsp?findOption=" + findOption + "&findWord=" + findWord + "&accAuth=" + accAuth + "&viewRange=" + viewRange, "UTF-8");

%>
<html>
    <head>
        <title>서식함활용</title>
        <meta http-equiv="Content-Type" content="text/html; 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">
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>
        <script src="/totsys/common/js/rollover.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>
	        var check;
			$(document).ready(function(){
				check = $("input:checkbox[name=check]");	
			});
            // 찾아진 주소중에 하나를 클릭 했을때 실행하는 메소드.
            function doLink(reuseDocID, docNameList, tableType) {
                if (confirm(docNameList + "<%=Moumi.getMessageBundle().getString("moumi.message.popup.dataReuse")%>")) {
                    opener.dform.reuseDocID.value = reuseDocID;
                    //opener.dform.deptCountText.value = Moumi.getMessageBundle().getString("moumi.message.tot_doc.submitDevision");
                    //opener.docForm.oldFormName.value = docNameList;
                    self.resizeTo(963, 626);
                    location = "/totsys/totper/mydocbox/regbox/reuse_copy_form.jsp?reuseDocID=" + reuseDocID;
                } else {
                    return;
                }
            }

            <%if ("OWN".equals(viewRange)) {%>
            function docDelete() {
                var checkValue = 0;
                var docIDList = "";
                if (<%=count%> == 1) {
                    if (check.checked == true) {
                        if (docIDList.length == 0)
                            docIDList += document.getElementById("checkDocID0").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.docCounterDelete")%>")) {
                        document.Del.docID.value = docIDList;
                        document.Del.submit();
                    }
                } else {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.deleteDocSelect")%>');
                }
            }


			function fn_changeDamDang() {
                var checkValue = 0;
                var docIDList = "";
                if (<%=count%> == 1) {
                    if (check.checked == true) {
                        if (docIDList.length == 0)
                            docIDList += document.getElementById("checkDocID0").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) {
                 	var height = screen.height;
	                var width = screen.width;
	                var leftpos = width / 2 - 350;
	                var toppos = height / 2 - 350;
                    frm = document.damdangForm;
	                frm.docID.value = docIDList
	                //2014.09.15 Update by KWON,HAN : 담당변경의 멀티선택 처리가 가능하도록 변경함.
	                //frm.action="/totsys/repoper/mydocbox/returnbox/popup_rep_transfer4.jsp";
	                frm.action = "/totsys/repoper/mydocbox/returnbox/popup_form_transfer.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();
                } else {
                    alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.deleteDocSelect")%>');
                }
            }

            function selectAll() {
                if (<%=count%> == 1) {
                    if (check.disabled == false)
                        check.checked = true;
                } else if (<%=count%> != 0) {
                    for (i = 0; i < check.length; i++) {
                        if (check[i].disabled == false)
                            check[i].checked = true;
                    }
                }
            }

            function cancelAll() {
                if (<%=count%> == 1) {
                    check.checked = false;
                } else if (<%=count%> != 0) {
                    for (i = 0; i < check.length; i++) {
                        check[i].checked = false;
                    }
                }
            }
            <%}%>

            function searchType(type) {
                document.searchForm.viewRange.value = type;
                document.searchForm.submit();
            }

            function popopener(url, target, width, height, align, valign, scroll, resize) {

                /////////////// window a ? ///////////////////////
                var scWidth = screen.width;
                var scHeight = screen.height;

                var toppos = 0;		//? top
                var leftpos = 0;	//? left

                if (align == "center") {
                    leftpos = (scWidth - width) / 2;
                } else if (align == "right") {
                    leftpos = (scWidth - width);
                } else if (align == '') {
                    leftpos = (scWidth - width) / 2;
                }

                if (valign == "middle") {
                    toppos = (scHeight - height) / 2;
                } else if (valign == "buttom") {
                    toppos = (scHeight - height);
                } else if (valign == '') {
                    toppos = (scHeight - height) / 2;
                }

                target = window.open(url, target, "width=" + width + ", height=" + height + ", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=" + scroll + ", resizable=" + resize + ", left=" + leftpos + ", top=" + toppos);
                //				target = window.open(url, target, "width="+width+", height="+height+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=auto, resizable="+resize+", left="+leftpos+", top="+ toppos);
                target.focus();
            }

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

            function init(){
                var sFindOption = "<%=findOption%>";
                //findOption = tmpFind.value;

                if (sFindOption == "name" || sFindOption == "totDoc.mUser.name") {
                    document.getElementById('spanFindWord').style.display = 'inline';
                    document.getElementById('spanRegDate').style.display = 'none';
                } else {
                    document.getElementById('spanFindWord').style.display = 'none';
                    document.getElementById('spanRegDate').style.display = 'inline';
                }
            }

            /**
             * 검색유형에 대한 이벤트 처리 함수
             * @param {type} obj
             * @returns {undefined}
             */
            function fn_findOptionChange(obj) {
                var val = obj.value;
               // alert("val = " + val);

                if(val == "name" || val == "totDoc.mUser.name") {
                    document.getElementById('spanFindWord').style.display = 'inline';
                    document.getElementById('spanRegDate').style.display = 'none';
                    document.getElementById('findWord').value = '';
                } else {
                    document.getElementById('spanFindWord').style.display = 'none';
                    document.getElementById('spanRegDate').style.display = 'inline';
                }
            }

            /**
             * 시작일과 종료일의 정합성 체크 함수
             * @param {type} stDate
             * @param {type} edDate
             * @returns {Boolean}
             */
            function isDateTrue(stDate, edDate) {
                if(stDate <= edDate) {
                        return true;
                }
                return false;
            }

            //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;
                }

                document.searchForm.submit();
            }

        </SCRIPT>
    </head>

    <!--<body style='' leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="init(); resizeTo('900', '750'); moveTo('100', '100');">-->
    <body style='' leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="init(); resizeTo('900', '770');">
        <!--타이틀 //-->
        <table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#00FFFF">
            <tr>
                <td style="padding: 10px 10px 0 10px;">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td bgcolor="728ab5" style="padding: 10px 20px 10px 20px">
                                <!-- 서식함활용 -->
                                <strong><font color="#FFFFFF"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.formBox")%><%=Moumi.getMessageBundle().getString("moumi.message.doc.UpTake")%></font></strong>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <!--타이틀 //-->


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

            <!---- 검색부분 //---->
            <tr>
                <td align="left">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr valign="middle">
                            <td align="left" width="350" valign="middle" style="padding-left: 10px;">
                                <FORM name="searchForm" action="./popup_form_list.jsp" method="post">
                                    <input type="hidden" name="strPage" value="<%= currentPage %>">
                                    <select name="findOption" class="inputtxt" align="absmiddle" onchange="fn_findOptionChange(this);" >
                                        <option value="name"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.document")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.name")%></option>
                                        <option value="totDoc.mUser.name"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.registrition")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.person")%></option>
                                        <option value="regDate"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.registrition")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.day")%></option>
                                    </select>
                                    <span id="spanFindWord" style="display: inline;">
                                    <input id="findWord" name="findWord"  type="text" class="inputtxt" size="30" maxlength="30" value="<%= findWord%>" align="absmiddle">
                                    </span>
                                    <!--등록일 -->
                                    <span id="spanRegDate" style="display: none;">
                                    <input name="stDate" type="text" size="10" value="<%=stDate%>" readonly onclick="showSetWin('searchForm.stDate');" style="cursor: pointer;  vertical-align: middle;" class="inputtxt">
                                    <a href="#" onclick="showSetWin('searchForm.stDate');">
                                        <img 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 src="/totsys/common/images/date.gif" align="middle">
                                    </a>
                                    </span>
                                    <input type="image" src="/totsys/common/images/bt_search.jpg" align="absmiddle">
                                    <input type="hidden" name="accAuth" value="<%=accAuth%>">
                                    <input type="hidden" name="viewRange" value="<%=viewRange%>">
                                </FORM>
                            </td>
                            <%if ("OWN".equals(viewRange)) {%>
                            <td valign="top">
                                <span onclick="selectAll()" style="cursor: hand">
                                    <img src="/totsys/common/images/bt_allsel.gif" align="absmiddle">
                                </span>
                                <span onclick="cancelAll()" style="cursor: hand">
                                    <img src="/totsys/common/images/bt_selcancle.gif" align="absmiddle">
                                </span>
                                <span onclick="docDelete()" style="cursor: hand">
                                    <img src="/totsys/common/images/bt_formdel.gif" align="absmiddle">
                                </span>
                                 <!--//담당변경//-->
                                <span onclick="fn_changeDamDang()" style="cursor: hand">
                                    <img src="/totsys/common/images/bt_damdang.gif" alt="<%=MoumiConfig.getMessageBundle().getString("moumi.message.button.trans")%>" />
                                </span>
                            </td>
                            <%}%>
                        </tr>
                    </table>
                </td>
            </tr><!----// 검색부분 ---->


            <!---- 리스트 시작 ---->
            <tr>
                <td valign="top" style="padding-left: 10px; padding-right: 10px">
                    <table border="1px" bordercolor="#e3e3e3" class="kecttep_list_table" width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <%if ("OWN".equals(viewRange)) {%>
                            <td class="kecttep_tdmenu" align="center" nowrap><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.select")%></td>
                            <%}%>
                            <td nowrap align="center" class="kecttep_tdmenu">&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.document")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.number")%>&nbsp;</td>
                            <td align="center" class="kecttep_tdmenu">&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.document")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.name")%>&nbsp;</td>
                            <td align="center" class="kecttep_tdmenu"><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.registrition")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.person")%></td>
                            <td nowrap align="center" class="kecttep_tdmenu">&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.coporation")%>/<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.devision")%>&nbsp;</td>
                            <td nowrap align="center" class="kecttep_tdmenu">&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.registrition")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.day")%>&nbsp;</td>
                            <td nowrap align="center" class="kecttep_tdmenu">&nbsp;<%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.remark")%>&nbsp;</td>
                        </tr>
                        <%//for(int i=0; i < count; i++){%>

                        <%
                            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;
                                FormVO fromVO = (FormVO)list.get(i);

//                            for (int i = 0; (i < recordSize) && ((nextCount + i) < count); i++) {
//                                index = nextCount + i;

                        %>
                        <tr style="padding-top: 3" valign="middle" onmouseover="this.style.backgroundColor = 'F9F9F9'" onmouseout="this.style.backgroundColor = 'white'" bgColor=#ffffff>
                        <input type="hidden" name="repDocID" value="<%= fromVO.getId()%>">
                        <input type="hidden" name="docName" value="<%= fromVO.getName()%>">

                        <%if ("OWN".equals(viewRange)) {%>
                        <td width="30" nowrap class="kecttep_graytd" height="25" align="center">
                            <input type="checkbox" name="check">
                            <input type="hidden" id="checkDocID<%=index%>" name="checkDocID<%=index%>" value="<%= fromVO.getId()%>">
                        </td>
                        <%}%>
                        <td width="80" nowrap height="25" align="center" class="kecttep_graytd">
                            <%= fromVO.getId()%>
                        </td>
                        <td class="kecttep_graytd">&nbsp;&nbsp;
                            <a style="cursor: hand;" heft="#" onclick="popopener('/totsys/common/web/documents/tot_doc/popup_inform_preview.jsp?docID=<%= fromVO.getId()%>&mode=preview&callType=regbox1step', 'preview', '840', '600', 'center', 'middle', 'yes', 'yes');">
                                <%= MString.getEllipsis(fromVO.getName(), wordLengthLimit)%>
                            </a>
                        </td>
                        <td width="80" nowrap align="center" class="kecttep_graytd"><%= fromVO.getOwnerName()%></td>
                        <td width="140" nowrap align="center" class="kecttep_graytd"><%= fromVO.getDeptName()%></td>
                        <td width="120" nowrap align="center" class="kecttep_graytd"><%= new SimpleDateFormat("yyyy/MM/dd").format(fromVO.getRegDate())%></td>
                        <td width="80" nowrap align="center" class="kecttep_last_graytd">&nbsp;</td>
            </tr>
                        <%
                            }       //end of for list
                        }       //end of if( count > 0)
//                            }
                        %>
                        <!----  내용 끝 ---->
        </table>
    </td>
</tr>

<tr>
    <td height="15">&nbsp;</td>
</tr>

<%if (count > 0) {%>
<tr valign="middle">
    <td colspan="<%if ("OWN".equals(viewRange)) {%>7<%} else {%>6<%}%>" align="center">
        <table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td height="25" colspan="13" align="center">
                    <!------------------------------- 페이지수 나오는 부분 시작 ------------------------------->
                    <%--
                    <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>
        </table>
    </td>
</tr>
<%} else {%>
<tr>
    <td colspan="<%if ("OWN".equals(viewRange)) {%>7<%} else {%>6<%}%>" align="center">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td class="kecttep_none_tdmenu" height="25" align="center"><%=Moumi.getMessageBundle().getString("moumi.message.popup.notRegistedDoc")%></td>
            </tr>
        </table>
    </td>
</tr>
<%}%>
<!---- 리스트 끝---->

<!--검색후 검색조건 선택하기위한 스크립트(히든값포함)-->
<input type="hidden" id="tmpFind" name="tmpFind" value="<%=findOption%>">
<FORM name="Del" action="/servlet/kr.co.kihyun.beans.totsys.doc.HttpDocDeleter" method="post">
    <INPUT type="hidden" name="docID" value="" />
    <INPUT type="hidden" name="userID" value="<%= usID%>" />
    <INPUT type="hidden" name="url" value="reuseform" />
    <INPUT type="hidden" name="viewRange" value="<%= viewRange%>" />
    <INPUT type="hidden" name="findOption" value="<%= findOption%>" />
    <INPUT type="hidden" name="findWord" value="<%= findWord%>" />
    <INPUT type="hidden" name="accAuth" value="<%= accAuth%>" />
</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="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 == "totDoc.mUser.name") {
        searchForm.findOption.selectedIndex = 1;
    } else if (tmpFind.value == "regDate") {
        searchForm.findOption.selectedIndex = 2;
    }
</script>
<!--검색후 검색조건 선택하기위한 스크립트 끝-->
</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>
<%
//        tx.commit();
    } 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();
    }
%>
