/* 
    IntraPMS Project
    부서 발령에서 사원의 현재 상태를 보여주는 서블릿

    
*/
import java.io.*;
import java.lang.*;

import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.etri.groupware.*;
import com.etri.groupware.organization.*;
import com.etri.groupware.authentication.* ;
import com.etri.groupware.bbs.*;


public class DepartmentChangeCenterServlet extends HttpServlet
{
	GroupwareControllerInterface groupwareController=null;
	BBSControllerInterface bbsController = null;
	ResultStatus bbsResultStatus = null;
	Properties pro=null;	

	public void init ( ServletConfig config ) throws ServletException 
	{
		super.init ( config ) ;
				
		//그룹웨어 컨트롤러를 생성한다.
		//먼저 프라퍼티를 생성한다.
		pro = new Properties();
		//DB매너저 구현 클래스 이름 설정
		pro.put("OrganizationDBManagerClassName", "PandaSoftOrganizationDBManager");
		pro.put("BBSDBManagerClassName", "PandaSoftBBSDBManager");
		pro.put("EDADBManagerClassName", "PandaSoftEDADBManager");
		pro.put("MailDBManagerClassName", "PandaSoftMailDBManger");
		
		try {
			groupwareController = GroupwareController.init( pro );
			System.out.println("그룹웨어 컨트롤러 생성을 마쳤습니다.");
			
			//게시판 관리 컨트롤러를 가져온다.
			bbsController = groupwareController.createBBSController();
			System.out.println("게시판 컨트롤러 생성도 무사히 마쳤습니다.");
			System.out.println ( "Groupware ShowMenuServlet init () Call..........." ) ;					
		}
		catch(Exception e) { }

	}

	public void destroy ( ) {
		super.destroy();
		DBConnectionManager.instance.release() ;
		System.out.println ( "Groupware UserAuthenticationServlet destroy () Call..........." ) ;
	}

	/*----------------------------------------------------------------- */
	/**
	[메소드이름]: doGet<br>
	[기능]: 부서 발령하기에서 사원의 현재 상태를 보여준다.<br>
	[파라미터]: HttpServletRequest request, HttpServletResponse response<br>
	[호출자] : DepartmentChangeServlet<br>
	*/
	/*--------------------------------------------------------------- */		
	public void doGet ( 
						HttpServletRequest	request , 
						HttpServletResponse	response
																				) throws ServletException, IOException {
		PrintWriter out ;
			
		// ContentType을 text/html로 set한다.
		response.setContentType("text/html;charset=euc-kr") ;
														
		// response의 Writer를 얻는다.
		out = new PrintWriter ( new OutputStreamWriter ( response.getOutputStream ( ) , "EUC-KR" ) ) ;
		
		/////////////////////////////////////////////
		// 세션 확인 부분 - 인증되지 않은 사용자의 경우 Login.html 로 되돌려 보낸다.
		String authenKind = null ;
		String authenId = null ;
		String authenName = null ;
		String authenLoginStatus = null;
		
		HttpSession session = request.getSession ( true );
		authenLoginStatus =  (String)session.getValue("Authentication");
		
		if( (authenLoginStatus == null) || ( !(authenLoginStatus.equals("true")) ) ){
			session.invalidate();
			response.sendRedirect("../Login.html");
		} else {
			authenKind = (String)session.getValue("Kind");
			authenId = (String)session.getValue("Id");
			authenName = (String)session.getValue("Name");   
		}

		System.out.println ( "메뉴 보여주기 서블릿의 response에 대한 프린트라이터가 생성되었습니다." ) ;

		// 넘겨받은 사원의 id를 저장한다.
		String id = request.getParameter ( "id" ) ;
		// 넘겨받은 사원의 부서를 저장한다.
		String department = request.getParameter ( "department" ) ;
		// 넘겨받은 사원의 팀을 저장한다.
		String team = request.getParameter ( "team" ) ;
		// 넘겨받은 사원의 직급을 저장한다.
		String orders = request.getParameter ( "orders" ) ;
		
		out.println ( "<html>" ) ;
		out.println ( "<head>" ) ;
		out.println ( "<style type=\"text/css\">" ) ;
		out.println ( "BODY {font-size:9pt; color:\"#000000\"; line-height:14px;}" ) ;
		out.println ( "A:Link {font-size:9pt; color:\"#000033\"; line-height:14px; text-decoration:none}" ) ;
		out.println ( "A:Visited {font-size:9pt; color:\"#330033\"; line-height:14px; text-decoration:none}" ) ;
		out.println ( "A:Hover {font-size:9pt; color:\"#0000ff\"; line-height:14px; text-decoration:underline}" ) ;
		out.println ( "td {font-size:9pt;}" ) ;
		out.println ( "td.red {font-size:9pt; color:\"#ff0000\"}" ) ;
		out.println ( "td.black {font-size:9pt; color:\"#000000\"}" ) ;
		out.println ( "td.navy {font-size:9pt; color:\"#000066\"}" ) ;
		out.println ( "td.space {font-size:1pt;}" ) ;

		out.println ( "</style>  </HEAD>" ) ;
		out.println ( "<title>버튼이 있는 프레임</title>" ) ;
		out.println ( "<script language=\"javascript\">" ) ;
		out.println ( "function load( ) {" ) ;
		out.println ( "parent.frames[\'right\'].form1.orders.value=\"" + orders + "\";" ) ;
		out.println ( "}</script>" ) ;
		out.println ( "<body bgcolor=lightyellow>" ) ;
		out.println ( "<form name=\"form1\">" ) ;
		out.println ( "<br>" ) ;
		out.println ( "<table align=center width=150>" );
		out.println ( "<tr><td colspan=3 align=\"center\" valign=\"center\"><br>사원의 현재 상태<br><br></td></tr>" ) ;
		
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><br>ID</td></tr>" ) ;		
		out.println ( "<tr><td bgcolor=\"lightyellow\" height=2 width=20%></td><td bgcolor=\"6699cc\" height=2 width=60%><td bgcolor=\"lightyellow\" height=2 width=20%></td></td></tr>" ) ;
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>" + id + "</td></tr>" ) ;
		
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><br>부 서</td></tr>" ) ;
		out.println ( "<tr><td bgcolor=\"lightyellow\" height=2 width=20%></td><td bgcolor=\"6699cc\" height=2 width=60%><td bgcolor=\"lightyellow\" height=2 width=20%></td></td></tr>" ) ;
		if ( department.equals ( "null" ) ) out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>없음</td></tr>" ) ;
		else out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>" + department + "</td></tr>" ) ;
		
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><br>팀</td></tr>" ) ;
		out.println ( "<tr><td bgcolor=\"lightyellow\" height=2 width=20%></td><td bgcolor=\"6699cc\" height=2 width=60%><td bgcolor=\"lightyellow\" height=2 width=20%></td></td></tr>" ) ;
		if ( team.equals ( "null" ) ) out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>없음</td></tr>" ) ;
		else out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>" + team + "</td></tr>" ) ;
		
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><br>직 급</td></tr>" ) ;
		out.println ( "<tr><td bgcolor=\"lightyellow\" height=2 width=20%></td><td bgcolor=\"6699cc\" height=2 width=60%><td bgcolor=\"lightyellow\" height=2 width=20%></td></td></tr>" ) ;
		out.println ( "	<tr><td colspan=3 align=\"center\" valign=\"center\"><font color=red size=3>" + orders + "</td></tr>" ) ;

		out.println ( "</table>" ) ;
		out.println ( "</form></body>" ) ;
	
		out.println ( "</html>" ) ;
		
		out.close ( ) ;
	}
}