<%@ 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="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="ct" tagdir="/WEB-INF/tags" %>

<form:form commandName="memberSearchVO" name="searchForm" method="get">
		<div class="search2">
			<ul>
				<li class="margin-left"><b>소속</b> 　</li>
				<li class="form_search margin-left">
					<form:select path="place1" cssClass="use">
      					<form:option value="" label="전체" />
					<c:forEach var="item" items="${place1List}">
		    			<form:option value="${item.code2}">${item.codenm}</form:option>
		    		</c:forEach>
	 			</form:select>
			 	</li>
			 	<li class="margin-left"><b>이름</b> 　</li>
			 	<li><form:input path="name"/></li>
			 	<li class="margin-left"><b>계급</b> 　</li>
			 	<li class="form_search">
				<form:select path="position" cssClass="use">
      				<form:option value="" label="전체" />
					<c:forEach var="item" items="${positionList}">
		    		<form:option value="${item.code2}">${item.codenm}</form:option>
		    		</c:forEach>
	 			</form:select>
				</li>
				<li>
					<span class="btn_blue"> 
						<a href="javascript:fn_searchListAndGoFirstPage();"><spring:message code="button.goSearch" /></a>
					</span>
				</li>
			</ul>	       	       
       	</div>
		<!-- <div id="search">
			<ul>
				<li>소속</li>
			<li>
				<form:select path="place1" cssClass="use">
      					<form:option value="" label="전체" />
					<c:forEach var="item" items="${place1List}">
		    			<form:option value="${item.code2}">${item.codenm}</form:option>
		    		</c:forEach>
	 			</form:select>
			</li>
			<li>이름</li>
			<li>
				<form:input path="name"/>
			</li>
			<li>계급</li>
			<li>
				<form:select path="position" cssClass="use">
      					<form:option value="" label="전체" />
					<c:forEach var="item" items="${positionList}">
		    			<form:option value="${item.code2}">${item.codenm}</form:option>
		    		</c:forEach>
	 			</form:select>
			</li>
			<li>
				<a href="javascript:fn_searchList();"><spring:message code="button.goSearch" /></a>
			</li>
			</ul>
       	</div>        -->
      	<form:hidden path="pageIndex" />
       	<form:hidden path="ordertype" />
       	<form:hidden path="ordercode" />
