<%@ 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">
	<div id="search">
		<div class="form_group">	
			<form:select path="place1" cssClass="use">
					<form:option value="" label="전체" />
					<c:forEach var="result" items="${placeList}" varStatus="status">
						<form:option value="${result.code2}" label="${result.codenm}" />
					</c:forEach>
    		</form:select>
    		<label for="searchKeyword" class="hidden">
					<spring:message code="search.keyword" />
			</label> 
			<form:input path="searchKeyword" cssClass="txt" />
			<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 commandName="susaList" name="listForm" method="get">
	<input type="hidden" name="idx" />
	<!-- List -->
	<div id="table">
		<div class="pageinfo">
			<ul class="left">
				<li>표시갯수<em>${paginationInfo.recordCountPerPage}</em></li>		
				<li>검색 게시물<em>${paginationInfo.totalRecordCount}</em>/<b>${totalCnt}</b>
					<c:set var="N" 	value="${paginationInfo.totalRecordCount/paginationInfo.recordCountPerPage}" />
				</li>		
				<li>현재 페이지 <em>${paginationInfo.currentPageNo}</em>/<b><fmt:formatNumber value="${N+(1-(N%1))%1}" type="number" pattern="#" /></b></li>	
			</ul>	
			<ul class="right btn-style">		
				<!-- <li><a class="btn_excel" href="/susa/promot/listtoexcel.do"></a></li> -->
				<li><a class="btn_excel" href="javascript:fn_exportToExcel();"></a></li>
				<li><a href="javascript:fn_reload()" class="btn_reset"></a></li>		
			</ul>	
		</div>		
	 	<!-- 		표시갯수:${paginationInfo.recordCountPerPage}
		<b>&nbsp;/&nbsp;</b> 
		검색 게시물 ${paginationInfo.totalRecordCount}/${totalCnt}
		<b>&nbsp;/&nbsp;</b>
		<c:set var="N" 	value="${paginationInfo.totalRecordCount/paginationInfo.recordCountPerPage}" />
		현재 페이지 ${paginationInfo.currentPageNo}/ <fmt:formatNumber value="${N+(1-(N%1))%1}" type="number" pattern="#" />
		<a href="javascript:fn_reload()">새로고침</a><br> -->
		
		<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" summary="게시판 목록을 확인 할 수 있습니다.">
			<caption class="hidden">게시판 목록</caption>
			<colgroup>
				<col width="50">
				<col width="180">
				<col width="100">
				<col width="280">
				<col width="120">
				<col width="120">				
				<col width="80">
				<col width="">
			</colgroup>
			<thead>
				<tr>
					<th align="center"><spring:message code="susa.pr.view.no" /></th>
					<th align="center"><spring:message code="susa.pr.view.place1" /></th>
					<th align="center"><spring:message code="susa.pr.view.chargeNm" /></th>
					<th align="center"><spring:message code="susa.pr.view.title" /></th>
					<th align="center"><spring:message code="susa.pr.view.sdate" /></th>
					<th align="center"><spring:message code="susa.pr.view.edate" /></th>
					<th align="center"><spring:message code="susa.pr.view.result" /></th>
					<th align="center"><spring:message code="board.header.attach" /></th>
				</tr>
			</thead>
			<c:choose>
			<c:when test="${fn:length(susaList) > 0}">
				<c:forEach var="result" items="${susaList}" varStatus="status">
				<tr>
					<td align="center">
						${(paginationInfo.currentPageNo-1) * paginationInfo.recordCountPerPage + status.index + 1}
					</td>
					<td align="left"><c:out value="${result.place1Str}" /></td>
					<td align="center"><c:out value="${result.chargeNm}" /></td>
					<td align="left">
						<a href="javascript:fn_select('<c:out value="${result.idx}"/>')">
							<c:out value="${result.title}" />
						</a>
					</td>
					<td align="center">
						<fmt:parseDate value="${result.sdate}" pattern="yyyyMMdd" var="sdate" scope="page" />
						<fmt:formatDate value="${sdate}" pattern="yyyy-MM-dd" />
					</td>
					<td align="center">
						<fmt:parseDate value="${result.edate}" pattern="yyyyMMdd" var="edate" scope="page" />
						<fmt:formatDate value="${edate}" pattern="yyyy-MM-dd" />
					</td>
					<td align="center">
						${result.resultFlag}
					</td>
					<td align="center">
						<c:choose>
							<c:when test="${result.fileCnt > 0}">O</c:when>
							<c:otherwise>-</c:otherwise>
						</c:choose>
					</td>
				</tr>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td align="center" colspan="8"><spring:message code="msg.nodata" /></td>
				</tr>
			</c:otherwise>
			</c:choose>
		</table>
	</div>
	<!-- /List -->
	<div id="paging">
		<ui:pagination paginationInfo="${paginationInfo}" type="image"
			jsFunction="fn_link_page" />
	</div>	
</form:form>
<form:form commandName="searchVO" name="menuForm" method="get">
	<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>
	<!-- <div id="sysbtn">
		<ul>
			<li>
				<a href="javascript:fn_addView();"><spring:message code="button.create" /></a> 
			</li>
			<li>
        		<a href="/susa/promot/listtoexcel.do"><spring:message code="button.excel" /></a>
   			</li>
		</ul>
	</div> -->
</form:form>

<script type="text/javaScript" defer="defer">
<!--
	/* 글 상세 화면 function */
	function fn_select(id) {
		document.listForm.idx.value = id;
		document.listForm.action = "<c:url value='/susa/promot/view.do'/>";
		document.listForm.submit();
	}

	/* 글 목록 화면 function */
	function fn_selectList() {
		document.searchForm.action = "<c:url value='/susa/promot/list.do'/>";
		document.searchForm.submit();
	}

	/* 글 등록 화면 function */
	function fn_addView() {
		document.menuForm.action = "<c:url value='/susa/promot/add.do'/>";
		document.menuForm.submit();
	}

	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/susa/promot/list.do'/>";
		document.searchForm.submit();
	}
	/* 새로고침 function */
	function fn_reload() {
		location.reload();
	}
	
	function fn_exportToExcel() {
		document.searchForm.action = "<c:url value='/susa/promot/listtoexcel.do'/>";
		document.searchForm.submit();
		document.searchForm.action = "";
	}	
//-->
</script>