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

<form:form commandName="reportSearchVO" name="searchForm" method="get">
	<form:hidden path="orderCol"/>
	<form:hidden path="orderAsc"/>
	<form:hidden path="pageIndex" />
	
	<div class="search2">
		<ul>
		 	<li class="margin-left">
		 		<b><spring:message code="report.search.period" /></b>
		 	</li>
		 	<li class="margin-left">
		 		<form:input path="dateStart" /> ~ <form:input path="dateEnd"/>
		 	</li>
		</ul>
		<ul class="mt-20">
		 	<li class="margin-left">
		 		<b><spring:message code="report.search.title" /></b>
		 	</li>
		 	<li class="w-320 margin-left">
		 		<form:input path="subject"/>
		 	</li>
			<li class="margin-left">
				<b><spring:message code="report.search.reporter" /></b>
			</li>
			<li class="w-240 margin-left">
				<form:input path="writeName"/>
			</li>
			<li>
				<input type="button" value="<spring:message code="button.goSearch" />" onclick="javascript:fn_search();" />
			</li>  
		</ul>
	</div>
	
</form:form>


<!-- List -->
<div id="table">
	<div class="pageinfo">
		<ct:pageInfo />
		<ul class="right btn-style-text">
			<li><a href="javascript:selectAll();"><spring:message code="button.selectAll" /></a></li>
			<li><a href="javascript:unselectAll();"><spring:message code="button.unselectAll" /></a></li>
			<li><a href="javascript:deleteSelectedItem();"><spring:message code="button.delSelected" /></a></li>
			<li><a href="#" onclick="javascript:fn_get_excel();">엑셀받기</a></li>
			<li><a href="#" 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="150">
			<col width="100">
			<col width="?">
			<col width="100">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
			<col width="34">
		</colgroup>
		
		<thead>
			<tr>
				<th align="center" rowspan="2"><spring:message code="report.list.select" /></th>
				<th align="center" rowspan="2"><span class="order" value="in_seq"><spring:message code="report.list.num" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				<th align="center" rowspan="2"><span class="order" value="in_name"><spring:message code="report.search.reporter" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				<th align="center" rowspan="2"><span class="order" value="in_subject"><spring:message code="board.header.title" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				<th align="center" rowspan="2"><span class="order" value="in_infodate"><spring:message code="report.view.infodate" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				<th align="center" colspan="2" class="tbl_list_col"><spring:message code="report.view.approval" /></th>
				<th align="center" colspan="8" class="tbl_list_col"><spring:message code="report.type.judge" /></th>
			</tr>
			<tr>
				<th align="center">담당관</th>
				<th align="center">팀장</th>
				<th align="center"><spring:message code="report.type.newsflash" /></th>
				<th align="center"><spring:message code="report.type.judge" /></th>
				<th align="center"><spring:message code="report.type.middle" /></th>
				<th align="center"><spring:message code="report.type.notice" /></th>
				<th align="center"><spring:message code="report.type.record" /></th>
				<th align="center"><spring:message code="report.type.survey" /></th>
				<th align="center"><spring:message code="report.type.reference" /></th>
				<th align="center" width="20"><spring:message code="report.type.worthless" /></th>
			</tr>
		</thead>
		
		<form:form name="reportForm" commandName="reportVO" method="post">
		<c:forEach var="result" items="${reportList}" varStatus="status">
			<tr>
				<td align="center">
					<input type="checkbox" class="cbInSeq" name="reportList[${status.index}].inSeq" value="${result.inSeq}"/>
				</td>
				<td align="left">
					국제정보분석-<c:out value="${result.inSeq}"/>
				</td>
				<td align="center">
					<c:out value="${result.inDuty}" /> <c:out value="${result.inName}" />
				</td>
				<td align="left">
					<a href="<c:url value="/report/updatePresent.do"><c:param name="inSeq" value="${result.inSeq}" /></c:url>">
						<c:out value="${result.inSubject}"/>
					</a>
				</td>
				<td align="center">
					<c:out value="${result.inInfodate}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isHead}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isSection}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge1}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge2}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge3}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge4}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge5}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge6}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge7}" />
				</td>
				<td align="center" class="bold">
					<c:out value="${result.isJudge8}" />
				</td>
			</tr>
		</c:forEach>
		</form:form>
		<c:if test="${reportList.size() <= 0 }">
			<tr><td align="center" colspan="18"><spring:message code="report.nodata" /></td></tr>
		</c:if>
	</table>
</div>

<div class="board_buttom">
	<ul class="btn-style right">			
		<li><a href="/report/add.do" class="btn_create"><spring:message code="button.writeReport" /></a></li>
	</ul>
</div>

<!-- /List -->

<div id="paging">
	<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
</div>

<script type="text/javascript">
<!--
	$(document).ready(function(){
		//날짜 설정
		$('input[id^="date"]').datepicker({dateFormat: 'yy-mm-dd'});

		// 정렬
		if (document.searchForm.orderCol && document.searchForm.orderCol.value.length > 0) {
			$('.order[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.action = "<c:out value='/report/presentList.do' />";
			document.searchForm.submit();
		});
	});

	// 검색하기
	function fn_search() {
		document.searchForm.action = "<c:out value='/report/presentList.do' />";
		document.searchForm.submit();
	}

	// 엑셀받기
	function fn_get_excel() {
		document.searchForm.action = "<c:out value='/report/presentExcel.do' />";
		document.searchForm.submit();
	}

	/* 전체선택 버튼 function */
	function selectAll() {
		$('.cbInSeq').prop('checked', true);
	}

	/* 선택해제 버튼 function */
	function unselectAll() {
		$('.cbInSeq').prop('checked', false);
	}

	// 선택삭제
	function deleteSelectedItem() {
		if($('.cbInSeq:checked').length == 0){
			alert('삭제할 견문을 선택해주십시오.');
		}
		else {
			if (confirm('<spring:message code="report.msg.askDel" arguments="' + $('.cbInSeq:checked').length + '" />')) {
				var selectedSeq = $('.cbInSeq:checked').map(function(){return {inSeq:$(this).val()}}).get();
				$.ajax({
					url: '<c:out value="/report/delete.do"/>',
					type: 'post',
					data: {selectedSeq: selectedSeq},
					dataType: 'json',
					success: function (data) {
						location.reload();
					}
				});
			}
		}
	}
		
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/report/presentList.do'/>";
		document.searchForm.submit();
	}
-->
</script>
