/* 
    ETRI IntraPMS Project
    Option 설정을 위한Servlet

    
*/

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

import com.etri.groupware.*;
import com.etri.groupware.eda.*;

public class EDAOptionServlet extends HttpServlet{

	GroupwareControllerInterface groupwareController = null;
	EDAControllerInterface edaController = null;
	Properties pro=null;
			
	public void init( ServletConfig sc ) throws ServletException{
		super.init(sc);
		
		pro = new Properties();
		pro.put("DriverName","weblogic.jdbc.mssqlserver4.Driver");
		pro.put("DBServer","jdbc:weblogic:mssqlserver4:GWDB@Server:1433");
		pro.put("User","sa");
		pro.put("Password","");
		
		pro.put("OrganizationDBManagerClassName","PandaSoftOrganizationDBManager");
		pro.put("BBSDBManagerClassName","PandaSoftBBSDBManager");
		pro.put("EDADBManagerClassName","PandaSoftEDADBManager");
		pro.put("MailDBManagerClassName","PandaSoftMailDBManager");
		
		try{
			groupwareController = GroupwareController.init( pro );
			System.out.println("그룹웨어 컨트롤러 생성을 마쳤습니다.");
			
			edaController = groupwareController.createEDAController();
			System.out.println("전자결재 컨트롤러 생성도 무사히 마쳤습니다.");	
		}
		catch( Exception e){
			System.out.println( e.toString() );
		}
	}

