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

<c:set var="dutiesCode" value="${myDutiesCode}"/>

<form:form name="listForm" commandName="reportSearchVO"  method="get">
	<form:hidden path="pageIndex"/>
	<form:hidden path="orderCol"/>
	<form:hidden path="orderAsc"/>
	
	<div class="pageinfo">
		<c:if test="${dutiesCode >= 2}">
		<ul class="right btn-style-text">
			<li>
				<a href="javascript:fn_selectAll();"><spring:message code="button.selectAll" /></a>
			</li>
			<li>
				<a href="javascript:fn_unselectAll();"><spring:message code="button.unselectAll" /></a>
			</li>
			<li>
				<a href="javascript:fn_submit();"><spring:message code="button.goApproval" /></a>
			</li>
		</ul>
		</c:if>
	</div>
</form:form>
	
<div id="table">
	
	<div class="pageinfo">
		<ct:pageInfo />
		<ul class="right btn-style">
			<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="90">
			<col width="150">
			<col width="90">
			<col width="90">
			<col width="200">
			<col width="100">
			<col width="90">
			<col width="30">
			
		</colgroup>
		<thead>
			<tr>
				<th align="center"><span class="order" value="in_regdate"><spring:message code="board.header.regdate" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				<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_category4"><spring:message code="report.view.division" /><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"><span class="order" value="in_state_code"><spring:message code="report.view.state" /><img src="/images/cmmn/blank_1x1.png" /></span></th>
				
				<c:if test="${dutiesCode >= 2}">
					<th align="center"><spring:message code="report.list.select" /></th>
					<c:if test="${dutiesCode == 3}">
						<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>
						<c:if test="${myGroupCode ne 3}">
							<th align="center"><spring:message code="report.type.fullReport" /></th>
						</c:if>
					</c:if>
					<th align="center"><spring:message code="report.view.opinion" /></th>
				</c:if>
			
			</tr>
		</thead>
		
		<form:form name="reportForm" commandName="reportVO" method="post">
		<c:forEach var="result" items="${reportList}" varStatus="status">
			<tr>
				<td align="center">
					<c:out value="${result.inRegdate}"/>
				</td>
				<td align="left">
					<c:out value="${result.docNo}"/>
				</td>
				<td align="center">
					<c:out value="${result.reporter}" />
				</td>
				<td align="center">
					<c:out value="${result.inCategory4Str}"/>
				</td>
				<td align="left">
					<a href="<c:url value="/report/approval.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.stateCodeName}" />
				</td>
				
				<c:if test="${dutiesCode >= 2}">
				
					<td align="center">
						<c:set var="useCategory" value="0" />
						<c:forEach var="cate" items="${category4}">
							<c:choose>
								<c:when test="${cate.value eq  result.inCategory4Str}">
									<input type="checkbox" class="cbInSeq" name="reportList[${status.index}].inSeq" value="${result.inSeq}"/>
									<c:set var="useCategory" value="1" />
								</c:when>
							</c:choose>
						</c:forEach>
						<c:if test="${useCategory == 0}" >
							<input type="checkbox" class="notUseCategory" name="" value=""  />
						</c:if>
					</td>
					
					
					<c:if test="${dutiesCode == 3}">
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="1"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="2"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="3"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="4"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="5"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="6"/></td>
						<td align="center"><input type="radio" name="reportList[${status.index}].inJudge" value="7" checked="checked"/></td>
						<c:if test="${myGroupCode ne 3}">
							<td align="center"><input type="checkbox" name="reportList[${status.index}].inReport" value="1"/></td>
						</c:if>
					</c:if>
					<td align="center"><input type="text" name="reportList[${status.index}].juMsg"/></td>
				</c:if>
			</tr>
		</c:forEach>
		</form:form>
		<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>


<script type="text/javascript">
<!--
	$(document).ready(function(){
		// 결재 후 메시지
		var errorMsg = '<c:out value="${errorMsg}" />';
		if (errorMsg != "") {
			alert(errorMsg);
		}
		
		// 정렬
		var orderCol = '<c:out value="${reportSearchVO.orderCol}" />';
		var orderAsc = '<c:out value="${reportSearchVO.orderAsc}" />';
		if (orderCol.length > 0) {
			$('span[value=' + orderCol + '] img').attr('src', (orderAsc == 'DESC') ? '/images/cmmn/order_desc.gif' : '/images/cmmn/order_asc.gif');
		}
		$('.order').click(function(){
			var ordercode = $(this).attr('value');
			if (document.listForm.orderCol.value == ordercode) {
				if (document.listForm.orderAsc.value == 'ASC') {
					document.listForm.orderAsc.value = 'DESC';
				} else {
					document.listForm.orderAsc.value = 'ASC';
				}
			} else {
				document.listForm.orderAsc.value = 'DESC';
			}
			document.listForm.orderCol.value = ordercode;
			
			document.listForm.action = "<c:out value='/report/waitList.do' />";
			document.listForm.submit();
		});
	});

	/* pagination 페이지 링크 function */
	function fn_link_page(pageNo) {
		document.listForm.pageIndex.value = pageNo;
		document.listForm.action = "<c:url value='/report/waitList.do'/>";
		document.listForm.submit();
	}
	
	/* 전체선택 버튼 function */
	function fn_selectAll() {
		$('input.cbInSeq').prop('checked', true);
	}

	/* 선택해제 버튼 function */
	function fn_unselectAll() {
		$('input.cbInSeq').prop('checked', false);
	}
	
	/* 결재하기 버튼 function */
	function fn_submit() {
		if($('.cbInSeq:checked').length == 0){
			alert('결재할 견문을 선택해주십시오.');
		}
		else {
			if (confirm('<spring:message code="report.msg.askApproval" arguments="' + $('.cbInSeq:checked').length + '" />')) {
				document.reportForm.action = "<c:url value='/report/approval.do'/>";
				document.reportForm.submit();
			}
		}
	}
	
	
	/*축소된 분야를 체크했을 경우*/
	$('.notUseCategory').click(function(){
		if($(this).is(":checked")){
			alert('견문구분(분야 4) 항목이 축소되어 결재를 진행할 수 없습니다.\n제목을 클릭하여 분야 4를 변경 후 결재를 진행하시기 바랍니다.');
			$(this).prop("checked", false);
		}
	});

-->




</script>
