<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">

<div class="modal-header">
  <h5 class="modal-title" id="menuEditModalLabel" th:text="${info.vulnKey eq null?'외사취약지 등록':'외사취약지 수정'}"></h5>
  <th:block th:if="${info.vulnKey eq null}">
  	<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </th:block>
  <th:block th:unless="${info.vulnKey eq null}">
  	<button type="button" class="btn-close" id="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </th:block>
</div>
<div class="modal-body">
  <form id="saveVulnoFm" method="post">
        <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
   		<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
   		<input type="hidden" name="vulnKey" th:value="${info.vulnKey}">
    	<input type="hidden" name="wrtOrgan" th:value="${info.wrtOrgan}">
    	<input type="hidden" name="wrtPart" th:value="${info.wrtPart}">
    	<input type="hidden" name="wrtTitle" th:value="${info.wrtTitle}">
    	<input type="hidden" name="wrtUserSeq" th:value="${info.wrtUserSeq}">
    	<input type="hidden" name="wrtNm" th:value="${info.wrtNm}">
          <div class="mb-3 row">
            <label for="ogCd" class="col-sm-2 col-form-label text-center">경찰서</label>        
            <div class="col-sm-10">
               <select class="form-select form-select-sm" id="mgtOrgan" name="mgtOrgan" th:disabled="${accessAuth ne 'ACC003'}">
                  <option value="">선택</option>
                  <th:block th:each="organList:${organList}">
                  	<th:block th:if="${info.vulnKey eq null}">
		              <option th:value="${organList.item_cd}" th:text="${organList.item_value}" th:selected="${organList.item_cd eq userOrgan}"></option>
		          	</th:block>
		          	<th:block th:unless="${info.vulnKey eq null}">
		              <option th:value="${organList.item_cd}" th:text="${organList.item_value}" th:selected="${organList.item_cd eq info.mgtOrgan}"></option>
		          	</th:block>
		          </th:block>
               </select>
            </div>
          </div>        
          <div class="mb-3 row">
            <label for="ogCd" class="col-sm-2 col-form-label text-center">취약지명</label>
            <div class="col-sm-10">
                  <input type="text" class="form-control" id="vulnNm" name="vulnNm" th:value="${info.vulnNm}" placeholder="직접입력">
            </div>
          </div> 
          <div class="mb-3 row">
            <label for="ogCd" class="col-sm-2 col-form-label text-center">취약등급</label>        
            <div class="col-sm-10">
               <select class="form-select form-select-sm" id="vulnType" name="vulnType">
                  <option value="">선택</option>
                  <th:block th:each="commonCode:${session.commonCode.get('VULNT')}">
		              <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemValue eq info.vulnType}"></option>
		          </th:block>
               </select>
            </div>
          </div>
          <div class="mb-3 row">
            <label for="ogCd" class="col-sm-2 col-form-label text-center">비고</label>
            <div class="col-sm-10">
                  <input type="text" class="form-control" id="description" name="description" th:value="${info.description}">
            </div>
          </div>         
          <div class="row mb-3">
	      <label for="fileInputer" class="col-sm-2 col-form-label text-center">업로드 자료</label>
	      <div class="col-sm-10" style="min-height: 70px;">
	        <div class="w-100 h-100 border border-info rounded text-center" id="uploadDiv">
	          <th:block th:if="${#arrays.isEmpty(info.fileList)}">
	            <br>파일을 업로드 해주세요.
	          </th:block>
	          <th:block th:unless="${#arrays.isEmpty(info.fileList)}">
	            <div class='row-col-6' th:each="infoFile:${info.fileList}">
	              <span th:data-fileseq="${infoFile.fileSeq}" th:text="|${infoFile.origNm}.${infoFile.fileExtn} ${infoFile.fileSize}|"></span>
	              <a href='#' class='uploadedFileDelete text-danger text-decoration-none'>삭제</a>
	            </div>
	          </th:block>
	        </div>
	      </div>
	      <input type="file" class="d-none" id="fileInputer" multiple>
    	</div>
   </form>
</div>
<div class="modal-footer justify-content-between">
  <div class="col-auto">
	<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
  </div>
  <div class="col-auto">
  <th:block th:if="${info.vulnKey eq null}">
    <button type="button" class="btn btn-primary" id="saveVuln">저장</button>
  </th:block>
  <th:block th:unless="${info.vulnKey eq null}">
    <button type="button" class="btn btn-danger" id="deleteVuln" th:if="${accessAuth eq 'ACC003'} or ${info.wrtUserSeq eq userSeq}">삭제</button>
    <button type="button" class="btn btn-warning" id="updateVuln" th:if="${accessAuth eq 'ACC003'} or ${info.wrtUserSeq eq userSeq}">수정</button>
  </th:block>
  </div>
</div>
</html>