
<%
/************************************************************@@
  * Program Name	: part_list.jsp
  * Description		: 기관 목록
  * Author				: 강원중
  * Create Date		: 2004-10-29
  * 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.beans.user.UserGroupList"
	import="kr.co.kihyun.beans.user.UserGroup"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
try{
	/********** session내의 userId **********/
	String usID = HttpSSOLogin.getLoginID(request);	
	int sysAuth =  HttpSSOLogin.getSysAuth(request);

	/************* 사용자정의 그룹리스트 ****************/
	UserGroupList grouplist = new UserGroupList();
	grouplist.executeQuery(usID, sysAuth);

	String[] usePartIDList = grouplist.getPartIDList();
	String[] useNameList = grouplist.getNameList();

	/**************** 파라메터 ****************/
	String listNum = clearXSS(request.getParameter("listNum"),"");

	String deptIDs = "";
	String deptNames = "";
	String userIDs = "";
	String userNames = "";
	String[] idList = null;
	String[] nameList = null;
	String[] userUserID = null;
	String[] userUserName = null;
	String[] userDeptID = null;

	if(!listNum.equals("")){
		UserGroup ugroup = new UserGroup();
		int num = Integer.parseInt(listNum);
				//부서리스트 가져오기
				idList = ugroup.getDeptID(usePartIDList[num]);
				nameList = ugroup.getDeptName(usePartIDList[num]);
				if(idList != null){	
					for(int i=0; i < idList.length; i++){
						if( i == 0 ){
							deptIDs = deptIDs + idList[i];
						}else{
							deptIDs = deptIDs + "," + idList[i] ;
						}
					}

					for(int j=0; j < nameList.length; j++){
						if( j == 0){
							deptNames = deptNames + nameList[j];
						}else{
							deptNames = deptNames + "," + nameList[j] ;
						}
					}
				}

				//개인리스트 가져오기
				ugroup.userSetting(usePartIDList[num]);

				userUserID = ugroup.getUserUserID();
				userUserName = ugroup.getUserUserName();
				userDeptID = ugroup.getUserDeptID();

				if(userUserID != null){
					for(int i=0; i<userUserID.length; i++){ 
						if(i==0){
							userIDs = userUserID[i]+"/"+userDeptID[i];
							userNames = userUserName[i];
						}else{
							userIDs += ","+ userUserID[i]+"/"+userDeptID[i];
							userNames += ","+userUserName[i];
						}
					}
				}

	StringBuffer setListBuff = new StringBuffer();
	setListBuff.append("nameList = '"+deptNames+"';\n");
	setListBuff.append("idList = '"+deptIDs+"';\n");
	setListBuff.append("unameList = '"+userNames+"';\n");
	setListBuff.append("uidList = '"+userIDs+"';\n");

	%>
<script>
		/*
		parent.nameList = "<%//=deptNames%>";
		parent.idList = "<%//=deptIDs%>";
		parent.unameList = "<%//=userNames%>";
		parent.uidList = "<%//=userIDs%>";
		parent.leftFrameAdd(parent.nameList,parent.idList); 
		parent.userFrameAdd(parent.unameList,parent.uidList);
		*/

		parent.tstate = true;
		var str = '';				
		str = '/servlet/kr.co.kihyun.beans.user.HttpDeptList?usID=<%=usID%>&num=<%=num%>&selectType=sin';
		parent.leftFrame.location.replace(str);

		var ustr = '';				
		ustr = '/servlet/kr.co.kihyun.beans.user.HttpUserList?usID=<%=usID%>&num=<%=num%>&selectType=userSelect';
		parent.rightFrame.location.replace(ustr);

	</script>
<%
	}

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<link rel='StyleSheet' href='/totsys/common/css/dtree.css'
	type='text/css' />
<script type='text/javascript' src='/totsys/common/js/dtree.js'></script>


<script>
	function goingSelect(num){
		location.href="/totsys/common/web/report_dept/iframe/use_list.jsp?listNum="+num;
	}
</script>


<body style='' text="#000000" leftmargin="0" topmargin="0"
	marginwidth="0" marginheight="0">
<%
if(useNameList != null){
%>
<TABLE width="100%" cellpadding="5" cellspacing="2" border="0">
	<TBODY>
		<TR>
			<TD>
			<div class='dtree'><script type='text/javascript'>
			d = new dTree('d');
			d.add(0,-1,'사용자정의 조직도');
<%
	for(int i=0; i<useNameList.length; i++){
		%>
			d.add("<%=usePartIDList[i]%>",0,"<%=useNameList[i]%>","javascript:goingSelect(<%=i%>)");
		<%
	}
%>
			document.write(d);
			d.openAll();
			</script></div>

			</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{	
}
%>
