<%@ 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="ct" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javaScript" language="javascript" defer="defer">
	/* 글 상세 화면 function */
	function fn_select(npIdx) {
		document.listForm.npIdx.value = npIdx;
		document.listForm.action = "<c:url value='/notice/view.do'/>";
	   	document.listForm.submit();
	}
	
	/* 글 목록 화면 function */
    function fn_selectList() {
       	//document.searchForm.action = "<c:url value='/notice/list.do'/>";
       	//document.searchForm.submit();
    	window.history.back();
    }
	
	/* 글 등록 화면 function */
	function fn_addView() {
	   	document.listForm.action = "<c:url value='/notice/addView.do'/>";
	   	document.listForm.submit();
	}
	
	/* 글 선택 삭제 function */
	function fn_deleteSelectedBoard() {
		var confirmed = confirm('선택한 게시물 중 삭제권한이 있는 게시물을 삭제합니다.\n삭제하시겠습니까?');
		if(confirmed){
			document.listForm.method = "post";
		   	document.listForm.action = "<c:url value='/notice/selectedDelete.do'/>";
		   	document.listForm.submit();
		}
	}
	
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/notice/list.do'/>";
		document.searchForm.submit();
	}
	/* 새로고침 function */
	function fn_reload() {
		location.reload();
	}
</script>
<form:form commandName="searchVO" name="searchForm" method="get">
	<div id="search">
		<div class="form_group">	
			<label class="hidden" for="searchCondition" style="visibility: hidden;"><spring:message code="search.keyword" /></label> 
			<form:select path="searchCondition" cssClass="use">
				<form:option value="0" label="소속" />
				<form:option value="1" label="작성자" />
				<form:option value="2" label="제목" />
			</form:select>
			<form:input path="searchKeyword" cssClass="txt" placeholder="검색어를 입력하세요."/>		
			<div class="inp_btn">
				<span class="btn_blue"><a href="javascript:fn_selectList();"><spring:message code="button.goSearch" /></a></span>
			</div>
		</div>
	</div>
	<form:hidden path="pageIndex" />
</form:form>

<form:form name="listForm" method="get">
	<input type="hidden" name="npIdx" />
	<!-- List -->
	<div id="table">		
		<div class="pageinfo">
			<ct:pageInfo />
			<ul class="right btn-style">
				<!-- <li><a href="javascript:fn_deleteSelectedBoard();" class="btn_delete"></a></li> -->
				<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" summary="게시판 목록을 확인 할 수 있습니다.">
			<caption class="hidden">공지사항 목록</caption>
			<colgroup>
				<col width="50">
				<col width="*">
				<col width="150">
				<col width="120">
				<col width="120">
				<col width="120">
			</colgroup>
			<thead>
				<tr>
					<th align="center"><spring:message code="board.header.no" /></th>
					<th align="center"><spring:message code="board.header.title" /></th>
					<th align="center"><spring:message code="board.header.writer" /></th>
					<th align="center">시작일</th>
					<th align="center">종료일</th>
					<th align="center"><spring:message code="board.header.regdate" /></th>
				</tr>
			</thead>
			<c:forEach var="result" items="${resultList}" varStatus="status">
				<tr>
					<td align="center" class="listtd">
					<c:out value="${result.npIdx}" />
					</td>
					<td align="left" class="listtd">
					<a href="javascript:fn_select('<c:out value="${result.npIdx}"/>')">
						<c:out value="${result.npSubject}" />
					</a></td>
					<td align="center" class="listtd"><b><c:out value="${result.npWriter}" /></b></td>
					<td align="center" class="listtd"><b><c:out value="${result.npStart}" /></b></td>
					<td align="center" class="listtd"><b><c:out value="${result.npEnd}" /></b></td>
					<td align="center" class="listtd"><fmt:formatDate value="${result.npRegdate}" pattern="yyyy-MM-dd" />&nbsp;</td>
				</tr>
			</c:forEach>
			<c:if test="${empty resultList}">
				<tr><td colSpan='7' align="center"><spring:message code="msg.nodata" /></td></tr>
			</c:if>
		</table>
	</div>
	<!-- /List -->
	<div id="paging">
		<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
	</div>
	<div class="board_buttom">
		<ul class="btn-style right">			
			<li><a href="javascript:fn_addView();" class="btn_create"><spring:message code="button.create" /></a></li>
		</ul>
	</div>	
</form:form>
