<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<form:form commandName="exmemberVO" name="addForm" method="post" enctype="multipart/form-data" id="addForm">
	<div class="memberAdd" id="table">
		<table class="tbl_add" width="100%" border="0" cellpadding="0" cellspacing="0">
			<colgroup>
				<col width="110" >
				<col width="250" >
				<col width="110" >
				<col width="250" >
			</colgroup>
			  <tr>
			  	<th><spring:message code="exmember.name"/></th>
			    <td>
			    	<span class="tbl_addtext"><spring:message code="member.view.hangul"/></span><form:input path="name" /><br/>
			    	<span class="tbl_addtext"><spring:message code="member.view.hanja"/></span><form:input path="chnname"/>
			    </td>
			    <th><spring:message code="exmember.userid"/></th>
			    <td>
					<c:if test="${registerFlag == 'create'}">
			    	</c:if>
			    	<c:if test="${registerFlag == 'modify'}">
			    		<form:hidden path="userid"/>
			    		<c:out value="${exmemberVO.userid}"/>
			    	</c:if>
			    </td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.cdate"/></th>
			    <td colspan="3">
			    	<fmt:formatDate value="${exmemberVO.cdateEx}" pattern="yyyy-MM-dd" var="cdateEx" />
			    	<form:input path="cdateEx" value="${cdateEx}"/>
		    	</td>
			  </tr>  
			  <tr>
			    <th><spring:message code="exmember.address"/></th>
			    <td colspan="3"><form:input path="address"/></td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.family"/></th>
			    <td colspan="3"><form:input path="family"/></td>
			  </tr>  
			  <tr>
			    <th><spring:message code="exmember.charge"/></th>
			    <td><form:input path="charge"/></td>
			    <th><spring:message code="exmember.email"/></th>
			    <td><form:input path="email"/></td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.ophone"/></th>
			    <td><form:input path="ophone"/></td>
			    <th><spring:message code="exmember.sdate"/></th>
			    <td><form:input path="sdate" readonly="readonly"/>
			    </td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.hphone"/></th>
			    <td><form:input path="hphone"/></td>
			    <th><spring:message code="exmember.pdate.now"/></th>
			    <td><form:input path="pdate" readonly="readonly"/></td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.cphone"/></th>
			    <td><form:input path="cphone"/></td>
			    <th><spring:message code="exmember.adate.now"/></th>
			    <td><form:input path="adate" readonly="readonly"/></td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.nowPlace"/></th>
			    <td class="form_select">
			    	<form:select path="nowPlace">
			    		<c:forEach var="item" items="${place1List}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>			    	
			    </td>
			    <th><spring:message code="exmember.nowPosition"/></th>
			    <td class="form_select">
			    	<form:select path="nowPosition">
			    		<c:forEach var="item" items="${positionList}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			 </tr>
			  <tr>
			    <th><spring:message code="exmember.place1.prev"/></th>
			    <td class="form_select">
			    	<form:select path="place1" onchange="fncGetCombo($('#place2_div'), 'place2', this.value);">
			    		<c:forEach var="item" items="${place1List}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>			    	
			    </td>
			    <td colspan="2">
			    	<span id="place2_div"></span>
			    </td>
			 </tr>
			 <tr>
			    <th><spring:message code="exmember.position.prev"/></th>
			    <td class="form_select">
			    	<form:select path="position">
			    		<c:forEach var="item" items="${positionList}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			    <th><spring:message code="exmember.place3"/></th>
			    <td><span id="place3_div"></span></td>
			 </tr>
			 <tr>
			    <th><spring:message code="exmember.jobtype"/></th>
			    <td class="form_select">
			    	<form:select path="jobtype">
			    		<c:forEach var="item" items="${jobTypeList}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			    <th><spring:message code="exmember.duties"/></th>
			    <td class="form_select">
		    		<form:select path="duties">
			    		<c:forEach var="item" items="${dutiesList}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			 </tr>
			 <tr>
			    <th><spring:message code="exmember.scholarship"/></th>
			    <td class="form_select">
			    	<form:select path="scholarship">
			    		<c:forEach var="item" items="${scholarshipList}">
			    			<form:option value="${item.code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			    <th><spring:message code="exmember.inout"/></th>
			    <td colspan="3" class="form_radio">
			    	<form:radiobutton path="inout" value="i"/><spring:message code="member.view.inout.i"/> 
			   	 	<form:radiobutton path="inout" value="o"/><spring:message code="member.view.inout.o"/>  
			   	 	<form:radiobutton path="inout" value="d"/><spring:message code="member.view.inout.d"/> 
			    </td>
			  </tr>
			  <tr>
			    <th><spring:message code="exmember.usegrade"/></th>
			    <td class="form_select">
			    	<form:select path="usegrade">
			    		<c:forEach var="item" items="${authList}">
			    			<fmt:parseNumber var="code2" type="number" value="${item.code2}" />
			    			<form:option value="${code2}">${item.codenm}</form:option>
			    		</c:forEach>
			    	</form:select>
			    </td>
			    <th><spring:message code="exmember.type"/></th>
			    <td colspan="3" class="form_radio">
			    	<form:radiobutton path="usertype" value="f"/><spring:message code="member.type.fa"/> 
			   	 	<form:radiobutton path="usertype" value="g"/><spring:message code="member.type.nofa"/>  
			    </td>
			  </tr>
			  <tr>
			 	<th><spring:message code="member.view.excareer_y"/></th>
			    <td class="form_day">
			    	<form:select path="excareer_y">
			    		<c:forEach var="item" begin="0" end="20" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>년</span>
			    	<form:select path="excareer_m">
			    		<c:forEach var="item" begin="0" end="11" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>개월</span>
			    </td>
			    <th><spring:message code="member.view.excareer1_y"/></th>
			    <td class="form_day">
			    	<form:select path="excareer1_y">
			    		<c:forEach var="item" begin="0" end="20" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>년</span>
			    	<form:select path="excareer1_m">
			    		<c:forEach var="item" begin="0" end="11" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>개월</span>
			    </td>
			  </tr>
			  <tr>
			    <th><spring:message code="member.view.excareer2_y"/></th>
			    <td class="form_day">
			    	<form:select path="excareer2_y">
			    		<c:forEach var="item" begin="0" end="20" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>년</span>
			    	<form:select path="excareer2_m">
			    		<c:forEach var="item" begin="0" end="11" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>개월</span>
			    </td>
			    <th><spring:message code="member.view.excareer3_y"/></th>
			    <td class="form_day">
					<form:select path="excareer3_y">
			    		<c:forEach var="item" begin="0" end="20" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>년</span>
			    	<form:select path="excareer3_m">
			    		<c:forEach var="item" begin="0" end="11" varStatus="status">
			    			<form:option value="${status.index}">${status.index}</form:option>
			    		</c:forEach>
			    	</form:select>
			    	<span>개월</span>
				</td>
			  </tr>
			  <tr>
			  	<th><spring:message code="member.view.userimg"/></th>
			  	<td colspan="3">
			  		<input type="file" name="img"/>
			  		<c:if test="${exmemberVO.userimg != null and (exmemberVO.userimg != '' or exmemberVO.userimg != ' ')}">
			  			<form:hidden path="userimg"/>
			  			<br><input class="fileDelete" type="checkbox" target="userimg" value="${exmemberVO.userimg}">기존 이미지를 삭제합니다.
			  		</c:if>
		  		</td>
			  </tr>
			  <tr>
			    <th><spring:message code="member.view.etc"/></th>
			    <td colspan="3"><form:textarea path="comment_" rows="2" cols="80" /></td>
			  </tr>
			  <tr>
			    <th><spring:message code="member.view.warning"/></th>
			    <td colspan="3" class="notice">
			    	* 등록일자는 다른 부서로 발령난 날을 선택해주시면 총 외사경력이 정확히 나타납니다.<br>
					* 사진 수정 시에는 삭제를 꼭 체크하고 등록해 주셔야 이전 이미지가 삭제 됩니다.<br>
			    </td>
			  </tr>
		</table>
	</div>
