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

<div id ="divPrintTitle" style="display: none;margin: 10px 0 10px 0;">
	<spring:message code="report.title" />
</div>
<div class="pageinfo">
	<ul class="right btn-style">
		<li>
			<a class="btn_print" href="<c:url value="/report/print.do"><c:param name="inSeq" value="${reportVO.inSeq}" /></c:url>" target="_blank">
				<spring:message code="button.goPrint" />
			</a>
		</li>
	</ul>
</div>

<fmt:parseNumber var="num1" type="number" value="${reportVO.inStateCode.charAt(0)}" />
<fmt:parseNumber var="num2" type="number" value="${reportVO.inStateCode.charAt(1)}" />

<form:form commandName="reportVO" name="formReprotApprove" id="formReprotApprove" enctype="multipart/form-data" method="post">
	<form:hidden path="inSeq"/>
	<form:hidden path="inFsseq"/>
	<form:hidden path="inStateCode"/>
	
	<div id="table">
		
		<table class="tbl_add">
			<colgroup>
	   			<col width="100"/>
	   			<col width="150"/>
	   			<col width="100"/>
	   			<col width="150"/>	   			
	   			<col width="100"/>
	   			<col width="150"/>	   			
	   			<col width="100"/>
	   			<col width=""/>
	   		</colgroup>	
	   		<tr>
	   			<th><spring:message code="report.list.num"/></th>
	   			<td>
	   				<c:if test="${reportVO.inStateCode eq '99'}"><spring:message code="report.view.saveDocNo" /></c:if>
	   				<c:if test="${reportVO.inStateCode ne '99'}">${reportVO.inPlaceName} 국제정보분석-${reportVO.inPlaceNum}</c:if>
	   			</td>
	   			<th><spring:message code="report.view.name" /></th>
	   			<td align="center" >${userType} ${reportVO.inDuty} ${reportVO.inName}</td>
	   		<c:choose>
			<c:when test="${viewDoc eq true}">
				<th><spring:message code="report.view.category1" /></th>
				<td align="left"><c:out value="${reportVO.inCategory1Str}" /></td>
				<th><spring:message code="report.view.category2" /></th>
				<td align="left"><c:out value="${reportVO.inCategory2Str}" /></td>				
			</c:when>
			<c:otherwise>		
				<th><spring:message code="report.view.category1" /></th>
				<td class="form_select">
					<form:select path="inCategory1">
						<c:forEach var="cate" items="${category1}">
							<c:if test="${cate.key eq reportVO.inCategory1}"><form:option selected="true" value="${cate.key}" label="${cate.value}" /></c:if>
							<c:if test="${cate.key ne reportVO.inCategory1}"><form:option value="${cate.key}" label="${cate.value}" /></c:if>
						</c:forEach>
					</form:select>
				</td>
				<th><spring:message code="report.view.category2" /></th>
				<td class="form_select">
					<form:select path="inCategory2">
						<c:forEach var="cate" items="${category2}">
							<c:if test="${cate.key eq reportVO.inCategory2}"><form:option selected="true" value="${cate.key}" label="${cate.value}" /></c:if>
							<c:if test="${cate.key ne reportVO.inCategory2}"><form:option value="${cate.key}" label="${cate.value}" /></c:if>
						</c:forEach>
					</form:select>
				</td>
					</c:otherwise>
			</c:choose>					
			</tr>				
			<tr>
				<th><spring:message code="report.view.memo" /></th>						
				<td colspan="7">
					<c:if test="${viewDoc eq true}"><c:out value="${reportVO.inMemo}" /></c:if>
					<c:if test="${viewDoc eq false}"><form:input path="inMemo" cssClass="txt" /></c:if>
				</td>
			</tr>								
			<tr>
				<th><spring:message code="board.header.title"/></th>
				<td colspan="7">					
					<c:if test="${viewDoc eq true}"><c:out value="${reportVO.inSubject}"/></c:if>
					<c:if test="${viewDoc eq false}">
						<form:input id="title" path="inSubject" maxlength="150" cssClass="txt"/>						
					</c:if>					
				</td>
			</tr>
			<tr>
	   			<th>
	   				<spring:message code="board.view.content" />
	   			</th>
	   			<td colspan="7">
	            	<c:if test="${viewDoc eq true}">
	            		<c:out value="${reportVO.inContent}" escapeXml="false"/>
	            	</c:if>
	            	<c:if test="${viewDoc eq false}">
			            <form:textarea path="inContent" rows="5" cols="58" htmlEscape="false"/>&nbsp;<form:errors path="inContent" />
	   					<ckeditor:replace replace="inContent" basePath="${pageContext.request.contextPath}/ckeditor/" />
	   					<span><spring:message code="etc.editor.descript"/></span>
		   			</c:if>
	            </td>
	   		</tr>
			<tr>
	   			<th>
	   				<spring:message code="board.view.attach" />1
	   			</th>
	            <td colspan="7">
					<c:if test="${not empty fn:trim(reportVO.inFile1)}">
						<p>
							<a href="/report/download.do?seq=<c:out value="${reportVO.inSeq}"/>&no=1" target="_blank">
					       		<c:out value="${reportVO.inFile1}"/>
					       	</a>
					       	<c:if test="${viewDoc eq false}">
								<input type="checkbox" name="deleteFile" value="1"/>삭제
								<c:set var="existOrder" value="${true}"/>
							</c:if>
						</p>
					</c:if>
					<c:if test="${viewDoc eq false}">
						<p><input type="file" name="fileObj1" class="input_file" size="60" /></p>
					</c:if>
	            </td>
			</tr>
			<tr>
	   			<th>
	   				<spring:message code="board.view.attach" />2
	   			</th>
	            <td colspan="7">
					<c:if test="${not empty fn:trim(reportVO.inFile2)}">
						<p>
							<a href="/report/download.do?seq=<c:out value="${reportVO.inSeq}"/>&no=2" target="_blank">
					       		<c:out value="${reportVO.inFile2}"/>
					       	</a>
					       	<c:if test="${viewDoc eq false}">
								<input type="checkbox" name="deleteFile" value="2"/>삭제
								<c:set var="existOrder" value="${true}"/>
							</c:if>
						</p>
					</c:if>
					<c:if test="${viewDoc eq false}">
						<p><input type="file" name="fileObj2" class="input_file" size="60" /></p>
					</c:if>
				</td>
			</tr>
			<tr>
	   			<th>
	   				<spring:message code="board.view.attach" />3
	   			</th>
	            <td colspan="7">
					<c:if test="${not empty fn:trim(reportVO.inFile3)}">
						<p>
							<a href="/report/download.do?seq=<c:out value="${reportVO.inSeq}"/>&no=3" target="_blank">
					       		<c:out value="${reportVO.inFile3}"/>
					       	</a>
					       	<c:if test="${viewDoc eq false}">
								<input type="checkbox" name="deleteFile" value="3"/>삭제
								<c:set var="existOrder" value="${true}"/>
							</c:if>
						</p>
					</c:if>
					<c:if test="${viewDoc eq false}">
						<input type="file" name="fileObj3" class="input_file" size="60" />
					</c:if>
				</td>
			</tr>
			<tr>
				<th>
					<spring:message code="report.view.infodate" />
				</th>
				<td colspan="7">
					<c:if test="${viewDoc eq true}">
						<c:out value="${reportVO.inInfodate}"/>
					</c:if>
					<c:if test="${viewDoc eq false}">
		   				<form:input path="strInfodate" cssClass="txt" readonly="true" value="${reportVO.inInfodate}" />
					</c:if>
				</td>
			</tr>
			<tr>
				<th>
					<spring:message code="report.view.state"/> 
				</th>
				<td colspan="7">
					<span class="save"><c:out value="${reportVO.stateCodeName}" /></span>
					<span style="color:#c8c8c8;">(<c:out value="${reportVO.inStateCode}"/>)</span>
				</td>
			</tr>
			<c:if test="${reportVO.inOfflineType ne '0' and reportVO.inOfflineType ne '' and reportVO.inOfflineType ne null}">
				<tr>
					<th>
						<spring:message code="menu.report.manage.offline_write"/>
					</th>
					<td colspan="7">
						<c:if test="${reportVO.inOfflineType eq '1'}"><spring:message code="member.type.fa" /> </c:if>
						<c:if test="${reportVO.inOfflineType eq '2'}"><spring:message code="member.type.nofa" /> </c:if>
						<c:out value="${offUser.place1Str} " />
						<c:out value="${offUser.positionStr} " />
						<c:out value="${offUser.name}" />(<c:out value="${offUser.userid}" />)
						<c:if test="${offUser.duties ne '없음'}"><c:out value="${offUser.duties}" /></c:if>
					</td>
				</tr>
			</c:if>
		</table>
		 
		<c:if test="${reportVO.stateCodeName eq '결재 완료'}">
			<table class="tbl_add">
				<tr class="th-bg">
					<th style="text-align:center;"><spring:message code="report.type.newsflash"/></th>
					<th style="text-align:center;"><spring:message code="report.type.judge"/></th>
					<th style="text-align:center;"><spring:message code="report.type.middle"/></th>
					<th style="text-align:center;"><spring:message code="report.type.notice"/></th>
					<th style="text-align:center;"><spring:message code="report.type.record"/></th>
					<th style="text-align:center;"><spring:message code="report.type.survey"/></th>
					<th style="text-align:center;"><spring:message code="report.type.reference"/></th>
					<th style="text-align:center;"><spring:message code="report.type.worthless"/></th>
				</tr>
				<tr>
					<td align="center"><c:if test="${reportVO.inJudge eq 1}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 2}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 3}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 4}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 5}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 6}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 7}">○</c:if></td>
					<td align="center"><c:if test="${reportVO.inJudge eq 8}">○</c:if></td>
				</tr>
			</table>
		</c:if>
		<c:if test="${num2 >= 2 }">
		<table class="tbl_add">
				<tr class="th-bg">
					<th>-</th>
					<th style="text-align:center;"><spring:message code="report.type.newsflash"/></th>
					<th style="text-align:center;"><spring:message code="report.type.judge"/></th>
					<th style="text-align:center;"><spring:message code="report.type.middle"/></th>
					<th style="text-align:center;"><spring:message code="report.type.notice"/></th>
					<th style="text-align:center;"><spring:message code="report.type.record"/></th>
					<th style="text-align:center;"><spring:message code="report.type.survey"/></th>
					<th style="text-align:center;"><spring:message code="report.type.reference"/></th>
					<th style="text-align:center;"><spring:message code="report.type.worthless"/></th>
				</tr>
				<tr>
					<td align="center">
					<c:choose>
							<c:when test="${fn:trim(juSection.juPlace1) ne ''}"><c:out value="${juSection.juPlace1}" /></c:when>
							<c:when test="${fn:trim(juHead.juPlace1) ne ''}"><c:out value="${juHead.juPlace1}" /></c:when>
							<c:when test="${docGroupCode eq 3}"><c:out value="${reportVO.inPlace1}" /></c:when>
							<c:otherwise><spring:message code="msg.noInfo"/></c:otherwise>
						</c:choose>
					</td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="1"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="2"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="3"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="4"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="5"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="6"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="7"/></c:if></td>
					<td align="center"><c:if test="${myDutiesCode eq 3}"><form:radiobutton path="inJudge" value="8" checked="checked" /></c:if></td>/
				</tr>
				<tr>
					<th>평가자</th>
					<td colspan="8">
						<c:if test="${not empty approveInfo}">
							<c:out value="${approveInfo.name}" /> 
						</c:if>
						<c:if test="${empty approveInfo}">
							<spring:message code="report.noSet"/>
						</c:if>
						<c:if test="${approveInfo.userid ne loginUserVO.userid}">
							<span style="color:#00f;">(<c:out value="${loginUserVO.name}"/> <c:out value="${loginUserVO.dutyStr}"/> 대행)</span>
						</c:if>
					</td>
				</tr>
				<tr>
					<th>검토의견</th>
					<td colspan="8">
						<form:input path="juMsg"/>
					</td>
				</tr>
			</table>
		</c:if>
	</div>
	
	<div class="boardviewinfo">
		<ul class="right btn-style">
			<c:if test="${num2 < 4 and viewDoc eq false}">
			<li>
				<a href="javascript:fn_report();"><spring:message code="button.goApproval" /></a>
			</li>
			</c:if>
			<li>
				<a href="javascript:history.back();"><spring:message code="button.goBack" /></a>
			</li>
		</ul>
	</div>
	
</form:form>

<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="reportVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" defer="defer">
	$(function(){
		$('#strInfodate').datepicker({dateFormat: 'yy-mm-dd'});
		
		var result = "<c:out value="${errorMsg}"/>";
		if (result != "") {
			alert(result);
		}
	});

	function fn_report() {
		frm = document.formReprotApprove;
		frm.action = "<c:out value="/report/approval.do"/>"
		frm.inStateCode.value = "${myGroupCode}" + "1";
		frm.inContent.value = encodeURIComponent(CKEDITOR.instances.inContent.getData());
		
		if(!validateReportVO(frm)){
	        return;
	    }else{
	       	frm.submit();
	    }
	}
</script>