<%@ 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="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<form:form commandName="searchVO" name="searchForm" method="get">
	<form:hidden path="orderCol" />
	<form:hidden path="orderAsc" />
	
	<div class="search2">
		<ul>
			<li><b><label for="eduCourse"><spring:message code="fa.edu.eduCourse" /></label></b> 　</li>
			<li class="form_search margin-left">
				<form:select path="eduCourse" cssClass="use">
					<c:forEach var="result" items="${eduCourseList}" varStatus="status">
						<form:option value="${result.code2}" label="${result.codenm}" />
					</c:forEach>
    			</form:select>
		 	</li>
		 	<li class="margin-left"><b><label for="place1">소속</label></b> 　</li>
		 	<li class="form_search margin-left">
		 		<form:select path="place1" cssClass="use">
					<c:forEach var="result" items="${placeList}" varStatus="status">
						<form:option value="${result.code2}" label="${result.codenm}" />
					</c:forEach>
    			</form:select>
			</li>	 
			<li class="margin-left"><label for="name"><spring:message code="fa.edu.name" /></label></li>
			<li class="margin-left"><form:input path="name" /></li>
			<li>
				<span class="btn_blue"> 
					<a href="javascript:fn_selectList();"><spring:message code="button.goSearch" /></a>
				</span>
			</li>			
		</ul>	       	       
	</div>
	
</form:form>
<div id="divPrintArea">
	<div id ="divPrintTitle" style="display: none;margin: 10px 0 10px 0;"><spring:message code="fa.edu" /></div>
	<form:form name="listForm" method="get">
		<input type="hidden" name="idx" />
		<!-- List -->
		<div id="table">
			<div class="pageinfo">
				<ul class="left">
					<li>검색결과 <em>${fn:length(eduList)}</em>건</li>		
				</ul>	
				<ul class="right btn-style">
					<li><a href="#" class="btn_reset" onclick="location.reload();"></a></li>
					<li><a class="btn_print" href="javascript:fn_print();"></a></li>
					<li><a class="btn_excel" href="<c:url value="/fa/edu/listtoexcel.do">
       					<c:param name="eduCourse" value="${searchVO.eduCourse}" />
       					<c:param name="place1" value="${searchVO.place1}" />
       					<c:param name="name" value="${searchVO.name}" />
       					<c:param name="orderCol" value="${searchVO.orderCol}" />
       					<c:param name="orderAsc" value="${searchVO.orderAsc}" />
       				 	</c:url>"></a>
       				</li>
				</ul>	
			</div>
			<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" summary="<spring:message code="fa.edu" /> 목록을 확인 할 수 있습니다.">
				<caption class="hidden"><spring:message code="fa.edu" />목록</caption>
				<thead>
					<tr>
						<th align="center">번호</th>
						<th align="center"><span class="order" value="ES_EDU_COURSE"><spring:message code="fa.edu.eduCourse" />&nbsp;<img src="/images/cmmn/blank_1x1.png" /></span></th>
						<th align="center"><span class="order" value="ES_SCHOLARSHIP"><spring:message code="fa.edu.scholarship" />&nbsp;<img src="/images/cmmn/blank_1x1.png" /></span></th>
						<th align="center"><span class="order" value="ES_POSITION"><spring:message code="fa.edu.position" />&nbsp;<img src="/images/cmmn/blank_1x1.png" /></span></th>
						<th align="center"><span class="order" value="ES_NAME"><spring:message code="fa.edu.name" />&nbsp;<img src="/images/cmmn/blank_1x1.png" /></span></th>
						<th align="center"><span class="order" value="ES_BIRTH"><spring:message code="fa.edu.birth" />&nbsp;<img src="/images/cmmn/blank_1x1.png" /></span></th>
						<th align="center"><spring:message code="fa.edu.eduTerm" /></th>
						<th align="center"><spring:message code="fa.edu.comment" /></th>
					</tr>
				</thead>
				<tbody>
				<c:choose>
				<c:when test="${fn:length(eduList) > 0}">
					<c:forEach var="result" items="${eduList}" varStatus="status">
					<tr>
						<td align="center" class="listtd"><c:out value="${status.index+1}" /></td>
						<td align="center" class="listtd"><c:out value="${result.eduCourseStr}" /></td>
						<td align="center" class="listtd"><c:out value="${result.scholarshipStr}" /></td>
						<td align="center" class="listtd"><c:out value="${result.positionStr}" /></td>
						<td align="center" class="listtd">
							<a href="<c:url value="/fa/edu/update.do">
										<c:param name="idx" value="${result.idx}" />
									 </c:url>">
								<c:out value="${result.name}" />
							</a>						
						</td>
						<td align="center" class="listtd"><c:out value="${result.birth}" /></td>
						<td align="center" class="listtd">
							<%-- <c:out value="${result.stdate}" /> ~ <c:out value="${result.eddate}" /> --%>
							<c:out value="${result.eduTerm}" />
						</td>
						<td align="center" class="listtd"><c:out value="${result.comment}" /></td>
					</tr>
					</c:forEach>
				</c:when>
				<c:otherwise>
					<tr>
						<td class="listtd" align="center" colspan="8">
							<spring:message code="msg.nodata" />
						</td>
					</tr>
				</c:otherwise>
				</c:choose>
				</tbody>
			</table>
		</div>
		<!-- /List -->
	</form:form>
</div>
<!-- /PrintArea -->

<form:form name="menuForm" method="get">
	<div id="sysbtn" class="board_buttom">
		<ul class="btn-style right">
			<c:if test="${loginUserVO.isAdmin}" >
			<li><a href="<c:url value="/fa/edu/add.do" />" class="btn_create"><spring:message code="button.create" /></a></li>
			</c:if>
		</ul>
	</div>
</form:form>

<script type="text/javaScript" defer="defer">
<!--
	/* 목록 화면 function */
	function fn_selectList() {
		document.searchForm.submit();
	}

	/* 출력 */
	function fn_print(){
		var divPrintTitle = document.getElementById("divPrintTitle");
		divPrintTitle.style.display = "inline";
		printDiv($("#divPrintArea").html());
		divPrintTitle.style.display = "none";
	}
	
	$(document).ready(function(){
		// 정렬
		if (document.searchForm.orderCol && document.searchForm.orderCol.value.length > 0) {
			$('span[value=' + document.searchForm.orderCol.value + '] > img')
				.attr('src', (document.searchForm.orderAsc.value == 'DESC') ? '/images/cmmn/order_desc.gif' : '/images/cmmn/order_asc.gif');
		}
		$('.order').click(function(){
			var ordercode = $(this).attr('value');
			if (document.searchForm.orderCol.value == ordercode) {
				if (document.searchForm.orderAsc.value == 'ASC') {
					document.searchForm.orderAsc.value = 'DESC';
				} else {
					document.searchForm.orderAsc.value = 'ASC';
				}
			} else {
				document.searchForm.orderAsc.value = 'DESC';
			}
			document.searchForm.orderCol.value = ordercode;
			document.searchForm.submit();
		});	
	});
//-->
</script>