</form:form>
<div class="boardviewinfo">
	<ul class="right btn-style">
		<li>
			<a href="javascript:fn_goAdd();">
           	<spring:message code="button.${registerFlag == 'modify' ? 'modify' : 'memberAdd'}"/>
           </a>
        </li>
		<li>
		 	<a href="javascript:fn_selectList();"><spring:message code="button.list"/></a>
        </li>            
	</ul>	
</div>
<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="exmemberVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" defer="defer">
$(document).ready(function(){
	$('#place1').change();
	$("#cdateEx").datepicker({
		dateFormat: 'yy-mm-dd',
		onSelect: function(date){
			$("#cdateEx").val(date);
		}
	});
	$("#sdate").datepicker({
		dateFormat: 'yy-mm-dd',
		onSelect: function(date){
			$("#sdate").val(date);
		}
	});
	$("#pdate").datepicker({
		dateFormat: 'yy-mm-dd',
		onSelect: function(date){
			$("#pdate").val(date);
		}
	});
	$("#adate").datepicker({
		dateFormat: 'yy-mm-dd',
		onSelect: function(date){
			$("#adate").val(date);
		}
	});
	
	$('.fileDelete').click(function(){
		var target = $(this).attr('target');
		if($(this).prop('checked')){
			$('input[name=' + target + ']').val('');
		} else {
			$('input[name=' + target + ']').val($(this).val());
		}
	});
});
<!--
/* 글 등록 function */
function fn_goAdd() {
	var frm = document.addForm;
	//if(!validateExmemberVO(frm)){
    //    return;
    //}else{
    	frm.action = "/fa/exmemberUpdate.do";
       	frm.submit();
    //}
}
/* 글 목록 화면 function */
function fn_selectList() {
   	location.href = "<c:url value='/fa/exmemberList.do'/>";
}
var Member = {
	checkID : function(_str) {
		var form = document.forms['write_form'];
		if(_str.length < 5 ) return;
		
		$.ajax({
			url: '/member/faIdCheck.json',
			type: 'get',
			data : {userid: _str},
			dataType: 'json',
			success: function (result) {
				var data = result.data;
				if (data == "1") {
					$('#checkid').val("N");
					$('#userid_desc').html("<spring:message code="member.msg.duplicate"/>");
					$('#userid_desc').css('color', '#f00');
					return;
				}else{
					$('#checkid').val("Y");
					$('#userid_desc').html("<spring:message code="member.msg.available"/>");
					$('#userid_desc').css('color', '#00f');
				}
			}
		});
	},
	checkPWD : function(_str){
		var form = document.forms['addForm'];
		var passwd = form.passwd.value;
		if(passwd == _str){
			$('#pwd_desc').html("<spring:message code="member.msg.match"/>");
			$('#pwd_desc').css('color', '#00f');
			form.checkPwd.value = 'Y'; 
		}else{
			$('#pwd_desc').html("<spring:message code="member.msg.dismatch"/>");
			$('#pwd_desc').css('color', '#f00');
			form.checkPwd.value = 'N'; 
		}
	},
	goList : function(){
		location.href="admin_member_list.php?list_type=admin";
	},	
	regist : function() {
	} 
};
	
