<%@ 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="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<form:form commandName="incidentVO" id="detailForm" name="detailForm" enctype="multipart/form-data">
	<form:hidden path="type" />
	<form:hidden path="writer" />
   	<div id="table">
   	<table class="tbl_add">
   		<colgroup>
   			<col width="180"/>
   			<col width=""/>
   			<col width="180"/>
   			<col width=""/>
   		</colgroup>
   		<tr>
   			<th>
   				<label for="title"><spring:message code="susa.in.view.place1" /></label>
   			</th>
   			<td colspan="3">
   				<label>${loginUserVo.place1Str}</label>
				<form:hidden path="place1" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="susa.in.view.chargeNm" /></label></th>
   			<td colspan="3">
   				<form:input path="chargeNm" />
   				<input type="checkbox" id="chkUserNameSetting" /><label for="chkUserNameSetting">작성자와 동일함</label>
   				<input type="hidden" id="hdChargeNm" value="${loginUserVo.name}" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="susa.in.view.title" /></label></th>
   			<td colspan="3">
   				<form:input path="title" cssClass="txt" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="susa.in.view.sdate" /></label></th>
   			<td>
   				<fmt:parseDate var="sdate" value="${incidentVO.sdate}" pattern="yyyyMMdd" scope="page" />
   				<fmt:formatDate var="sdate" value="${sdate}" pattern="yyyy-MM-dd" />
   				<form:input path="sdate" cssClass="txt" readonly="true" value="${sdate}" />
   			</td>
   			<th><label for="title"><spring:message code="susa.in.view.edate" /></label></th>
   			<td>
   			<fmt:parseDate var="edate" value="${incidentVO.edate}" pattern="yyyyMMdd" scope="page" />
   				<fmt:formatDate var="edate" value="${edate}" pattern="yyyy-MM-dd" />
   				<form:input path="edate" cssClass="txt" readonly="true" value="${edate}" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="susa.in.view.contents" /></label></th>
   			<td colspan="3">
   				<form:input path="contents" cssClass="txt" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="susa.in.view.result" /></label></th>
   			<td colspan="3">
   				<form:input path="result" cssClass="txt" />
   			</td>
   		</tr>
   		<tr>
   			<th><label for="title"><spring:message code="board.view.attach" /></label></th>
   			<td colspan="3">
   				<c:choose>
			       <c:when test="${registerFlag != 'modify'}">
				   		<p><input type="file" name="file1" class="input_file" size="60" /></p>
	   					<p><input type="file" name="file2" class="input_file" size="60" /></p>
	   					<p><input type="file" name="file3" class="input_file" size="60" /></p>
			       </c:when>
			       
			       <c:otherwise>
				       <c:forEach var="count" begin="1" end="3" varStatus="status">
				       		<p>
				       			<c:forEach var="file" items="${susaFileVO}"  varStatus="status2">
				       				<c:if test="${file.orders == status.index}">
				       					<input type="checkbox" name="deleteFile" value="${file.seq}"/>
				       					<c:out value="${file.orgName}"/>는 삭제합니다.
				       					<c:set var="existOrder" value="${true}"/>
				       				</c:if>
				       			</c:forEach>
				       			
				       			<c:if test="${existOrder eq null or existOrder == false}">
				       				<input type="file" name="file${status.count}" class="input_file" size="60" />
				       			</c:if>
			       				<c:set var="existOrder" value="${false}"/>
				       		</p>
						</c:forEach>
			       </c:otherwise>
		       	</c:choose>
   			</td>
   		</tr>
   	</table>
    </div>
    <div class="boardviewinfo">
		<ul class="right btn-style">
   			<li>
           		<a href="javascript:fn_selectList();"><spring:message code="button.goList" /></a>
            </li>
   			<li>
               	<a href="javascript:fn_save();">
                 	<c:if test="${registerFlag == 'create'}"><spring:message code="button.goCreate" /></c:if>
                 	<c:if test="${registerFlag == 'modify'}"><spring:message code="button.goModify" /></c:if>
             	</a>
          	</li>
   		</ul>
   	</div>
</form:form>


<script type="text/javascript" src="<c:url value='/validator.do'/>"></script>
<validator:javascript formName="incidentVO" staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javaScript" defer="defer">
<!--
	$(window).ready(function() {
		$("#chkUserNameSetting").click(function() {
			if (this.checked){
				$("#chargeNm").val($("#hdChargeNm").val());	
			} else {
				$("#chargeNm").val("");
			}
		});
		
		$("#sdate").datepicker({
			dateFormat: 'yy-mm-dd',
			onSelect: function(date){
				$("#sdate").val(date);
			}
		});
		$("#edate").datepicker({
			dateFormat: 'yy-mm-dd',
			onSelect: function(date){
				$("#edate").val(date);
			}
		});
	})
	
	function fn_selectList(){
		location.href = "<c:url value='/susa/incident/list.do'/>";
	}
	
	function fn_save(){
    	frm = document.detailForm;
    	if(!validateIncidentVO(frm)){
            return;
        }else{
           	frm.submit();
        }		
	}
-->	
</script>