<%@ page contentType="text/html; charset=UTF-8"
         import="kr.co.kihyun.beans.user.HttpSSOLogin"
         import="kr.co.kihyun.text.html.ServletUtil"
         import="kr.co.kihyun.lang.MString" import="kr.co.kihyun.lang.MLong"
         import="java.net.URLDecoder" import="kr.co.kihyun.lang.Encoder"
         import="kr.co.kihyun.beans.totsys.report.ReportList"
         import="kr.co.kihyun.beans.user.User"
         import="kr.co.kihyun.moumi.report.MReport"
         import="kr.co.kihyun.moumi.Moumi"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%    try {
        String rootID = request.getParameter("rootID");
        //System.out.println(":::::rootID:::::" + rootID);

        if (HttpSSOLogin.getSysAuth(request) != Moumi.SYSADM && HttpSSOLogin.getSysAuth(request) != Moumi.SUB_SYSADM && HttpSSOLogin.getSysAuth(request) != Moumi.SUB_TOTADM && HttpSSOLogin.getSysAuth(request) != Moumi.REPOADM) {
            out.println(ServletUtil.alert(Moumi.getMessageBundle().getString("moumi.message.popup.notAuth")));
            String connURL = "parent.location='/totsys/login/frame.jsp';";
            out.println(ServletUtil.getJavaScript(connURL));
            return;
        }
%>
<!DOCTYPE html>
<html lang="ko">
	<head>
		<meta charset="UTF-8">
		<title>조직도 관리</title>
        <script src="/totsys/common/js/jquery-1.12.4.min.js"></script>
        <script src="/totsys/common/js/jquery.cookie.js"></script>
		<script src="/totsys/common/js/jquery.hotkeys.js"></script>
		<script src="/totsys/common/js/jquery.jstree.js"></script>
        <link rel="stylesheet" href="/totsys/common/css/kecttep.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/text.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/SquareButtons.css" type="text/css">
        <link rel="stylesheet" href="/totsys/common/css/contentStyle.css" type="text/css">
		<link rel="stylesheet" href="/totsys/common/css/basic.css" type="text/css">
        <script src="/totsys/common/js/org_search.js"></script>
        <script>
            // 부서 선택 시 유저 뽑아내기.
            function userList(id, name, type) {
                type = type.toLowerCase();

                if (type == 'root')
                    return;

                if (type != '') {
                    idAll = id;
                    selid = id;
                    selname = name;
                } else {
                    idAll = '';
                    selid = '';
                    selname = '';
                    type = 'dept';
                }
                seltype = type;
                idUpper = false;
                userGroup = false;
                if (type == 'user')
                    id = id.split('/')[0];

                document.detailFrame.location.replace('/totsys/sysadm/' + type + '/' + type + '_view.jsp?' + type + 'ID=' + id);
            }

            function searchWord() {
                var type = $('#findOption').val();
                type = type.toUpperCase();
                //alert("type = " + type);
                var word = $('#search').val();
                word = $.trim(word)         //2014.08.18 Add by KWON,HAN
                $('#search').val(word);     //2014.08.18 Add by KWON,HAN

                if (word.length < 2) {
                    alert("검색어는 2글자 이상이어야 합니다.");
                    return;
                }
                var $ff = $("#leftFrame");
                $ff[0].contentWindow.$("#searchType").text(type);  //검색유형
                $ff[0].contentWindow.$("#searchWord").text(word);  //검색값
                $ff[0].contentWindow.$("#search").click();
            }

            //조직도에서 검색된 노드로 포커스를 이동시킨다.  strType : down, up
            function focusMove(strType) {
                //alert("strType = " + strType);
                var $ff = $("#leftFrame");
                $ff[0].contentWindow.$("#moveType").text(strType);      //포커스이동타입
                $ff[0].contentWindow.$("#focusMove").click();
            }

            function treeReload() {
                var $ff = $("#leftFrame");
                $ff[0].contentWindow.$("#refresh").click();
            }

        </script>
    </head>
    <body>
        <form name="list" method="post" action="/servlet/kr.co.kihyun.beans.user.HttpDeptList" target="deptFrame">
            <input type="hidden" name="idList">
            <input type="hidden" name="nameList">
            <input type="hidden" name="typeList">
            <input type="hidden" name="openeridList">
            <input type="hidden" name="openernameList">
            <input type="hidden" name="openertypeList">
        </form>
        <table>
            <jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />
        </table>
        <table style="width: 930px;">
            <tr>
                <td style="width: 400px; text-align: left; padding-left: 15px;" class="kecttep_title">
                    <img src="/totsys/common/web/report_dept/images/ico_1.gif">
                    <%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.deptMap")%>
                </td>
                <td style="width: 20px; text-align: left;">&nbsp;</td>
                <td style="width: 510px; text-align: left;" class="kecttep_title pl_20">
                    <img alt="글머리" src="/totsys/common/web/report_dept/images/ico_1.gif">
                    <%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.detail")%><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.info")%>
                </td>
            </tr>
            <!-- 분류,부서 선택 -->
            <tr>
                <td style="width: 400px; vertical-align: top;">
                    <table style="width: 400px;">
                        <tr>
                            <td style="height: 30px; padding: 0;"><jsp:include page="toolbar.jsp" flush="true" /></td>
                        </tr>
                        <tr>
                            <td style="padding: 0;">
                               <!--// <iframe name="leftFrame" id="leftFrame" src="newTree2.jsp?userYN=Y&rootID=<%=rootID%>" width="400" height="325" frameborder="0"></iframe>//-->
                                <iframe name="leftFrame" id="leftFrame" src="newTree2.jsp?userYN=Y&rootID=<%=rootID%>" width="400" height="325" frameborder="0"></iframe>
                            </td>
                        </tr>
                        <tr class="toolbar">
                            <td class="kecttep_title" style="padding-left: 10px; text-align: left;">검색 :
                                <span style="width: 70px;">
                                <!-- showMSG 존재하지 않는 함수 -->
                                    <select id="findOption" name="findOption" class="inputtxt" onchange="$('#search').val('');
                                            //showMSG(this.options[this.selectedIndex].value, msg);
                                            ">
                                        <option value="user" selected><%=Moumi.getMessageBundle().getString("moumi.message.tot_doc.user")%></option>
                                        <option value="dept"><%=Moumi.getMessageBundle().getString("moumi.message.doc.Devision")%><%=Moumi.getMessageBundle().getString("moumi.message.doc.Name")%></option>
                                    </select>
                                </span>
                                <input id="search" name="search" type="text" class="inputtxt" value="" size="23" onkeyDown="if(event.keyCode === 13) { searchWord(); }" style="ime-mode:active;"/>
                                <a href="#" onclick="searchWord()"><img alt="찾기" src="/totsys/common/images/bt_search_inquiry2.gif"></a>
                                <a href="#" onclick="focusMove('down');"><img alt="다음" src="/totsys/common/images/bt_down.jpg"></a>
                                <a href="#" onclick="focusMove('up');"><img alt="이전" src="/totsys/common/images/bt_up.jpg"></a>
                            </td>
                        </tr>
                    </table></td>
                <td style="width: 20px;">&nbsp; </td>
                <td style="text-align: right; vertical-align: top;">
                    <table style="width: 510px;">
                        <tr>
                            <td><iframe name="detailFrame" src="about:blank" width="520px;" height="500px;" frameborder="0"></iframe></td>
                        </tr>
                    </table>
                </td>
        </table>
    </body>
</html>
<%
    } catch (Exception e) {
        e.printStackTrace();
        out.println(Moumi.getMessageBundle().getString("moumi.message.tot_doc.error") + "sysadm/org/org_view.jsp");
    } finally {
    }
%>
