/* 
    IntraPMS Project
    사원 등록,검색 폼 제공 서블릿

    
*/
import java.io.* ;
import javax.servlet.* ;
import javax.servlet.http.* ;

import java.util.*;

import java.sql.DriverManager ;
import java.sql.Connection ;
import java.sql.Statement ;
import java.sql.ResultSet ;
import java.sql.SQLException ;

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

public class AddSearchOfficialServlet extends HttpServlet
{
	GroupwareControllerInterface gc = null ;
	OrganizationManagementControllerInterface  omc = null ;
	Properties myPro = null ;

	public void init ( ServletConfig config ) throws ServletException {
		super.init ( config ) ;
		System.out.println ( "AddSearchOfficialServlet init () Call..........." ) ;

		// 그룹웨어 컨트롤러를 생성한다.
		// 먼저 프라퍼티를 생성한다.
		myPro = new Properties ( ) ;
		// DB매니저 구현 클래스 이름 설정
		myPro.put ( "OrganizationDBManagerClassName" , "PandaSoftOrganizationDBManager" ) ;
		myPro.put ( "BBSDBManagerClassName" , "PandaSoftBBSDBManager" ) ;
		myPro.put ( "EDADBManagerClassName" , "PandaSoftEDADBManager" ) ;
		myPro.put ( "MailDBManagerClassName" , "PandaSoftMailDBManager" ) ;
		////////////////////////////////////////
		System.out.println ( "사원 추가와 검색 서블릿의 POST에서 프라퍼티 설정을 무사히 마쳤습니다." ) ;
		
		try {
			gc = GroupwareController.init ( myPro ) ;
			/////////////////////////////////////////////////
			System.out.println ( "사원 추가와 검색 서블릿의 POST에서 사용할 그룹웨어 컨트롤러 생성을 무사히 마쳤습니다." ) ;
			
			// 조직도 관리 컨트롤러를 가져온다.
			omc = gc.createOrganizationManagementController ( ) ;
			///////////////////////////////////////////////////////////
			System.out.println ( "사원 추가와 검색 서블릿의 POST에서 사용할 조직도 관리 컨트롤러 생성도 무사히 마쳤습니다." ) ;
		} catch ( Exception e ) { }
		
	}

	public void destroy ( ) {
		super.destroy();
		DBConnectionManager.instance.release() ;
		System.out.println ( "AddSearchOfficialServlet destroy () Call..........." ) ;
	}
	
	/*----------------------------------------------------------------- */
	/**
	[메소드이름]: doGet<br>
	[기능]: 사원 등록또는 사원 검색의 html폼을 제공한다.<br>
	[파라미터]: HttpServletRequest request, HttpServletResponse response<br>
	[호출자] : 사용자<br>
	*/
	/*--------------------------------------------------------------- */		
	public void doGet (
		HttpServletRequest request ,
		HttpServletResponse response ) throws ServletException , IOException
	{
		PrintWriter out ;
		String head = " 팬더 소프트 " ;
		// Set content type and other response header fields first
		response.setContentType ( "text/html;charset=euc-kr" ) ;
		// then write the data of the response
		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 ();
		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");   
		}
		/////////////////////////////////////////////
		
		// upDep 파라미터로 넘겨받은 부서의 이름을 저장한다.
		String upDep = request.getParameter ( "upDep" ) ;
		upDep = new String ( upDep.getBytes("ISO-8859-1") , "EUC-KR" ) ;
		// team 파라미터로 넘겨받은 팀의 이름을 저장한다.
		String team = request.getParameter ( "team" ) ;
		team = new String ( team.getBytes("ISO-8859-1") , "EUC-KR" ) ;
		
		// response로 보내줄 html페이지의 style 부분을 출력하여 준다.
		out.println ( "<html><head><title>팬더 소프트</title>" ) ;
		out.println ( "<META content=\"text/html; charset=euc-kr\" http-equiv=Content-Type>" ) ;
		out.println ( "<STYLE type=text/css>.form {" ) ;
		out.println ( "	BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; COLOR: #3a1d1d; FACE: 굴림" ) ;
		out.println ( "}" ) ;
		out.println ( "</STYLE>" ) ;
		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 ( "<body>" ) ;
		
		out.println ( "<p align=right><img src=\"/image/우측_관리기능.gif\" alt=\"관리 기능\"></p>" ) ;
		
