<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.biz_nis.cmn.CommonMethod" %>
<%@ page import="com.biz_nis.nw_prstus.goal_nmvl_prstus.GoalNmvlPrstusDAO" %>
<%@ page import="com.biz_nis.nw_prstus.goal_nmvl_prstus.GoalNmvlPrstusDTO" %>
<%@ page import="org.apache.log4j.Logger" %>

<%
	Logger l_oLogger = Logger.getLogger( "" );

  	request.setCharacterEncoding("UTF-8");

  	if("".equals(CommonMethod.nullChk( (String)session.getAttribute("mbr_id") ))
			&& "".equals(CommonMethod.nullChk( (String)session.getAttribute("mbr_pwd") ))) {
		out.println("<script language='JavaScript'>");
		out.println("	location.href='/';");
		out.println("</script>");
	}

  	//변수 선언부
  	GoalNmvlPrstusDAO l_oGoalNmvlPrstusDAO = null;
  	GoalNmvlPrstusDTO l_oGoalNmvlPrstusDTO = null;
  	boolean l_bSuccess = false;

  	try {
  		l_oGoalNmvlPrstusDAO = new GoalNmvlPrstusDAO();
  		l_oGoalNmvlPrstusDTO = new GoalNmvlPrstusDTO();

		int    p_nCurPage     	= CommonMethod.intNullChk(request.getParameter("cur_page"));
		int    p_nListSize    	= CommonMethod.intNullChk(request.getParameter("list_size"));
		String p_sSlct_flag   	= CommonMethod.nullChk(request.getParameter("slct_flag"));
		String p_sSrch_text   	= CommonMethod.nullChk(request.getParameter("srch_text"));
		String p_sSrch_fr_dt    = CommonMethod.nullChk(request.getParameter("srch_fr_dt"));
		String p_sSrch_to_dt    = CommonMethod.nullChk(request.getParameter("srch_to_dt"));
		String p_sSlct_idstry 	= CommonMethod.nullChk(request.getParameter("slct_idstry"));
		String p_sSlct_entp 	= CommonMethod.nullChk(request.getParameter("slct_entp"));
		String p_sSlct_jobcl 	= CommonMethod.nullChk(request.getParameter("slct_jobcl"));

		String p_sFlag        		= CommonMethod.nullChk( request.getParameter("flag") );
		String p_sGoal_seq 			= CommonMethod.nullChk(request.getParameter("goal_seq"));
		String p_sGoal_mbr_id 		= CommonMethod.nullChk(request.getParameter("goal_mbr_id"));
		String p_sGoal_mbr_belng 	= CommonMethod.nullChk( request.getParameter("goal_mbr_belng") );
		String p_sGoal_idstry  		= CommonMethod.nullChk( request.getParameter("goal_idstry") );
		int    p_nGoal_inwonsu     	= CommonMethod.intNullChk( request.getParameter("goal_inwonsu") );
		int    p_nGoal_base     	= CommonMethod.intNullChk( request.getParameter("goal_base") );
		int    p_nGoal_year     	= CommonMethod.intNullChk( request.getParameter("goal_year") );

		l_oGoalNmvlPrstusDTO.setGoal_seq( p_sGoal_seq );
		l_oGoalNmvlPrstusDTO.setGoal_mbr_id( p_sGoal_mbr_id );
		l_oGoalNmvlPrstusDTO.setGoal_mbr_belng( p_sGoal_mbr_belng );
		l_oGoalNmvlPrstusDTO.setGoal_idstry( p_sGoal_idstry );
		l_oGoalNmvlPrstusDTO.setGoal_inwonsu( p_nGoal_inwonsu );
		l_oGoalNmvlPrstusDTO.setGoal_base( p_nGoal_base );
		l_oGoalNmvlPrstusDTO.setGoal_year( p_nGoal_year );

		// Insert
		if (("I").equals(p_sFlag)) {
			l_bSuccess = l_oGoalNmvlPrstusDAO.insert( l_oGoalNmvlPrstusDTO );

			if (l_bSuccess) {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_list.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
				</form>

				<script>
					alert("등록되었습니다.");
					document.form.submit();
				</script>
<%
			} else {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_write.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
				</form>

				<script>
					alert("등록도중 에러가 발생하였습니다.");
					document.form.submit();
				</script>
<%
			}
		}

		// update
		else if (("U").equals(p_sFlag)) {
		  	l_bSuccess = l_oGoalNmvlPrstusDAO.update( l_oGoalNmvlPrstusDTO );

			if (l_bSuccess) {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_list.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
				</form>

				<script>
					alert("수정되었습니다.");
					document.form.submit();
				</script>
<%
			} else {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_edit.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
					<input type="hidden" id="goal_seq" name="goal_seq" value="<%=p_sGoal_seq %>">
				</form>

				<script>
					alert("수정도중 에러가 발생하였습니다.");
					document.form.submit();
				</script>
<%
			}
		}
		// delete
		else if (("D").equals(p_sFlag)) {
		  	l_bSuccess = l_oGoalNmvlPrstusDAO.delete( p_sGoal_seq );

			if (l_bSuccess) {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_list.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
				</form>

				<script>
					alert("삭제되었습니다.");
					document.form.submit();
				</script>
<%
			} else {
%>
				<form name="form" method="post" action="goal_nmvl_prstus_edit.jsp">
					<input type="hidden" id="cur_page" name="cur_page" value="<%= p_nCurPage %>"/>
					<input type="hidden" id="list_size" name="list_size" value="<%= p_nListSize %>"/>
					<input type="hidden" id="srch_fr_dt" name="srch_fr_dt" value="<%= p_sSrch_fr_dt %>"/>
					<input type="hidden" id="srch_to_dt" name="srch_to_dt" value="<%= p_sSrch_to_dt %>"/>
					<input type="hidden" id="slct_idstry" name="slct_idstry" value="<%= p_sSlct_idstry %>"/>
					<input type="hidden" id="slct_entp" name="slct_entp" value="<%=p_sSlct_entp %>">
					<input type="hidden" id="slct_jobcl" name="slct_jobcl" value="<%=p_sSlct_jobcl %>">
					<input type="hidden" id="goal_seq" name="goal_seq" value="<%=p_sGoal_seq %>">
				</form>

				<script>
					alert("삭제도중 에러가 발생하였습니다.");
					document.form.submit();
				</script>
<%

			}
		}
	} catch( Exception e ) {
	  l_oLogger.debug( e.toString() );
	} finally {}

%>