<%@ 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" %>

<div id="tbCondition" style="display: none">
	<form:form commandName="reportSearchVO" id="searchForm" name="searchForm" method="get">
		<form:hidden path="orderCol"/>
		<form:hidden path="orderAsc"/>
		
		<form:hidden path="myGroupCode" />
		<form:hidden path="pageIndex" />
		<form:hidden path="dateStart"/>
		<form:hidden path="dateEnd"/>
		<form:hidden path="writeName"/>
		<form:hidden path="writeId"/>
		<c:forEach var="item" items="${reportSearchVO.places}">
			<input type="hidden" name="places" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.judges}">
			<input type="hidden" name="judges" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.fullReport}">
			<input type="hidden" name="fullReport" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.policeType}">
			<input type="hidden" name="policeType" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.category1}">
			<input type="hidden" name="category1" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.category2}">
			<input type="hidden" name="category2" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.category3}">
			<input type="hidden" name="category3" value="${item}"/>
		</c:forEach>
		<c:forEach var="item" items="${reportSearchVO.category4}">
			<input type="hidden" name="category4" value="${item}"/>
		</c:forEach>
		<form:hidden path="subject"/>
		<form:hidden path="filename"/>

		<table class="tbl_add">
			<colgroup>
				<col width="140"/>
				<col width="110"/>
				<col width="140"/>
				<col width="110"/>
				<col width="140"/>
				<col width="110"/>
				<col width="140"/>
				<col width="110"/>
			</colgroup>
			<tr>
				<th align="center"><spring:message code="report.search.period" /></th>
				<td colspan="7">
					<c:out value="${reportSearchVO.dateStart}"/> ~ <c:out value="${reportSearchVO.dateEnd}"/>
				</td>
			</tr>
			<tr>
				<th align="center"><spring:message code="report.search.reporter" /></th>
				<td colspan="3">
					<c:out value="${reportSearchVO.writeName}" />
				</td>
				<th align="center"><spring:message code="report.search.id" /></th>
				<td colspan="3">
					<c:out value="${reportSearchVO.writeId}"/>
				</td>
			</tr>
			<tr>
				<th align="center" rowspan="2"><spring:message code="report.search.place" /></th>
				<td rowspan="2" colspan="3">
					<ul><c:forEach var="place" items="${placeList}">
						<c:if test="${fn:contains(fn:join(reportSearchVO.places, ','), place.code2)}">
							<li style="width: 130px; float: left;"><c:out value="${place.codenm}"/></li>
						</c:if>
					</c:forEach></ul>
				</td>
				<th align="center" rowspan="2"><spring:message code="report.view.appraisal" /></th>
				<td rowspan="2">
					<c:forEach var="item" items="${reportSearchVO.judges}">
						<c:set var="judge">${item}</c:set>
						<p><c:out value="${judgeList[judge]}"/></p>
					</c:forEach>
				</td>
				<th align="center"><spring:message code="report.type.fullReport" /></th>
				<td valign="top">
					<c:if test="${fn:contains(fn:join(reportSearchVO.fullReport, ','), 1)}"><p>경찰서상보</p></c:if>
					<c:if test="${fn:contains(fn:join(reportSearchVO.fullReport, ','), 2)}"><p>지방청상보</p></c:if>
				</td>
			</tr>
			<tr>
				<th align="center"><spring:message code="report.view.division" /></th>
				<td valign="top">
					<c:if test="${fn:contains(fn:join(reportSearchVO.policeType, ','), 1)}"><p>외사경찰</p></c:if>
					<c:if test="${fn:contains(fn:join(reportSearchVO.policeType, ','), 2)}"><p>일반경찰</p></c:if>
				</td>
			</tr>
			<tr>
				<th align="center"><spring:message code="report.view.category1" /></th>
				<td valign="top">
					<c:forEach var="category" items="${reportSearchVO.category1}">
						<p><c:out value="${category1[category]}"/></p>
					</c:forEach>
				</td>
				<th align="center"><spring:message code="report.view.category2" /></th>
				<td valign="top">
					<c:forEach var="category" items="${reportSearchVO.category2}">
						<p><c:out value="${category2[category]}"/></p>
					</c:forEach>
				</td>
				<th align="center"><spring:message code="report.view.category3" /></th>
				<td valign="top">
					<c:forEach var="category" items="${reportSearchVO.category3}">
						<p><c:out value="${category3[category]}"/></p>
					</c:forEach>
				</td>
				<th align="center"><spring:message code="report.view.category4" /></th>
				<td valign="top">
					<c:forEach var="category" items="${reportSearchVO.category4}">
						<p><c:out value="${category4[category]}"/></p>
					</c:forEach>
				</td>
			</tr>
			<tr>
				<th align="center"><spring:message code="board.header.title" /></th>
				<td colspan="7"><c:out value="${reportSearchVO.subject}"/></td>
			</tr>
			<tr>
				<th align="center"><spring:message code="report.search.attachnm" /></th>
				<td colspan="7"><c:out value="${reportSearchVO.filename}"/></td>
			</tr>
		</table>
	</form:form>
