<%@ 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" %>
<style type="text/css">input.goalTotal {width: 20px;}</style>

<form:form commandName="reportSearchVO" name="searchForm" method="get">
	<div class="search2">
		<ul>
		 	<li>
		 		<b><spring:message code="report.search.period" /></b>
		 	</li>
		 	<li class="form_search margin-left">
		 		<form:select path="year" cssClass="use">
					<c:forEach var="item" items="${yearList}" varStatus="status">
		 				<form:option value="${item}" label="${item}년"/>
					</c:forEach>
		 		</form:select>
		 	</li>
		 	<li class="form_search">
		 		<form:select path="month" cssClass="use">
					<c:forEach var="item" items="${monthList}" varStatus="status">
		 				<form:option value="${item}" label="${item}월"/>
					</c:forEach>
		 		</form:select>
		 	</li>
		 	<c:if test="${authAdmin > 0}">
			 	<li class="margin-left">
			 		<b><spring:message code="report.search.place" /></b>
			 	</li>
			 	<li class="form_search margin-left">
			 		<form:select path="placeGroup" cssClass="use">>
						<c:forEach var="item" items="${placeList}">
							<form:option value="${item.code2}" label="${item.codenm}" />
						</c:forEach>
					</form:select>	
			 	</li>
			 </c:if>
		</ul>
	</div>
	
	<!-- 상위 버튼 -->
	<div class="pageinfo">
		<ul class="right btn-style">
			<li><a class="btn_update" href="javascript:update();"></a></li>
		</ul>
	</div>
</form:form>