</form:form>
<div id="table">
	<div class="pageinfo">
    	<ct:pageInfo />
    	<ul class="right btn-style">
			<li><a href="#" class="btn_reset" onclick="location.reload();"></a></li>
		</ul>		       
    </div>
	<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0">
		<colgroup>
   			<col width="60"/>
   			<col width="140"/>
   			<col width="100"/>
   			<col width="80"/>	   			
   			<col width="120"/>
   			<col width="100"/>	   			
   			<col width="100"/>
   			<col width="100"/>	   			
   			<col width="160"/>
   			<col width="90"/>
	    </colgroup>	   		
		<thead>
			<tr>
				<th rowspan="2"><spring:message code="member.view.seq"/></th>
				<th rowspan="2">
					<span class="order" value="<spring:message code="member.value.order.nowplace1"/>">
						<spring:message code="member.view.place1now" />
						<img src="/images/cmmn/blank_1x1.png" />
					</span>
				</th>
				<th rowspan="2">
					<span class="order" value="<spring:message code="member.value.order.nowposition"/>">
						<spring:message code="member.view.positionnow" />
						<img src="/images/cmmn/blank_1x1.png" />
					</span>
				</th>
				<th rowspan="2">
					<span class="order" value="<spring:message code="member.value.order.name"/>">
						<spring:message code="member.view.name" />
						<img src="/images/cmmn/blank_1x1.png" />
					</span>
				</th>
				<th rowspan="2">
					<span class="order" value="<spring:message code="member.value.order.userid"/>">
						<spring:message code="member.view.userid" />
						<img src="/images/cmmn/blank_1x1.png" />
					</span>
				</th>
				<th class="tbl_list_col" colspan="3"><spring:message code="member.view.lastestCareer"/></th>
				<th rowspan="2"><spring:message code="member.view.totalFaPeriod"/></th>
				<th rowspan="2"><spring:message code="member.view.etc"/></th>
			</tr>
			<tr>
				<th><spring:message code="member.view.position"/></th>
				<th><spring:message code="member.view.charge"/></th>
				<th><spring:message code="member.view.workPeriod"/></th>
			</tr>
		</thead>
		<tbody>
			<c:choose>
			<c:when test="${fn:length(resultList) > 0}">		
			<c:forEach items="${resultList}" var="item" varStatus="status">
			<tr>
				<td align="center"><c:out value="${item.rnum}"/></td>
				<td align="center">
					<c:choose>
						<c:when test="${item.nowPlaceStr ne null and fn:length(item.nowPlaceStr) > 0}"><c:out value="${item.nowPlaceStr}"/></c:when>
						<c:otherwise>-</c:otherwise>
					</c:choose>
				</td>
				<td align="center">
					<c:choose>
						<c:when test="${item.nowPositionStr ne null and fn:length(item.nowPositionStr) > 0}"><c:out value="${item.nowPositionStr}"/></c:when>
						<c:otherwise>-</c:otherwise>
					</c:choose>
				</td>
				<td align="center">
					<a href="<c:url value="/fa/exmemberView.do">
								<c:param name="userid" value="${item.userid}" />
							</c:url>">
						<c:out value="${item.name}"/>
					</a>
				</td>
				<td align="center"><c:out value="${item.userid}"/></td>
				<td align="center"><c:out value="${item.positionStr}"/></td>
				<td align="center">
					<c:choose>
						<c:when test="${item.charge ne null and fn:length(item.charge) > 0}"><c:out value="${item.charge}"/></c:when>
						<c:otherwise>-</c:otherwise>
					</c:choose>
				</td>
				<td align="center"><c:out value="${fn:split(item.excareer, '-')[0]}"/>년 <c:out value="${fn:split(item.excareer, '-')[1]}"/>개월</td>
				<td align="center"><c:out value="${item.getTotExcareerTermStr()}" /></td>
				
				<td align="center">
					<a href="<c:url value="/fa/exmemberUpdate.do">
								<c:param name="userid" value="${item.userid}" />
							 </c:url>">[수정]</a></td>
			</tr>			
			</c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td align="center" colspan="10">
						<spring:message code="msg.nodata" />
					</td>
				</tr>
			</c:otherwise>
			</c:choose>
		</tbody>
	</table>
</div>
<!-- /List -->
<div id="paging">
	<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
</div>
<script type="text/javaScript" defer="defer">
	<!--
	$(document).ready(function(){
		
		if (document.searchForm.ordercode && document.searchForm.ordercode.value.length > 0) {
			$('.order[value=' + document.searchForm.ordercode.value + '] img')
				.attr('src', (document.searchForm.ordertype.value == '1') ? '/images/cmmn/order_desc.gif' : '/images/cmmn/order_asc.gif');
		}
		
		$('.order').click(function(){
			var ordercode = $(this).attr('value');
			if (document.searchForm.ordercode.value == ordercode) {
				if (document.searchForm.ordertype.value == 1) {
					document.searchForm.ordertype.value = 0;
				} else {
					document.searchForm.ordertype.value = 1;
				}
			} else {
				document.searchForm.ordertype.value = 0;
			}
			document.searchForm.ordercode.value = ordercode;
			fn_searchList();
		});
		
		$("#name").keydown(function(e){
			if (e.keyCode == 13) {
				fn_searchListAndGoFirstPage();
			}
		});
	});
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/fa/exmemberList.do'/>";
		document.searchForm.submit();
	}
	/* 글 목록 화면 function */
    function fn_searchList() {
       	document.searchForm.action = "<c:url value='/fa/exmemberList.do'/>";
       	document.searchForm.submit();
    }
    function fn_searchListAndGoFirstPage() {
    	document.searchForm.pageIndex.value = 1;
    	fn_searchList();
    }
	//-->
</script>