</div>

<form:form name="listForm" method="get">	
	<div id="table">
		<div class="pageinfo">
			<ct:pageInfo />
			<ul class="right btn-style-text">
				<li>
					<a id="btnCondigion" href="#"><spring:message code="button.showCondition" /></a>
				</li>
				<li>
					<a href="javascript:searchAgain();"><spring:message code="button.searchAgain" /></a>				
				</li>
				<li>
					<a href="javascript:fn_get_excel();"><spring:message code="button.getExcel" /></a>				
				</li>
			</ul>		
		</div>		
		<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" summary="게시판 목록을 확인 할 수 있습니다.">
			<caption class="hidden">게시판 목록</caption>
			<colgroup>
				<col width="195">
				<col width="110">
				<col width="?">
				<col width="100">
				<col width="50">
				<col width="50">
				<col width="80">
				<col width="80">
				<col width="80">
				<col width="80">
			</colgroup>
			<thead>
				<tr>
					<th align="center"><span class="order" value="in_seq"><spring:message code="report.list.num" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_name"><spring:message code="report.search.reporter" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_subject"><spring:message code="board.header.title" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_infodate"><spring:message code="report.view.infodate" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center">
						<c:choose>
							<c:when test="${myGroupCode eq '3'}">
								<c:set var="judgeField" value="in_judge3"/>
							</c:when>
							<c:when test="${myGroupCode eq '2'}">
								<c:set var="judgeField" value="in_judge2"/>
							</c:when>
							<c:when test="${myGroupCode eq '1'}">
								<c:set var="judgeField" value="in_judge1"/>
							</c:when>
							<c:otherwise>
								<c:set var="judgeField" value="in_judge"/>
							</c:otherwise>
						</c:choose>
						<span class="order" value="${judgeField}"><spring:message code="report.view.appraisal" />
						</span>
					</th>
					<th align="center"><span class="order" value="in_report"><spring:message code="report.type.fullReport" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_cateogory1"><spring:message code="report.view.category1" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_cateogory2"><spring:message code="report.view.category2" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_cateogory3"><spring:message code="report.view.category3" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
					<th align="center"><span class="order" value="in_cateogory4"><spring:message code="report.view.category4" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				</tr>
			</thead>
			<c:forEach var="result" items="${reportList}" varStatus="status">
				<tr>
					<td align="left">
						<c:out value="${result.docNo}"/>
					</td>
					<td align="center">
						<c:out value="${result.reporter}" />
					</td>
					<td align="left">
						<a href="<c:url value="/report/updateList.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">
						<c:out value="${result.judgeStr}" />
					</td>
					<td align="center">
						<c:out value="${result.fullReportStr}" />
					</td>
					<td align="center">
						<c:out value="${result.inCategory1Str}" />
					</td>
					<td align="center">
						<c:out value="${result.inCategory2Str}" />
					</td>
					<td align="center">
						<c:out value="${result.inCategory3Str}" />
					</td>
					<td align="center">
						<c:out value="${result.inCategory4Str}" />
					</td>
				</tr>
			</c:forEach>
			<c:if test="${reportList.size() <= 0}">
				<tr><td align="center" colspan="10"><spring:message code="report.nodata" /></td></tr>
			</c:if>
		</table>
	</div>
	
	<div id="paging">
		<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
	</div>
</form:form>


<script type="text/javascript">
<!--
	$(document).ready(function(){
		// 조건보기
		$('#btnCondigion').click(function(){
			$('#tbCondition').toggle();
		});
		
		// 정렬
		if (document.searchForm.orderCol && document.searchForm.orderCol.value.length > 0) {
			console.log($('input[value=' + document.searchForm.orderCol.value + ']'));
			$('input[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/searchResult.do' />";
			document.searchForm.submit();
		});
	});

 	/* 다시 검색 */
	function searchAgain() {
		document.searchForm.action = "<c:out value='/report/search.do' />";
		document.searchForm.submit();
	}

	//견문 엑셀받기
	function fn_get_excel() {
		
		document.searchForm.action = "<c:out value='/report/listtoexcel.do' />";
		document.searchForm.submit();
	}
	
	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.searchForm.pageIndex.value = pageNo;
		document.searchForm.action = "<c:url value='/report/searchResult.do'/>";
		document.searchForm.submit();
	}
-->
</script>