		out.println ( "<form><table border=0 hspace=1 width=800 cellpadding=3><tr width=800><td width=340>" ) ;	

		if ( request.getParameter ( "add" ) != null ) {
			// 사원 등록 버튼을 눌렀을 경우이다.
			if ( upDep.equals ( "null" ) ) {
				// 부서가 없는 사원 등록의 경우이다. 즉, 사장, 이사 같은 사원이다.
				out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a></font>" ) ;
			} else {
				// 부서가 있는 사원 등록의 경우이다.
				if ( team.equals ( "null" ) ) {
					// 부서가 존재하고 팀은 없는 사원 등록의 경우이다. 즉, 부장, 부장비서 같은 사원이다.
					out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a>  >>  <a href=\"/servlet/ShowAllTeamServlet?page=1&name=" + upDep + "\">" + upDep + "</a></font>" ) ;
				} else {
					// 부서가 팀 모두 존재하는 일반적인 사원이다.
					out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a>  >>  <a href=\"/servlet/ShowAllTeamServlet?page=1&name=" + upDep + "\">" + upDep + "</a>  >>  <a href=\"/servlet/ShowAllOfficialServlet?page=1&name=" + team + "&upDep=" + upDep + "\">" + team + "</a></font>" ) ;
				}				
			}
			out.println ( "</td><td width=460 align=right>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?add=add\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depAdd.src='/image/부서등록-1.jpg'\" onMouseOut=\"document.forms[0].depAdd.src='/image/부서등록.jpg'\"><img name=depAdd src=\"/image/부서등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?search=search\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depSea.src='/image/부서검색-1.jpg'\" onMouseOut=\"document.forms[0].depSea.src='/image/부서검색.jpg'\"><img name=depSea src=\"/image/부서검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?add=add&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temAdd.src='/image/팀등록-1.jpg'\" onMouseOut=\"document.forms[0].temAdd.src='/image/팀등록.jpg'\"><img name=temAdd src=\"/image/팀등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?search=search&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temSea.src='/image/팀검색-1.jpg'\" onMouseOut=\"document.forms[0].temSea.src='/image/팀검색.jpg'\"><img name=temSea src=\"/image/팀검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?add=add&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offAdd.src='/image/사원등록-1.jpg'\" onMouseOut=\"document.forms[0].offAdd.src='/image/사원등록.jpg'\"><img name=offAdd src=\"/image/사원등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?search=search&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offSea.src='/image/사원검색-1.jpg'\" onMouseOut=\"document.forms[0].offSea.src='/image/사원검색.jpg'\"><img name=offSea src=\"/image/사원검색.jpg\"></a>" ) ;
			out.println ( "</td></tr><tr width=800 valign=middle bgcolor=\"#3399ff\"><td colspan=2 width=800><nobr><FONT color=#ffffff>사원 등록 하기</nobr></td></tr></table></form>" ) ;
	
			out.println ( "<p><p><p><p>" ) ;	
			
			// response로 보내줄 html의 자바 스크립트 부분이다.
			out.println ( "<script language=\"JavaScript\">" ) ;
			out.println ( "<!--" ) ;
			out.println ( "	function Check_Form(form)" ) ;
			out.println ( "	{ " ) ;
			out.println ( "	if ( form.id.value.length == 0 )	 alert(\"사원의 ID는 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.password.value.length == 0 )	 alert(\"사원의 패스워드는 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.password2.value.length == 0 )	 alert(\"사원의 패스워드 확인은 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.password2.value != form.password.value )	 alert(\"패스워드가 일치하지 않습니다.!!!!\");" ) ;
			out.println ( "	else if ( form.residentRegistrationNum.value.length == 0 )	 alert(\"사원의 주민등록번호는 필수 항목입니다!!!!\");" ) ;				
			out.println ( "	else if ( form.firstName.value.length == 0 )	 alert(\"사원의 이름은 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.familyName.value.length == 0 )	 alert(\"사원의 성은 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.sex.value.length == 0 )	 alert(\"사원의 성별은 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else if ( form.orders.value.length == 0 )	 alert(\"사원의 직급은 필수 항목입니다!!!!\");" ) ;
			out.println ( "	else {" ) ;
			out.println ( "           var numMonth=form.month.selectedIndex;" ) ;
			out.println ( "           var valueMonth = form.month.options[numMonth].value;" ) ;
			out.println ( "           var numDay=form.day.selectedIndex;" ) ;
			out.println ( "           var valueDay=form.day.options[numDay].value;" ) ;
			out.println ( "           var numYear=form.year.selectedIndex;" ) ;
			out.println ( "           var valueYear=form.year.options[numYear].value;" ) ;
			out.println ( "              if((((form.year.options[numYear].value % 4) == 0) && ((form.year.options[numYear].value % 100) != 0) || ((form.year.options[numYear].value % 400) == 0))){" ) ;
			out.println ( "                     var temp = 1;" ) ;
			out.println ( "              }" ) ;
			out.println ( "              else{" ) ;
			out.println ( "                     var temp = 2;" ) ;
			out.println ( "              }" ) ;
			out.println ( "	      if((form.month.options[numMonth].value == 1) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"1월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "        else if((form.month.options[numMonth].value == 2) && (temp == 1) && (form.day.options[numDay].value > 29)){" ) ;
			out.println ( "                  alert(\"윤년 2월은 1에서 29일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 2) && (temp == 2) && (form.day.options[numDay].value >28)){" ) ;
			out.println ( "                  alert(\"평년 2월은 1에서 28일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 3) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"3월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 4) && ((form.day.options[numDay].value > 30) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"4월은 1에서 30일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 5) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"5월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 6) && ((form.day.options[numDay].value > 30) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"6월은 1에서 30일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 7) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"7월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 8) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"8월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 9) && ((form.day.options[numDay].value > 30) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"9월은 1에서 30일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 10) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"10월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 11) && ((form.day.options[numDay].value > 30) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"11월은 1에서 30일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else if((form.month.options[numMonth].value == 12) && ((form.day.options[numDay].value > 31) || (form.day.options[numDay].value < 1))){" ) ;
			out.println ( "                  alert(\"12월은 1에서 31일 사이입니다.\");" ) ;
			out.println ( "              }   " ) ;
			out.println ( "              else form.submit(); " ) ;
			out.println ( "        }		" ) ;
			out.println ( "	} " ) ;
			out.println ( "function Back_Click()" ) ;
			out.println ( "	{ " ) ;
			out.println ( " history.back() ; " ) ;
			out.println ( "	} " ) ;
			out.println ( "function img_Click()" ) ;
			out.println ( "	{ " ) ;
			out.println ( "    var file ; " ) ;
			out.println ( "    document.all.img.style.display=(document.all.img.style.display=='none')?'':'none';" ) ;
			out.println ( "    file = \"file:///\" + document.forms[1].image.value ; " ) ;
			out.println ( "		document.forms[1].img.src = file ; " ) ;
			out.println ( "	} " ) ;
			out.println ( "function fileView()" ) ;
			out.println ( "	{ " ) ;
			out.println ( "    document.all.file.style.display=(document.all.file.style.display=='none')?'':'none';" ) ;
			out.println ( "    document.all.view.style.display=(document.all.view.style.display=='none')?'':'none';" ) ;
			out.println ( "	} " ) ;
			out.println("function selectTeam()");
			out.println("{ ");
			out.println("	for ( var j=0 ; document.forms[1].team[j] != null ; )");
			out.println("	{");
			out.println("		document.forms[1].team[j] = null ;");
			out.println("	}");
			out.println("");
			out.println("	var teamId = document.forms[1].department.value ;");
			out.println("	var department = teamId.indexOf( \";\" );");
			out.println("	teamId = teamId.substring( department +1, teamId.length );");
			out.println("	var length = teamId.length;");
			out.println("");
			out.println("	if ( length == 0 )");
			out.println("	{");
			out.println("		alert ( \"이 부서에는 팀이 존재하지 않습니다.\" ) ;");
			out.println("	}");
			out.println("	else");
			out.println("	{");
			out.println("		var element = document.createElement(\"OPTION\");");
			out.println("		element.text = \"없음\" ;");
			out.println("		element.value = \"null\" ;");
			out.println("		document.forms[1].team.options.add( element ) ;");
			out.println("		for ( var i=0; length > i ;) {");
			out.println("			var position = teamId.indexOf ( \";\", i ) ;");
			out.println("			var temp = teamId.substring ( i , position ) ;");
			out.println("			if ( temp != '') { ");
			out.println("			var newElement = document.createElement(\"OPTION\");");
			out.println("			newElement.text = temp ;");
			out.println("			newElement.value = temp ;");
			out.println("			document.forms[1].team.options.add( newElement ) ; }");
			out.println("			i = position + 1;");
			out.println("		}");
			out.println("	}");
			out.println("}");
			out.println ( "//-->" ) ;
			out.println ( "</script>" ) ;
	
			// 새로운 사원을 등록할 경우 이미지 파일을 업로드 해야 하므로 method=post가 되어야 한다.
			// 또한 enctype도 multipart/form-data로 설정한다.
			out.println ( "<form action=\"/servlet/ShowAllOfficialServlet\" method=\"POST\" enctype=\"multipart/form-data\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"page\" value=\"1\">" ) ;		
			out.println ( "<input type=\"hidden\" name=\"form\" value=\"form\">" ) ;	
			out.println ( "<input type=\"hidden\" name=\"update\" value=\"no\">" ) ;	
			out.println ( "<input type=\"hidden\" name=\"trueadd\" value=\"trueadd\">" ) ;
			out.println ( "<TABLE align=center border=0 cellPadding=2 cellSpacing=1 width=700>" ) ;
			out.println ( "  <TBODY><TR>  " ) ;
			out.println ( "    <TD bgColor=#3399ff><FONT color=#ffffff size=2><B>[ 새로운 사원 등록하기 ]</B></FONT> " ) ;
			out.println ( "  </TD></TR></TBODY></TABLE>" ) ;
			out.println ( "<CENTER><TABLE bgColor=#cccccc border=0 cellPadding=1 cellSpacing=1 width=700>" ) ;
			
			out.println ( "<tr bgColor=#f7f7f7>" ) ;
			// 아이디 입력하기.
			out.println ( "<td width=150><IMG src=\"/image/icon_red.gif\"><FONT size=2> ID</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"15\" name=\"id\"></td>" ) ;
			// 패스워드 입력하기
			out.println ( "<td width=150><IMG src=\"/image/icon_red.gif\"><FONT size=2> 패스워드</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"password\" size=\"10\" name=\"password\"><FONT size=1 color=red>&nbsp;*확인</font><input class=form type=\"password\" size=\"10\" name=\"password2\"></td>" ) ;			
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			
			// 주민 등록번호
			out.println ( "<td ><IMG src=\"/image/icon_red.gif\"><FONT size=2> 주민등록번호</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"15\" name=\"residentRegistrationNum\"></td>" ) ;
			// 성별
			out.println ( "<td ><IMG src=\"/image/icon_red.gif\"><FONT size=2> 성별</font></td>" ) ;
			out.println ( "<td colspan=2><select class=form name=\"sex\">" ) ;
			out.println ( "<option value=\"1\">남자</option><option value=\"2\">여자</option></select></td>" ) ;			
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			
			// 성
			out.println ( "<td ><IMG src=\"/image/icon_red.gif\"><FONT size=2> 성</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"10\" name=\"familyName\"></td>" ) ;			
	
			// 이름
			out.println ( "<td ><IMG src=\"/image/icon_red.gif\"><FONT size=2> 이름</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"10\" name=\"firstName\"></td>" ) ;
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
				
			// 직급
			out.println ( "<td ><IMG src=\"/image/icon_red.gif\"><FONT size=2> 직급</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"10\" name=\"orders\"></td>" ) ;
			
			// 나이 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 나이</font></td>" ) ;
			out.println ( "<td colspan=2><select class=form name=\"age\">" ) ;
			for ( int a = 18 ; a < 51 ; a++ ) {
				out.println ( "<option value=\"" + a + "\">" + a + "</option>" ) ;
			}
			out.println ( "</select></td>" ) ;						
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
				
			// 부서 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 부서</font></td>" ) ;
			out.println ( "<td colspan=2 valign=middle><select style=\"width=120\" name=\"department\" onChange='selectTeam()'>" ) ;
			out.println ( "<option value='null;;'>없음</option>" ) ;
			// 데이타 베이스에서 조직도 트리의 내용 즉, 부서와 팀을 가져온다.
			String[][] departmentAndTeam = omc.getOrganizationTree ( ) ;
			// 부서 리스트
			for ( int o=0 ; !(departmentAndTeam[o][0].equals("null")) ; o++ ) 
			{
				String teamList = departmentAndTeam[o][0] + ";";
				//팀 리스트
				for ( int p=1 ; !(departmentAndTeam[o][p].equals("null")) ; p++ )
					teamList = teamList + departmentAndTeam[o][p] + ";";
					out.println("<option value='" + teamList + "'>"+ departmentAndTeam[o][0]+"</option> ");
				}
				out.println ( "</select></td>" ) ;
				
			// 팀 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 팀</font></td>" ) ;
			out.println ( "<td colspan=2 valign=middle><select style=\"width=120\" name=\"team\">" ) ;
			out.println ( "<option value='null'>없음</option>" ) ;
			out.println ( "</select></td>" ) ;
			
			// 전화번호 입력하기
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 전화번호</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"20\" name=\"phoneNumber\"></td>" ) ;
			// 팩스번호 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 팩스 번호</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"20\" name=\"faxNumber\"></td>" ) ;
			
			// 휴대폰 입력하기
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 휴대폰</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"20\" name=\"personalPhone\"></td>" ) ;
			// 집 전화번호 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 집 전화번호</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"20\" name=\"homePhoneNumber\"></td>" ) ;
			
			// 주소 입력하기
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 주소</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"25\" name=\"address\"></td>" ) ;
			// 우편 번호 입력하기
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 우편번호</font></td>" ) ;
			out.println ( "<td colspan=2><input class=form type=\"text\" size=\"20\" name=\"zipCode\"></td>" ) ;
			
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 권한 설정</font></td>" ) ;
			out.println ( "<td colspan=2><input type=\"radio\" checked name=\"userKind\" value=\"0\"> 사용자" ) ;
			out.println ( "<input type=\"radio\" name=\"userKind\" value=\"1\"> 관리자</td>" ) ;			
			// 입사일 입력하기
			out.println ( "<td><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 입사일</font></td>" ) ;
			out.println ( "<td colspan=2><p><select class=form name=\"year\">" ) ;
			for ( int y = 1990 ; y < 2021 ; y++ ) {
				out.println ( "<option value=\"" + y + "\">" + y + "</option>" ) ;
			}
			out.println ( "</select>" ) ;
			out.println ( "<select class=form name=\"month\">" ) ;
			for ( int m = 1 ; m < 13 ; m++ ) {
				out.println ( "<option value=\"" + m + "\">" + m + "</option>" ) ;
			}
			out.println ( "</select>" ) ;
			out.println ( "<select class=form name=\"day\">" ) ;
			for ( int d = 1 ; d < 32 ; d++ ) {
				out.println ( "<option value=\"" + d + "\">" + d + "</option>" ) ;
			}
			out.println ( "</select></p></td>" ) ;
			
			
			// 주요업무 입력하기
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 주요 업무</font></td>" ) ;
			out.println ( "<td colspan=5><textarea class=form name=\"weightWork\" rows=\"2\" cols=\"60\"></textarea></td>" ) ;
			
			// 기타 사항 입력하기
			out.println ( "</tr><tr bgColor=#f7f7f7>" ) ;
			out.println ( "<td ><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 기타 사항</font></td>" ) ;
			out.println ( "<td colspan=5><textarea class=form name=\"others\" rows=\"2\" cols=\"60\"></textarea></td>" ) ;
			out.println ( "</tr>" ) ;
			
			// 사진 입력하기
			out.println ( "<TR bgColor=#f7f7f7><td><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 사진</font></td>" ) ;
			// 파일 업로드 하기.
			out.println ( "<td colspan=5 valign=center>" ) ;
			out.println ( "<INPUT type=button name=fileview value=\"사진 첨부하기\" onClick=\"fileView()\">" ) ;
			out.println ( "<input STYLE=\"display:none\" id=file class=form type=\"file\" size=20 name=\"image\"><input type=\"hidden\" name=\"box\" value=\"box\">" ) ;
			out.println ( "<input STYLE=\"display:none\" id=view class=form name=\"but1\" type=\"button\" value=\"선택한 이미지 보기\" onClick=\"img_Click()\">" ) ;
			// 파일 업로드를 위한 파일 다이얼 로그 박스가 나오는 버튼이다.
			out.println ( "<img STYLE=\"display:none\" id=img name=img border=\"2\"></td>" ) ;
			out.println ( "</tr>" ) ;
			
			// 마지막 경고 메세지(?)를 보여준다.
			out.println ( "<TR bgColor=#f7f7f7><TD align=right colSpan=6><FONT color=red size=2><IMG src=\"/image/icon_red.gif\"> \"붉은색\"아이콘 항목은 반드시 입력하셔야 합니다. </FONT></TD></TR>" ) ;
			
			out.println ( "</TABLE></CENTER>" ) ;
			out.println ( "<BR><CENTER><TABLE border=0 cellPadding=2 cellSpacing=1>" ) ;
			out.println ( "  <TR><TD width=680 align=right>" ) ;
			out.println ( "<INPUT type=button name=add value=\"등록 하기\" onClick=\"Check_Form(this.form)\">" ) ;
			out.println ( "<INPUT type=reset name=reset value=\"다시 쓰기\">" ) ;
			out.println ( "<INPUT type=button name=back value=\"되돌아 가기\" onClick=\"Back_Click()\">" ) ;
			out.println ( "</TD></TR></TABLE></CENTER></FORM>" ) ;
		} else if ( request.getParameter ( "search" ) != null ) {
			// 사원 검색 버튼을 눌렀을 경우이다.		
	
			out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a></font>" ) ;
			out.println ( "</td><td width=460 align=right>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?add=add\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depAdd.src='/image/부서등록-1.jpg'\" onMouseOut=\"document.forms[0].depAdd.src='/image/부서등록.jpg'\"><img name=depAdd src=\"/image/부서등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?search=search\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depSea.src='/image/부서검색-1.jpg'\" onMouseOut=\"document.forms[0].depSea.src='/image/부서검색.jpg'\"><img name=depSea src=\"/image/부서검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?add=add&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temAdd.src='/image/팀등록-1.jpg'\" onMouseOut=\"document.forms[0].temAdd.src='/image/팀등록.jpg'\"><img name=temAdd src=\"/image/팀등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?search=search&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temSea.src='/image/팀검색-1.jpg'\" onMouseOut=\"document.forms[0].temSea.src='/image/팀검색.jpg'\"><img name=temSea src=\"/image/팀검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?add=add&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offAdd.src='/image/사원등록-1.jpg'\" onMouseOut=\"document.forms[0].offAdd.src='/image/사원등록.jpg'\"><img name=offAdd src=\"/image/사원등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?search=search&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offSea.src='/image/사원검색-1.jpg'\" onMouseOut=\"document.forms[0].offSea.src='/image/사원검색.jpg'\"><img name=offSea src=\"/image/사원검색.jpg\"></a>" ) ;
			out.println ( "</td></tr><tr width=800 valign=middle bgcolor=\"#3399ff\"><td colspan=2 width=800><nobr><FONT color=#ffffff>사원 검색하기</nobr></td></tr></table></form>" ) ;
		
	
			out.println ( "<p><p><p><p>" ) ;	
			
			out.println ( "<script language=\"JavaScript\">" ) ;
			out.println ( "<!--" ) ;
			out.println ( "	function Check_Form(form)" ) ;
			out.println ( "	{ " ) ;
			out.println ( "	if ( form.firstName.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else if ( form.weightWork.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else if ( form.ecd.checked == true )	 form.submit();" ) ;				
			out.println ( "	else if ( form.address.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else if ( form.sexok.checked == true )	 form.submit();" ) ;
			out.println ( "	else if ( form.orders.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else if ( form.others.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else if ( form.id.value.length != 0 )	 form.submit();" ) ;
			out.println ( "	else alert(\"검색 조건 중에서 하나는 꼭 입력해야 합니다!!!!\");" ) ;
			out.println ( "	} " ) ;
			out.println ( "function Back_Click()" ) ;
			out.println ( "	{ " ) ;
			out.println ( "		history.back();" ) ;
			out.println ( "	} " ) ;
			out.println ( "//-->" ) ;
			out.println ( "</script>" ) ;
			out.println ( "<form action=\"/servlet/ShowAllOfficialServlet\" method=\"GET\">" ) ;
			out.println ( "<TABLE align=center border=0 cellPadding=2 cellSpacing=1 width=700>" ) ;
			out.println ( "  <TBODY>  <TR>" ) ;
			out.println ( "    <TD bgColor=#3399ff><FONT color=#ffffff size=2><B>[ 사원 검색하기 ]</B></FONT> " ) ;
			out.println ( "  </TD></TR></TBODY></TABLE>" ) ;
			out.println ( "<CENTER><TABLE bgColor=#cccccc border=0 cellPadding=1 cellSpacing=1 width=700>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> ID</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><INPUT class=form name=id size=20> </FONT></TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 이름</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><INPUT class=form name=firstName size=10></FONT></TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 성별</font></td>" ) ;
			out.println ( "<TD colSpan=3 width=380><FONT face=굴림체><select class=form name=\"sex\">" ) ;
			out.println ( "<option value=\"1\">남자</option><option value=\"2\">여자</option></select>" ) ;
			out.println ( "<input type=\"checkbox\" name=\"sexok\" value=\"sexok\">성별 검색</td></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 직급</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><INPUT class=form name=orders size=10> </FONT></TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 주소</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><INPUT class=form name=address size=50></FONT></TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 입사일</font></td>" ) ;
			out.println ( "<td><p><select name=\"year\">" ) ;
			for ( int y = 1990 ; y < 2021 ; y++ ) {
				out.println ( "<option value=\"" + y + "\">" + y + "</option>" ) ;
			}
			out.println ( "</select>" ) ;
			out.println ( "<select name=\"month\">" ) ;
			for ( int m = 1 ; m < 13 ; m++ ) {
				out.println ( "<option value=\"" + m + "\">" + m + "</option>" ) ;
			}
			out.println ( "</select>" ) ;
			out.println ( "<select name=\"day\">" ) ;
			for ( int d = 1 ; d < 32 ; d++ ) {
				out.println ( "<option value=\"" + d + "\">" + d + "</option>" ) ;
			}
			out.println ( "</select>" ) ;
			out.println ( "<input type=\"checkbox\" name=\"ecd\" value=\"ecd\">입사일 검색" ) ;
			out.println ( "<input type=\"radio\" checked name=\"boa\" value=\"b\">전" ) ;
			out.println ( "<input type=\"radio\" name=\"boa\" value=\"a\">후" ) ;
			out.println ( "</p></td></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 주요 업무</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><textarea class=form name=weightWork rows=3 cols=60></textarea></FONT> </TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_dot1.gif\"><FONT size=2> 기타 사항</FONT></DIV></TD><TD colSpan=3 width=380><FONT face=굴림체><textarea class=form name=others rows=4 cols=60></textarea></FONT> </TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD width=120><DIV align=left><IMG src=\"/image/icon_red.gif\"><FONT size=2> 검색 방법</FONT></DIV></TD><TD align=center colSpan=3 width=410><FONT face=굴림체><input type=\"radio\" name=\"orAnd\" value=\"or\" checked>OR ( 또는 ) 검색<br><input type=\"radio\" name=\"orAnd\" value=\"and\">AND ( 그리고 ) 검색</FONT> </TD></TR>" ) ;
			out.println ( "<TR bgColor=#f7f7f7><TD align=right colSpan=4><FONT color=red size=2><IMG src=\"/image/icon_dot1.gif\"> \"검은색\"아이콘 항목중 반드시 하나는 입력하셔야 합니다. </FONT></TD></TR>" ) ;
			out.println ( "</table></CENTER>" ) ;
			
			out.println ( "<BR><CENTER><TABLE border=0 cellPadding=2 cellSpacing=1>" ) ;
			out.println ( "  <TR><TD width=680 align=right>" ) ;
			out.println ( "<input type=\"hidden\" name=\"form\" value=\"form\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"search\" value=\"search\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"name\" value=\"" + team + "\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"upDep\" value=\"" + upDep + "\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"page\" value=\"1\">" ) ;
			out.println ( "<INPUT type=button name=search value=\"검색 하기\" onClick=\"Check_Form(this.form)\">" ) ;
			out.println ( "<INPUT type=reset name=reset value=\"다시 쓰기\">" ) ;
			out.println ( "<INPUT type=button name=back value=\"되돌아 가기\" onClick=\"Back_Click()\">" ) ;
			out.println ( "</TD></TR></TABLE></CENTER></FORM>" ) ;
		}
		out.println ( "</body></html>" ) ;		
		out.close ( ) ;
	}
}


			
		