<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
  <div class="modal-header">
    <th:block th:if="${boardInvestigation.ivsgtType eq 'arrest'}">
      <h5 class="modal-title" id="ivsgtViewModalLabel">검거보고서</h5>
    </th:block>
    <th:block th:if="${boardInvestigation.ivsgtType eq 'proceeding'}">
      <h5 class="modal-title" id="ivsgtViewModalLabel">진행보고서</h5>
    </th:block>
    <th:block th:if="${boardInvestigation.ivsgtType eq 'result'}">
      <h5 class="modal-title" id="ivsgtViewModalLabel">결과보고서</h5>
    </th:block>
    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </div>
  <div class="modal-body" id="ivsgtViewBody">
    <form action="#" method="post" id="ivsgtEditForm">
      <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="ivsgtKey" th:value="${boardInvestigation.ivsgtKey}">
      <input type="hidden" name="wrtOrgan" th:value="${boardInvestigation.wrtOrgan}">
      <input type="hidden" name="contentState">
      <input type="hidden" name="ivsgtType" th:value="${boardInvestigation.ivsgtType}">
      <div class="mb-3 row">
        <label for="wrtUserNm" class="col-sm-2 col-form-label text-center">작성자</label>
        <div class="col-sm-2">
          <input type="text" class="form-control border-0" id="wrtUserNm" name="wrtUserNm" th:value="${boardInvestigation.wrtNm}" readonly>
        </div>
        <label for="wrtDt" class="col-sm-2 col-form-label text-center">작성일시</label>
        <div class="col-sm-2">
          <input type="text" class="form-control border-0" id="wrtDt" name="wrtDt" th:value="${#temporals.format(boardInvestigation.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
        </div>
      </div>
      <div class="mb-3 row">
        <label for="contentTitle" class="col-sm-2 col-form-label text-center">제목</label>
        <div class="col-sm-10">
          <input type="text" class="form-control border-0" id="contentTitle" name="contentTitle" th:value="${boardInvestigation.contentTitle}" readonly>
        </div>
      </div>
      <div class="mb-3 row" id="arrestTypeDiv">
        <label class="col-sm-2 col-form-label text-center">검거유형1</label>
        <div class="col-sm-2">
            <div th:utext="${boardInvestigation.arrestType.arrestCdName}"></div>
        </div>
        <label class="col-sm-2 col-form-label text-center">검거유형2</label>
        <div class="col-sm-2">
          <div th:utext="${boardInvestigation.arrestType.arrestCd2Name}"></div>
        </div>
      </div>
      <div class="mb-3 row">
        <label for="hashTags" class="col-sm-2 col-form-label col-form-label-sm text-center">해시태그</label>
        <div class="col-sm-10">
          <input type="text" class="form-control form-control-sm border-0" id="hashTags" name="hashTags" th:value="${boardInvestigation.hashTags}"
                 placeholder="없음" readonly>
        </div>
      </div>
      <div class="mb-3 row justify-content-center">
        <div class="col-8">
          <div class="mb-3 row">
            <label for="contentInfoDiv" class="col-sm-2 col-form-label text-center">사건개요</label>
            <div class="col-sm-10" id="contentInfoDiv">
              <div type='text' class="col-sm-10" name='contentInfos'th:utext="${boardInvestigation.contentInfo}" readonly></div>
            </div>
          </div>
          <div class="mb-3 row">
            <label for="contentMainDiv" class="col-sm-2 col-form-label text-center">주요내용</label>
            <div class="col-sm-10" id="contentMainDiv">
              <div type='text' class="col-sm-10" name='contentMain' th:utext="${boardInvestigation.contentMain}" readonly></div>
            </div>
          </div>
        </div>
        <div class="col-4">
          <table class="table">
            <thead>
            <tr>
              <th>파일명</th>
              <th>사이즈</th>
            </tr>
            </thead>
            <tbody>
            <th:block th:if="${#lists.isEmpty(boardInvestigation.fileList)}">
              <tr>
                <td colspan="2">파일이 없습니다.</td>
              </tr>
            </th:block>
            <th:block th:unless="${#lists.isEmpty(boardInvestigation.fileList)}">
              <th:block th:each="file:${boardInvestigation.fileList}">
                <tr class="fileInfoTr">
                  <td><a href="#" class="fileDownLink" data-board="ivsgt"
                         th:data-parentkey="${file.ivsgtKey}" th:data-fileseq="${file.fileSeq}" th:text="|${file.origNm}.${file.fileExtn}|"></a></td>
                  <td th:text="${file.fileSize}"></td>
                </tr>
              </th:block>
            </th:block>
            </tbody>
          </table>
        </div>
        <th:block th:if="${boardInvestigation.ivsgtType eq 'proceeding' or boardInvestigation.ivsgtType eq 'result'}">
          <div class="row mb-3">
            <label for="relatedReportDiv" class="col-sm-2 col-form-label text-center">연관보고서</label>
            <div class="col-sm-10" id="relatedReportDiv">
              <div class="row justify-content-start">
                <th:block th:each="relatedReports:${boardInvestigation.relatedReportsList}">
                  <div class="col-auto">
                    <input class="border-0" type="text" name="relatedReportsText" th:value="${relatedReports.contentTitle}" readonly>
                  </div>
                </th:block>
              </div>
            </div>
          </div>
        </th:block>
      </div>
    </form>
  </div>
  <div class="modal-footer">
    <th:block th:if="${userSeq eq boardInvestigation.wrtUserSeq or accessAuth eq 'ACC003'}"><!--작성자일 경우 수정 허용--><!--관리자일 경우 수정 허용-->
      <button type="button" class="btn btn-warning" id="ivsgtEditBtn">수정</button>
    </th:block>
    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
  </div>
</html>