	public void destroy(){
		System.out.println("EDAOptionServlet Destroy() 호출");
		super.destroy();
		DBConnectionManager.instance.release();
		System.out.println("EDAOptionServlet Destroy() 완료");
	}


/*----------------------------------------------------------------- */
/**
 [메소드이름]: doGet<br>
 [기능]: Option설정을 위한 화면을 보여준다.<br>
 [파라미터]: HttpServletRequest req,HttpServletResponse res<br>
 [호출자] : 사용자<br>
 */
/*--------------------------------------------------------------- */	
	public void doGet(HttpServletRequest req,HttpServletResponse res)
	 throws ServletException,IOException{
	 
	 	HttpSession session = req.getSession(true);
	 	
	 	PrintWriter out;
	 	
		res.setContentType("text/html;charset=edu-kr");
		out = new PrintWriter( new OutputStreamWriter(
		 res.getOutputStream(),"EUC-KR"));
		 
		boolean authentication = false;
		
		String id = null;
		String name = null;		
		Map course = new HashMap();
		if((session.isNew()))
		{
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		else if(session.getValue("Authentication").equals("true")){
			authentication = true;
			id = (String)session.getValue("Id");
			name = (String)session.getValue("Name");
		}
		else{
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		
		if(authentication){
			out.println("<html>");
			out.println("<head>");
			out.println("<title>전자 결재 개인 설정</title>");
			out.println("<SCRIPT LANGUAGE=\"JavaScript\">");
			out.println("function EDALineSelection() {");
			out.println("myWin = window.open ( \"/EDALineSelection.html\" , \"결재선선택\" , \"width=650,height=450,scrollbars=1,copyHistory=1\" )");	
			out.println("}");

			out.println("function result( d ) {");
			out.println("var allOfficial = arguments[0] ;");
			out.println("var e1 = document.createElement(\"OPTION\")" );
			out.println("e1.text = allOfficial ;");
			out.println("e1.value = allOfficial ;");
			out.println("e1.selected = true ;");
			out.println("document.form1.defaultPath.options.add(e1);");
			out.println("myWin.close();");
			out.println("}");
			
			out.println("</SCRIPT>"); 
			
			out.println("<body text=\"blue\" " +
			 "link=\"blue\" vlink=\"black\" alink=\"#FF2020\">");

			out.println("<p align=right><img src=\'../image/우측_기안결재.gif\'></p>");

			out.println("<p><font size=\"2\"><br></font></p>");
			out.println("<p align=\"center\"><font size=\"4\" color=\"gray\"> " +
			 "<b>사용자 환경 설정</b></font></p>");

			out.println("<p><font size=\"2\"><hr width=\"600\"> </font>");
			out.println("<div align=\"center\">"+
			 "<table border=\"0\" width=\"600\">");
			
			out.println("<form method=\"post\" name=\"form1\" action=\"/servlet/EDAOptionServlet\">");
    			
    			try{
    				EDAOption option = edaController.loadEDAOption( name + "(" + id + ")" );
    				
	    			course = edaController.listApprovalCourse ( name + "(" + id + ")" );
	    			String[] courseArray = new String[ course.size() ];
	    			String[] courseView = new String[ course.size() ];
	    			for( int i=0 ; i < courseArray.length ; i++ ){
	    				courseArray[i] = "";
	    				courseView[i] = "";
	    			}
	    			List courseList = new ArrayList();
	    			int count = 0;
	    			for( Iterator i = course.entrySet().iterator(); i.hasNext() ; count++ ){
	    				Map.Entry e = (Map.Entry) i.next(); 
	    				courseList = (List)e.getValue();
	    				ApprovalCourse path = new ApprovalCourse();
	    				for ( int j = 0 ; j < courseList.size() ; j++ ){
	    					path = ( ApprovalCourse ) courseList.get( j );
	    					if( path.gettype() == ApprovalCourse.SUBMITAPPROVAL ){
	    						courseArray[ count ] = courseArray[ count ] + path.getpersonID() + "," + "결재" + ";" ;
	    						StringTokenizer st = new StringTokenizer ( path.getpersonID() , "(" );
	    						courseView[ count ] = courseView[ count ] + "->" + st.nextToken() + "(" + "결재" + ")"; 
	    					}
	    					else if ( path.gettype() == ApprovalCourse.SUBMITINFORM ){
	    						courseArray[ count ] = courseArray[ count ] + path.getpersonID() + "," + "통보" + ";" ;
	    						StringTokenizer st = new StringTokenizer ( path.getpersonID() , "(" );
	    						courseView[ count ] = courseView[ count ] + "->" + st.nextToken() + "(" + "통보" + ")";	    						
	    					}
	    				}
	    				
	    			}
	    			out.println("<tr>");
	        		out.println("<td width=\"250\"  bgcolor=\"#C7E4FF\">"+
	        		 "<p><font size=\"2\">&nbsp;&nbsp;기본 결재경로?</font></td>");
	        		out.println("<td colspan=\"2\"><p><font size=\"2\"><select name=\"defaultPath\">" );
				for( int i = 0 ; i < courseArray.length ; i++ ){
					System.out.println( "DB에 저장되어 있는 결재 경로 : "+courseArray[i]);
					if( option.getdefaultPath().equals( courseArray[i] )){
						out.println("<option value=\'" + courseArray[i] + "\' selected >" + courseView[i] + "</option>");
						System.out.println("기본 결재 경로로 저장한 경로");
					}
					else
						out.println("<option value=\'" + courseArray[i] + "\'>" + courseView[i] + "</option>");
				}
				out.println("</select>");

				out.println("<input type=\"button\" value=\"경로설정\" onClick=\"EDALineSelection()\">");
				out.println("<input type=\"checkbox\" name=\"deleteButton\" value=\"deletePath\" >&nbsp;삭제 </td>");
	    			out.println("</tr>");
	    			
	    			out.println("<tr>");
	        		out.println("<td width=\"250\"  bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;페이지당 게시물의 수?</font></td>");
	        		out.println("<td><p align=\"center\"><font size=\"2\">" +
	        		 "<input type=\"text\" name=\"numOfItem\" value=\"" + option.getnumOfItem() + "\" size=\"5\">"+
	        		 "</font><font size=\"2\" color=\"black\">개</font><font size=\"2\"> " +
	            		 "</font></td>");
	            		out.println("<td><p>&nbsp;</td>");
				out.println("</tr>");
	    
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;결재함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"ingBoxSort\">");
	        		if( option.getingBoxSort().equals("initDay")){
	            			out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            			out.println("<option value=\"initPersonID\">작성자</option>");
	            			out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            			System.out.println("기존에는 결재함 정렬 키워드가 날짜임");
	            		}
	            		else if(option.getingBoxSort().equals("initPersonID")){
	            			out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            			out.println("<option selected value=\"initPersonID\">작성자</option>");
	            			out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            			System.out.println("기존에는 결재함 정렬 키워드가 작성자임");
	            		}
	            		else{ 	            			
	            			out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            			out.println("<option value=\"initPersonID\">작성자</option>");
	            			out.println("<option selected value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            			System.out.println("기존에는 결재함 정렬 키워드가 제목임");
	            		}
	            		
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">");
	            		if( option.getingSortMethod().equals("ASC")){
	            		 out.println("<input type=\"radio\" name =\"ingSortMethod\" value=\"ASC\" checked>오 름"+
	            		 "<input type=\"radio\" name=\"ingSortMethod\" value=\"DESC\" >내 림</font></td>");
	            		}
	            		else{
	            		 out.println("<input type=\"radio\" name =\"ingSortMethod\" value=\"ASC\" >오 름"+
	            		 "<input type=\"radio\" name=\"ingSortMethod\" value=\"DESC\" checked>내 림</font></td>");
	            		}
	    			out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;완결함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"completeBoxSort\">");
	        		if( option.getcompleteBoxSort().equals("initDay")){
		            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
		            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
		            		System.out.println("기존에는 완결함 정렬 키워드가 날짜");
		            	}
		            	else{
		            		out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
		            		out.println("<option selected value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
		            		System.out.println("기존에는 완결함 정렬 키워드가 제목");
		            	}
		            	
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">");
	            		if( option.getcompleteSortMethod().equals("ASC")){
		            		out.println("<input type=\"radio\" name =\"completeSortMethod\" value=\"ASC\" checked>오 름"+
		            		 "<input type=\"radio\" name=\"completeSortMethod\" value=\"DESC\">내 림</font></td>");
		            	}
				else{
					out.println("<input type=\"radio\" name =\"completeSortMethod\" value=\"ASC\" >오 름"+
		            		 "<input type=\"radio\" name=\"completeSortMethod\" value=\"DESC\" checked>내 림</font></td>");
				}
	        		out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;반려함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"rejectBoxSort\">");
	            		if( option.getrejectBoxSort().equals("initDay")){
	            			out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            			out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            			System.out.println("기존에는 반려함 정렬 키워드가 날짜였음");
	            		}
	            		else {
	            			out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            			out.println("<option selected value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            			System.out.println("기존에는 반려함 정렬 키워드가 제목였음");
	            		}
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">");
	            		if( option.getrejectSortMethod().equals("DESC")){
		            		out.println("<input type=\"radio\" name =\"rejectSortMethod\" value=\"ASC\">오 름"+
		            		 "<input type=\"radio\" name=\"rejectSortMethod\" value=\"DESC\" checked>내 림</font></td>");
		            	}
		            	else{
		            		out.println("<input type=\"radio\" name =\"rejectSortMethod\" value=\"ASC\" checked>오 름"+
		            		 "<input type=\"radio\" name=\"rejectSortMethod\" value=\"DESC\" >내 림</font></td>");
	    			}
	    			out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;공용 문서함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"publicBoxSort\">");
	            		if( option.getpublicBoxSort().equals("initDay")){
		            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
		            		out.println("<option value=\"initPersonID\">작성자</option>");
		            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
		            		System.out.println("기존에는 공용 문서함 정렬 키워드가 날짜 였음");
		            	}
	            		else if( option.getpublicBoxSort().equals("initPersonID")){
		            		out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
		            		out.println("<option selected value=\"initPersonID\">작성자</option>");
		            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
		            		System.out.println("기존에는 공용 문서함 정렬 키워드가 작성자 였음");
		            	}
	            		else{
		            		out.println("<option value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
		            		out.println("<option value=\"initPersonID\">작성자</option>");
		            		out.println("<option selected value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
		            		System.out.println("기존에는 공용 문서함 정렬 키워드가 제목 였음");
		            	}

		            	
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">");
	            		if( option.getpublicSortMethod().equals("DESC")){
		            		out.println("<input type=\"radio\" name =\"publicSortMethod\" value=\"ASC\">오 름"+
		            		 "<input type=\"radio\" name=\"publicSortMethod\" value=\"DESC\" checked>내 림</font></td>");
		            	}
		            	else{
					out.println("<input type=\"radio\" name =\"publicSortMethod\" value=\"ASC\" checked >오 름"+
		            		 "<input type=\"radio\" name=\"publicSortMethod\" value=\"DESC\" >내 림</font></td>");
		            	}
		    		out.println("</tr>");
	
				out.println("</table></div>");
				out.println("<p align=\"center\"><font size=\"2\">"+
				 "<hr width=\"600\"></font></p>");
				out.println("<p align=\"center\"><font size=\"2\">"+
				 "<input type=\"submit\" value=\" 설 정 \" >" );
				out.println("<input type=\"reset\" value=\" 취 소 \"> </font></p></form>");
			}
			catch ( Exception e){

	    			
	    			out.println("<tr>");
	        		out.println("<td width=\"250\"  bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;페이지당 게시물의 수?</font></td>");
	        		out.println("<td><p align\"center\"><font size=\"2\">" +
	        		 "<input type=\"text\" name=\"numOfItem\" value=\"15\" size=\"5\">"+
	        		 "</font><font size=\"2\" color=\"black\">개</font><font size=\"2\"> " +
	            		 "</font></td>");
	            		out.println("<td><p>&nbsp;</td>");
				out.println("</tr>");
	    
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;결재함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"ingBoxSort\">");
	            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            		out.println("<option value=\"initPersonID\">작성자</option>");
	            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">"+
	            		 "<input type=\"radio\" name =\"ingSortMethod\" value=\"ASC\">오 름"+
	            		 "<input type=\"radio\" name=\"ingSortMethod\" value=\"DESC\" checked>내 림</font></td>");
	    			out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;완결함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"completeBoxSort\">");
	            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">"+
	            		 "<input type=\"radio\" name =\"completeSortMethod\" value=\"ASC\">오 름"+
	            		 "<input type=\"radio\" name=\"completeSortMethod\" value=\"DESC\" checked>내 림</font></td>");
	        		out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;반려함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"rejectBoxSort\">");
	            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">"+
	            		 "<input type=\"radio\" name =\"rejectSortMethod\" value=\"ASC\">오 름"+
	            		 "<input type=\"radio\" name=\"rejectSortMethod\" value=\"DESC\" checked>내 림</font></td>");
	    			out.println("</tr>");
	
	    			out.println("<tr>");
	        		out.println("<td width=\"250\" bgcolor=\"#C7E4FF\"><p>"+
	        		 "<font size=\"2\">&nbsp;&nbsp;공용 문서함 정렬 키워드?</font></td>");
	        		out.println("<td width=\"121\"><p align=\"center\"><font size=\"2\">"+
	        		 "<select name=\"publicBoxSort\">");
	            		out.println("<option selected value=\"initDay\">날&nbsp;&nbsp;&nbsp;짜</option>");
	            		out.println("<option value=\"initPersonID\">작성자</option>");
	            		out.println("<option value=\"title\">제&nbsp;&nbsp;&nbsp;목</option></select></font></td>");
	            		out.println("<td width=\"114\"><p><font size=\"2\" color=\"black\">"+
	            		 "<input type=\"radio\" name =\"publicSortMethod\" value=\"ASC\">오 름"+
	            		 "<input type=\"radio\" name=\"publicSortMethod\" value=\"DESC\" checked>내 림</font></td>");
	    			out.println("</tr>");
	
				out.println("</table></div>");
				out.println("<p align=\"center\"><font size=\"2\">"+
				 "<hr width=\"600\"></font></p>");
				out.println("<p align=\"center\"><font size=\"2\">"+
				 "<input type=\"submit\" value=\" 설 정 \" >" );
				out.println("<input type=\"reset\" value=\" 취 소 \"> </font></p></form>");

			}

			out.println("</body>");

			out.println("</html>"); 
		
		} else {
			//사용자 인증에 실패하였습니다.
			res.sendRedirect("../Login.html");
		}
		
		out.close();
	}
	