function fncGetCombo(_obj, _id, _value) {
	$.ajax({
		url: '/code/place2.json',
		type: 'get',
		data : {code1: _value},
		dataType: 'json',
		success: function (result) {
			var data = result.data;
			if (data.length > 0) {
				var select = $('#place2').empty();
				if (select.length == 0) {
					select = $('<select id="place2" name="place2">');
				}
				for (var i=0; i < data.length; i++) {
					var option = $('<option>')
								.html(data[i].codenm)
								.val(data[i].code2);
					if ('${exmemberVO.place2}' == data[i].code2) {
						option.attr('selected', true);
					}
					select.append(option);
				}
				_obj.append(select);
				console.log(_value);
				var combo2 = $("#place3_div");
				if(_value.toUpperCase() != "PS00"){				
					fncGetCombo2(combo2, "place3", "C009", "11");
				}else{
					fncGetCombo2(combo2, "place3", "C009");
				}
			}
		}
	});
}
function fncGetCombo2(_obj, _id, _value, _option) {
	$.ajax({
		url: '/code/place3.json',
		type: 'get',
		data : {code1: _value, code2: _option},
		dataType: 'json',
		success: function (result) {
			var data = result.data;
			if (data.length > 0) {
				var select = $('#place3').empty();
				if (select.length == 0) {
					select = $('<select id="place3" name="place3">');
				}
				for (var i=0; i < data.length; i++) {
					var option = $('<option>')
								.html(data[i].codenm)
								.val(data[i].code2);
					if ('${exmemberVO.place3}' == data[i].code2) {
						option.attr('selected', true);
					}
					select.append(option);
				}
				_obj.append(select);
			}
		}
	});
}
-->
</script>