<!-- List -->
<div id="table">
	
	<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0" summary="게시판 목록을 확인 할 수 있습니다.">
		<caption class="hidden">목표 관리 목록</caption>
		<colgroup>
			<col width="50"/>
			<col width="80"/>
			<col width="?"/>
			<col width="?"/>
			<col width="?"/>
			<col width="80"/>
		</colgroup>
		<thead>
			<tr>
				<th align="center"><spring:message code="report.goal.no" /></th>
				<th align="center"><spring:message code="report.goal.name" /></th>
				<th align="center"><spring:message code="report.goal.agent" /></th>
				<th align="center"><spring:message code="report.goal.foreignCoop" /></th>
				<th align="center"><spring:message code="report.goal.infoCoop" /></th>
				<th align="center"><spring:message code="report.goal.sum" /></th>
			</tr>
		</thead>
		<tbody>
		
		<fmt:parseNumber var="year" integerOnly="true" type="number" value="${reportSearchVO.year}" />
		<fmt:parseNumber var="month" integerOnly="true" type="number" value="${reportSearchVO.month}" />
		
		<form:form commandName="reportGoalVO" name="reportGoalForm" methos="post">
		<input type="hidden" name="goPlace1" value="${reportSearchVO.placeGroup}"/>
		<input type="hidden" name="goYear" value="${year}"/>
		<input type="hidden" name="goMonth" value="${month}"/>
		
		<c:forEach var="item" items="${goalList}" varStatus="status">
			<input type="hidden" name="reportGoalList[${status.index}].goId" value="${item.goId}" />
			<tr class="tbl_list_input">
				<td align="center">
					<c:out value="${item.rn}"/>
				</td>
				<td align="center">
					<c:out value="${item.name}"/>
				</td>
				
				<!-- 전종요원 -->
				<td align="center">
					<c:choose>
						<c:when test="${item.goGoal1 > 0}">
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="0" id="goal10${status.index}"/>
						</c:when>
						<c:otherwise>
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="0" id="goal10${status.index}" checked="checked"/>
						</c:otherwise>
					</c:choose>
					<label for="goal10${status.index}"><spring:message code="report.goal.notExist"/></label>
					
					<c:choose>
						<c:when test="${item.goGoal1 eq 2}">
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="2" id="goal12${status.index}" checked="checked"/>
						</c:when>
						<c:otherwise>
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="2" id="goal12${status.index}"/>
						</c:otherwise>
					</c:choose>
					<label for="goal12${status.index}"><spring:message code="report.goal.deskJob"/></label>
					
					<c:choose>
						<c:when test="${item.goGoal1 eq 4}">
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="4" id="goal14${status.index}" checked="checked"/>
						</c:when>
						<c:otherwise>
							<input type="radio" name="reportGoalList[${status.index}].goGoal1" value="4" id="goal14${status.index}"/>
						</c:otherwise>
					</c:choose>
					<label for="goal14${status.index}"><spring:message code="report.goal.outsideJob"/></label>
					
					<input type="text" readonly="readonly" class="goalTotal" id="goal1Total${status.index}" value="${item.goGoal1}">
				</td>
				
				<!-- 대외협력 -->
				<td align="center">
					<c:choose>
						<c:when test="${item.goGoal2 > 0}">
							<input type="radio" name="reportGoalList[${status.index}].goGoal2" value="0" id="goal20${status.index}"/>
						</c:when>
						<c:otherwise>
							<input type="radio" name="reportGoalList[${status.index}].goGoal2" value="0" id="goal20${status.index}" checked="checked"/>
						</c:otherwise>
					</c:choose>
					<label for="goal20${status.index}"><spring:message code="report.goal.notExist"/></label>
					
					<c:choose>
						<c:when test="${item.goGoal2 eq 2}">
							<input type="radio" name="reportGoalList[${status.index}].goGoal2" value="2" id="goal22${status.index}" checked="checked"/>
						</c:when>
						<c:otherwise>
							<input type="radio" name="reportGoalList[${status.index}].goGoal2" value="2" id="goal22${status.index}"/>
						</c:otherwise>
					</c:choose>
					<label for="goal22${status.index}"><spring:message code="report.goal.exist"/></label>
					
					<input type="text" readonly="readonly" class="goalTotal" id="goal2Total${status.index}" value="${item.goGoal2}">
				</td>
				
				<!-- 정보협력 -->
				<td align="center">
					<c:choose>
					<c:when test="${year > 2010 or (year == 2010 and month >= 10)}">
						<c:choose>
							<c:when test="${item.goGoal3 > 0}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="0" id="goal30${status.index}"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="0" id="goal30${status.index}" checked="checked"/>
							</c:otherwise>
						</c:choose>
						<label for="goal30${status.index}"><spring:message code="report.goal.notExist"/></label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 3}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="3" id="goal31${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="3" id="goal31${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal31${status.index}">A</label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 2}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal32${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal32${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal32${status.index}">B</label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 2}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal33${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal33${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal33${status.index}">C</label>
					</c:when>
					
					<c:otherwise>
					<spring:message code="report.goal.notExist"/>
						<c:choose>
							<c:when test="${item.goGoal3 > 0}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="0" id="goal30${status.index}"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="0" id="goal30${status.index}" checked="checked"/>
							</c:otherwise>
						</c:choose>
						<label for="goal30${status.index}"><spring:message code="report.goal.notExist"/></label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 5}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="5" id="goal35${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="5" id="goal35${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal35${status.index}">A</label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 3}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="3" id="goal33${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="3" id="goal33${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal33${status.index}">B</label>
						
						<c:choose>
							<c:when test="${item.goGoal3 eq 2}">
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal32${status.index}" checked="checked"/>
							</c:when>
							<c:otherwise>
								<input type="radio" name="reportGoalList[${status.index}].goGoal3" value="2" id="goal32${status.index}"/>
							</c:otherwise>
						</c:choose>
						<label for="goal32${status.index}">C</label>
					</c:otherwise>
					</c:choose>
						
					<input type="text" readonly="readonly" class="goalTotal" id="goal3Total${status.index}" value="${item.goGoal3}">
				</td>
				
				<!-- 계 -->
				<td align="center">
					<input type="text" name="reportGoalList[${status.index}].goTotal" id="total${status.index}" value="${item.goTotal}"/>
				</td>
			</tr>
		</c:forEach>
		</form:form>
		</tbody>
	</table>
</div>
<!-- /List -->

<script type="text/javascript">
<!--
	function update() {
		$('form[name=reportGoalForm]').submit();
	}

	$(document).ready(function(){
		$('input[id^=goal]').each(function(){
			$(this).click(function(){
				var val = $(this).val(),
					id = $(this).attr('id'),
					type = id.substr($(this).attr('id').length - 3, 1),
					idx = id.substr($(this).attr('id').length - 1, 1);
				$('#goal' + type + 'Total' + idx).val(val);
				
				$('#total' + idx).val(
					parseInt($('#goal1Total' + idx).val()) + parseInt($('#goal2Total' + idx).val()) + parseInt($('#goal3Total' + idx).val())
				);
			});
		});
		
		$('#year').change(function(){
			$('form[name=searchForm]').submit();
		});
		
		$('#month').change(function(){
			$('form[name=searchForm]').submit();
		});
		
		$('#placeGroup').change(function(){
			$('form[name=searchForm]').submit();
		});
	});

-->
</script>