/*----------------------------------------------------------------- */
/**
 [메소드이름]: doPost<br>
 [기능]: Option을 설정하여 준다.<br>
 [파라미터]: HttpServletRequest req,HttpServletResponse res<br>
 [호출자] : this<br>
 */
/*--------------------------------------------------------------- */		
	public void doPost( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException {
		//session확인 하는 곳
		HttpSession session = req.getSession( true );
		
		res.setContentType("text/html;charset=euc-kr");
		PrintWriter out = new PrintWriter( new OutputStreamWriter ( res.getOutputStream(), "EUC-KR"));
		

		boolean authentication = false;
		
		String id = null;

		String name = null;

		if( session.isNew() ){
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		else if(session.getValue("Authentication").equals("true")){
			authentication = true ;
			id = (String) session.getValue("Id");
			name = (String) session.getValue("Name");
		}
		else {
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		
		if( authentication ){
			int numOfItem = Integer.parseInt( req.getParameter( "numOfItem" ) );
			System.out.println( " 리스트당 문서 개수 : "+ numOfItem );
			
			String ingBoxSort = req.getParameter("ingBoxSort");
			System.out.println( " 결재함 정렬 기 준 : " + ingBoxSort );

			String ingSortMethod = req.getParameter("ingSortMethod");
			System.out.println( " 결재함 정렬 순 서 : " + ingSortMethod );			
			
			String completeBoxSort = req.getParameter("completeBoxSort");
			System.out.println( " 완결함 정렬 기 준 :" + completeBoxSort );

			String completeSortMethod = req.getParameter("completeSortMethod");
			System.out.println( " 완결함 정렬 순 서 :" + completeSortMethod );
			
			String rejectBoxSort = req.getParameter("rejectBoxSort");
			System.out.println( " 반려함 정렬 기 준 :" + rejectBoxSort );

			String rejectSortMethod = req.getParameter("rejectSortMethod");
			System.out.println( " 반려함 정렬 순 서 :" + rejectSortMethod );
			
			String publicBoxSort = req.getParameter("publicBoxSort");
			System.out.println( " 공용 문서함 정렬 기 준 : " + publicBoxSort );

			String publicSortMethod = req.getParameter("publicSortMethod");
			System.out.println( " 공용 문서함 정렬 순 서 :" + publicSortMethod );

			String	defaultPath = req.getParameter("defaultPath");



			String deleteButton = req.getParameter("deleteButton");
			
			boolean deletePath = false;
			if( req.getParameter("deleteButton") != null && deleteButton.equals("deletePath")){
				deletePath = true;
				System.out.println("삭제 설정");
			}
			
			boolean pathNull = true;
			if( req.getParameter("defaultPath") != null ) {
				defaultPath = new String( defaultPath.getBytes("ISO-8859-1"),"KSC5601");
				System.out.println( " default Path : " + defaultPath );	
				pathNull = false;
			}
			
			EDAOption option = new EDAOption();
			if( deletePath || pathNull) {
				option = new EDAOption( ingBoxSort, ingSortMethod, completeBoxSort , completeSortMethod , rejectBoxSort , rejectSortMethod , publicBoxSort , publicSortMethod , numOfItem );
				System.out.println("결재 경로 없는 옵션 설정");
			}
			else{
				option = new EDAOption( ingBoxSort, ingSortMethod, completeBoxSort , completeSortMethod , rejectBoxSort , rejectSortMethod , publicBoxSort , publicSortMethod , defaultPath , numOfItem );
				System.out.println("결재 경로 있는 옵션 설정");
				System.out.println( " default Path : " + defaultPath );	
			}
			ApprovalCourse[] courseArray = null;
			if( pathNull == false ){
				ApprovalDocument document = new ApprovalDocument();
				StringTokenizer st = new StringTokenizer( defaultPath ,";");
				Vector path = new Vector(); 
				Vector type = new Vector();
				while( st.hasMoreTokens() ){
					StringTokenizer st1= new StringTokenizer(st.nextToken(),",");
					path.add(st1.nextToken());
					type.add(st1.nextToken());
				}
				courseArray = new ApprovalCourse[ path.size()];
				for( int i = 0 ; i < path.size() ; i++){
					if(((String)(type.elementAt(i))).equals("결재")){
						courseArray[i] = new ApprovalCourse( null , (String)path.elementAt(i) , (i+1) ,
					 	 ApprovalCourse.NOTCOMPLETE , ApprovalCourse.SUBMITAPPROVAL );
					}
					else {
						courseArray[i] = new ApprovalCourse( null , (String)path.elementAt(i) , (i+1) ,
					 	 ApprovalCourse.NOTCOMPLETE , ApprovalCourse.SUBMITINFORM );
					}
				}
			}		
			System.out.println("결재 경로를 저장하기 위한 함수 시작");//여기부터
			EDAResultStatus result = new EDAResultStatus( EDAResultStatus.SUCCESS);
			if( deletePath ){
				System.out.println("삭제 로직 시작");
				result = edaController.deleteApprovalCourse( name + "(" + id + ")" , null , courseArray );
			}
			else if ( pathNull == false ){
				System.out.println("저장 로직 시작");
				result = edaController.saveApprovalCourse( name + "(" + id + ")" , null , courseArray );
			}	
	
			if( result.getResultStatus() == EDAResultStatus.SUCCESS )
				System.out.println("결재 경로 저장 성공");
			else{
				out.println("<br><br><p align=center><b>" + name + "님의 정보가 등록되지 않았습니다.</b><br><br>");
				System.out.println("Message : " + result.getReason() );
			}
			
			result = edaController.saveEDAOption ( name+"("+id+")" , option );
			if ( result.getResultStatus() == EDAResultStatus.SUCCESS ){
				out.println("<br><br><p align=center><font size=2 color=\"gray\"><b>" + name + "님의 정보를 등록하였습니다.</b></font><br><br>");
				if( deletePath ){
					out.println("<p align=center>지정하신 결재 경로는 삭제 되었습니다.</p>");
				}
			}
			else{
				out.println("<br><br><p align=center><b>" + name + "님의 정보가 등록되지 않았습니다.</b><br><br>");
				System.out.println("Message : " + result.getReason() );
			}
			out.println("</body></html>");
			out.close();	
		}
		else{
			res.sendRedirect("../Login.html");
		}
		
	}	
}