
<%
/************************************************************@@
  * Program Name	: group_list.jsp
  * Description		: 그룹목록
  * Author			: 기현테크
  * Create Date		: 2010-11-24
  * History			:
@@************************************************************/
%>

<%@ page contentType="text/html; charset=UTF-8"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.moumi.Moumi" import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.beans.user.Dept"
	import="kr.co.kihyun.beans.user.UserGroupList"
	import="kr.co.kihyun.beans.user.UserGroup"
	import="org.slf4j.Logger"
	import="org.slf4j.LoggerFactory"
	%>

<%
Logger LOG = LoggerFactory.getLogger(this.getClass());
try{
	/********** session내의 userId **********/
	String usID = HttpSSOLogin.getLoginID(request);
	int sysAuth = HttpSSOLogin.getSysAuth(request);

	/************ GroupList **************/
	UserGroupList grouplist = new UserGroupList();

	grouplist.executeQuery(usID,sysAuth);

	int groupCount = grouplist.getCount();

	//LOG.debug("groupCount: {}", groupCount);
	String[] usePartIDList = grouplist.getPartIDList();
	//LOG.debug("usePartIDList: {}", usePartIDList);
	String[] useNameList = grouplist.getNameList();

	//LOG.debug("useNameList {}", useNameList);
	int[] usePartCountList = new int[groupCount];
	String[] useDescList = grouplist.getDescList();
	//LOG.debug("useDescList {}", useDescList);

//	Dept dept = new Dept();

	StringBuffer stringTree = new StringBuffer();

	stringTree.append("<ul class=\"mktree\" id=\"tree1\">");

/*
	for(int p=0; p<groupCount; p++){
		if(dept.getLowDeptCount(usePartIDList[p])>0){
			stringTree.append("<li id=\""+usePartIDList[p]+"\"><span style=\"cursor:pointer;\" onclick=\"toggleF('"+usePartIDList[p]+"'); parent.userList('"+usePartIDList[p]+"');\"><img src=\"/totsys/common/images/plus.gif\" id='i_"+usePartIDList[p]+"'>&nbsp;"+useNameList[p]+"</span><input id='h_"+usePartIDList[p]+"' type='hidden' value='close'/><div id=\"t_"+usePartIDList[p]+"\"></div></li>");
		}else{
			stringTree.append("<li id=\""+usePartIDList[p]+"\"><span style=\"cursor:pointer;\" onclick=\"parent.userList('"+usePartIDList[p]+"');\"><img src=\"/totsys/common/images/bullet.gif\">&nbsp;"+useNameList[p]+"</span></li>");
		}
	}
*/

	for(int p=0; p<groupCount; p++){
		usePartCountList[p] = new UserGroupList().groupCount(usePartIDList[p]);
		stringTree.append("<li id=\""+usePartIDList[p]+"\"><span id=\"span_"+usePartIDList[p]+"\" style=\"cursor:pointer;\" onclick=\"parent.groupList('"+usePartIDList[p]+"','"+useNameList[p]+"', 'group'); selectItem('"+usePartIDList[p]+"');\"><img src=\"/totsys/common/images/plus.gif\">&nbsp;"+useNameList[p]//+" {"+MString.checkNull(useDescList[p])+"}"
                                                                                                                                                                                                                                                                                                     +" ("+usePartCountList[p]+")"); //   {} 제거
		if(new UserGroupList().getUserUserEffectiveness(usePartIDList[p]) == true)
			stringTree.append("&nbsp;<font color=\"red\">[")
			.append(Moumi.getMessageBundle().getString("moumi.message.tot_doc.modification")).append("]</font></span></li>");
		else
			stringTree.append("</span></li>");
	}
	stringTree.append("</ul>");


%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK REL="stylesheet" HREF="/totsys/common/css/mktree.css">
<SCRIPT LANGUAGE="JavaScript" SRC="/totsys/common/js/mktree.js"></SCRIPT>

<script src="/totsys/common/js/rollover.js"></script>

<script language="javascript">
			function toReportFrame(partID, partName, selectType){
				parent.tstate = true;

				var str = '';
				str = '/servlet/kr.co.kihyun.beans.user.HttpDeptList?partID='+partID+'&selectType='+selectType;
				parent.leftFrame.location.replace(str);
			}
/*
		function init(partID, selectType){
				parent.tstate = true;

				var str = '';
				str = '/servlet/kr.co.kihyun.beans.user.HttpDeptList?partID='+partID+'&selectType='+selectType;
				parent.leftFrame.location.replace(str);
		}
*/
		function init(){
			parent.userGroup = true;
		}
		</script>


<script type="text/javascript">
			var xhr = null;
			var subID = "";

			var selected_id = "";
			var old_id = "";


function getXMLHttpRequest() {
	if (window.ActiveXObject) {
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");//IE 상위 버젼
        } catch (e1) {
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");//IE 하위 버젼
            } catch (e2) {
                return null;
            }
        }
    } else if (window.XMLHttpRequest) {
        return new XMLHttpRequest();//IE 이외의 브라우저(FireFox 등)
    } else {
        return null;
    }
}// XMLHttpRequest 객체 얻기



function requestTree(id) {
	subID = id;
    URL = "./subtree.jsp?id=" + id;//한글 처리
    xhr = getXMLHttpRequest();//XMLHttpRequest 객체 얻기
    xhr.onreadystatechange = responseTree;//콜백 함수  등록
    xhr.open("GET", URL, true);//연결
    xhr.send(null);//전송
}// 서버에 요청



function responseTree() {
    if (xhr.readyState == 4) {//완료
        if (xhr.status == 200) {//오류없이 OK
            var str = xhr.responseText;//서버에서 보낸 내용 받기
            document.getElementById("t_"+subID).innerHTML = str;//보여주기
        } else {
            alert("Fail : " + httpRequest.status);
        }
    }
}// 응답

function toggleF(id) {
	subID = id;
	var hid = "h_"+id;
    if (document.getElementById("h_"+subID).value == "open") {//폴더열려있음
		document.getElementById("h_"+subID).value = "close";
        document.getElementById("t_"+subID).innerHTML = "";
		document.getElementById("i_"+subID).src = "/totsys/common/images/plus.gif";
    }
	else{
		document.getElementById("h_"+subID).value = "open";
		document.getElementById("i_"+subID).src = "/totsys/common/images/minus.gif";
		requestTree(id);
	}
}// 응답


function selectItem(id) {
	old_id = selected_id;
	selected_id = id;
	var old_item = document.getElementById("span_"+old_id);
	if(old_item){
		old_item.style.fontWeight="normal";
	}
    document.getElementById("span_"+selected_id).style.fontWeight="bold";
}// 응답

</script>

</head>

<!--<body style='overflow=auto' bgcolor="#CECECE" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >-->
<body style='' text="#000000" leftmargin="0" topmargin="0"
	marginwidth="0" marginheight="0" onLoad="init()">
<TABLE width="100%" cellpadding="5" cellspacing="2" border="0">
	<TBODY>
		<TR>
			<TD align="left"><%=stringTree.toString()%></TD>
		</TR>
	</TBODY>
</TABLE>
</body>
</html>
<%
}catch(Exception ex){ex.printStackTrace();

	out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
}finally{
}
%>
