<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
  <h5 class="modal-title" id="planViewModalLabel">청산보고서 열람</h5>
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
  <div class="row">
    <div class="col-12">
      <input type="hidden" name="resultKey" id="viewModalResultKey" th:value="${result.resultKey}">
      <input type="hidden" name="wrtOrgan" th:value="${result.wrtOrgan}">
      <input type="hidden" name="resultState" id="resultState" th:value="${result.resultState}">
      <ul class="nav nav-tabs" id="userTab" role="tablist">
        <li class="nav-item" role="presentation">
          <button class="nav-link active" id="clearReportViewTab" data-bs-toggle="tab" data-bs-target="#clearReportViewTabPanel" type="button" role="tab" aria-controls="clearReportViewTabPanel" aria-selected="true">청산보고서</button>
        </li>
        <li class="nav-item" role="presentation">
          <button class="nav-link" id="resultReportViewTab" data-bs-toggle="tab" data-bs-target="#resultReportViewTabPanel" type="button" role="tab" aria-controls="resultReportViewTabPanel" aria-selected="false">결과보고서</button>
        </li>
        <li class="nav-item" role="presentation">
          <button class="nav-link" id="affairListViewTab" data-bs-toggle="tab" data-bs-target="#affairListViewTabPanel" type="button" role="tab" aria-controls="affairListViewTabPanel" aria-selected="false">견문목록&증빙자료</button>
        </li>
      </ul>
      <div class="tab-content border border-top-0" id="configInfo">
        <div class="tab-pane fade p-2 show active" id="clearReportViewTabPanel" role="tabpanel" aria-labelledby="clearReportViewTab" tabindex="0">
          <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="${result.wrtUserNm}" readonly>
            </div>
            <label for="wrtDt" class="col-sm-1 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(result.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
            </div>
            <div class="col-sm-2"></div>
            <label for="resultState" class="col-sm-1 col-form-label text-center">상태</label>
            <div class="col-sm-2">
              <th:block th:each="commonCode:${session.commonCode.get('DST')}">
                <input type="text" class="form-control border-0" th:if="${commonCode.itemCd eq result.resultState}" th:value="${commonCode.itemValue}" readonly>
              </th:block>
            </div>
          </div>
          <hr>
          <div class="mb-3 row">
            <label for="clearTitle" class="col-sm-2 col-form-label text-center">목적(제목)</label>
            <div class="col-sm-6">
              <input type="text" class="form-control border-0" id="clearTitle" name="clearTitle" th:value="${result.clearTitle}" readonly>
            </div>
            <label for="useDate" class="col-sm-1 col-form-label text-center">사용기간</label>
            <div class="col-sm-3">
              <input type="text" class="form-control border-0" id="useDate" name="useDate"
                     th:value="${#strings.concat(#temporals.format(result.useStartDt, 'yyyy-MM-dd'), '~', #temporals.format(result.useEndDt, 'yyyy-MM-dd'))}" readonly>
            </div>
          </div>
          <div class="mb-3 row">
            <label for="planPrice" class="col-sm-2 col-form-label text-center">계획금액</label>
            <div class="col-sm-2">
              <input type="text" class="form-control border-0" id="planPrice" name="planPrice" th:value="${#numbers.formatInteger(result.planPrice, 1, 'COMMA')+'원'}" readonly>
            </div>
            <label for="usePrice" class="col-sm-1 col-form-label text-center">집행액</label>
            <div class="col-sm-2">
              <input type="text" class="form-control border-0" id="usePrice" name="usePrice" th:value="${#numbers.formatInteger(result.usePrice, 1, 'COMMA')+'원'}" readonly>
            </div>
            <div class="col-sm-1"></div>
            <label for="workDate" class="col-sm-1 col-form-label text-center">사업기간</label>
            <div class="col-sm-3">
              <input type="text" class="form-control border-0" id="workDate" name="workDate"
                     th:value="${#strings.concat(#temporals.format(result.workStartDt, 'yyyy-MM-dd'), '~', #temporals.format(result.workEndDt, 'yyyy-MM-dd'))}" readonly>
            </div>
          </div>
          <hr>
          <div class="mb-3 row">
            <label for="clearTitle" class="col-sm-2 col-form-label text-center">세부<br>집행내역</label>
            <div class="col-sm-10">
              <table class="table table-hover">
                <thead>
                <tr>
                  <th>no</th>
                  <th>구분</th>
                  <th>상세</th>
                  <th>금액</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="clearInfo:${result.clearInfoList}">
                  <td th:text="${clearInfo.infoSeq+1}"></td>
                  <th:block th:each="commonCode:${session.commonCode.get('RIC')}">
                    <td th:if="${clearInfo.useCatg eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <th:block th:each="commonCode:${session.commonCode.get('RID')}">
                    <td th:if="${clearInfo.useDetail eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <td th:text="${#strings.concat(#numbers.formatInteger(clearInfo.price, 1, 'COMMA'), '원')}"></td>
                </tr>
                </tbody>
              </table>
            </div>
          </div>
          <hr>
          <div class="mb-3 row">
            <label for="clearEtc" class="col-sm-2 col-form-label text-center">비고</label>
            <div class="col-sm-10">
              <input type="text" class="form-control border-0" id="clearEtc" name="clearEtc" th:value="${result.clearEtc}" readonly>
            </div>
          </div>
        </div>
        <div class="tab-pane fade p-2" id="resultReportViewTabPanel" role="tabpanel" aria-labelledby="resultReportViewTab" tabindex="0">
          <div class="mb-3 row">
            <label for="resultTitle" class="col-sm-2 col-form-label text-center">사업명</label>
            <div class="col-sm-10">
              <input type="text" class="form-control border-0" id="resultTitle" name="resultTitle" th:value="${result.resultTitle}" readonly>
            </div>
          </div>
          <div class="mb-3 row">
            <label for="usePrice" class="col-sm-2 col-form-label text-center">집행예산</label>
            <div class="col-sm-2">
              <input type="text" class="form-control border-0" id="usePrice" name="usePrice" th:value="${#numbers.formatInteger(result.usePrice, 1, 'COMMA')+'원'}" readonly>
            </div>
            <div class="col-sm-1"></div>
            <label for="workDate" class="col-sm-1 col-form-label text-center">사업기간</label>
            <div class="col-sm-3">
              <input type="text" class="form-control border-0" id="workDate" name="workDate"
                     th:value="${#strings.concat(#temporals.format(result.workStartDt, 'yyyy-MM-dd'), '~', #temporals.format(result.workEndDt, 'yyyy-MM-dd'))}" readonly>
            </div>
          </div>
          <hr>
          <div class="mb-3 row">
            <label for="clearTitle" class="col-sm-2 col-form-label text-center">활동내용</label>
            <div class="col-sm-10">
              <table class="table table-hover">
                <thead>
                <tr>
                  <th>no</th>
                  <th>접촉대상자</th>
                  <th>접촉내용</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="resultInfo:${result.resultInfoList}">
                  <td th:text="${resultInfo.infoSeq+1}"></td>
                  <td th:text="${resultInfo.contactTarget}"></td>
                  <td th:utext="${resultInfo.contactInfo}"></td>
                </tr>
                </tbody>
              </table>
            </div>
          </div>
          <hr>
          <div class="mb-3 row">
            <label for="resultEtc" class="col-sm-2 col-form-label text-center">비고</label>
            <div class="col-sm-10">
              <input type="text" class="form-control border-0" id="resultEtc" name="resultEtc" th:value="${result.resultEtc}" readonly>
            </div>
          </div>
        </div>
        <div class="tab-pane fade p-2" id="affairListViewTabPanel" role="tabpanel" aria-labelledby="affairListViewTab" tabindex="0">
          <div class="row">
            <div class="col-8">
              <table class="table table-hover">
                <thead>
                <tr>
                  <th>작성일자</th>
                  <th>제목</th>
                  <th>활용</th>
                </tr>
                </thead>
                <tbody>
                <tr class="affairViewTr" th:each="affair:${result.affairBoardList}">
                  <input type="hidden" class="affairKey" th:value="${affair.affairKey}">
                  <td th:text="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd')}"></td>
                  <td th:text="${affair.title}"></td>
                  <th:block th:each="ratingCode:${session.commonCode.get('AAR')}">
                    <td class="affairRate" th:if="${ratingCode.itemCd eq affair.affairRate}" th:text="${#strings.concat(ratingCode.itemValue, (affair.organUp eq 'T'?'(상보)':''))}"></td>
                  </th:block>
                </tr>
                </tbody>
              </table>
            </div>
            <div class="col-4">
              <table class="table">
                <thead>
                <tr>
                  <th>파일명</th>
                  <th>사이즈</th>
                </tr>
                </thead>
                <tbody>
                <th:block th:if="${#lists.isEmpty(result.fileList)}">
                  <tr>
                    <td colspan="2">파일이 없습니다.</td>
                  </tr>
                </th:block>
                <th:block th:unless="${#lists.isEmpty(result.fileList)}">
                  <th:block th:each="file:${result.fileList}">
                    <tr class="fileInfoTr">
                      <td><a href="#" class="fileDownLink" data-board="affairResult"
                             th:data-parentkey="${file.resultKey}" 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>
          </div>
        </div>
      </div>
    </div>
    <th:block th:unless="${#lists.isEmpty(result.apprvList)}">
      <hr>
      <th:block th:each="apprv,cnt:${result.apprvList}">
        <div class="row justify-content-between py-1">
          <div class="col-auto">
            <th:block th:each="commonCode:${session.commonCode.get('DST')}">
              <span th:if="${commonCode.itemCd eq apprv.state}" th:text="|결재결과: ${commonCode.itemValue}|"></span>
            </th:block>
            <span th:text="|결재자: ${apprv.userNm}|"></span>
          </div>
          <div class="col-auto">
            <span th:text="|결재일시: ${#temporals.format(apprv.saveDt, 'yyyy-MM-dd HH:mm:ss')}|"></span>
          </div>
          <div class="col-12">
            <span th:text="|기타의견: ${apprv.etc}|"></span>
          </div>
        </div>
      </th:block>
    </th:block>
    <div class="col-12 mt-2" th:if="${apprvAuth ne null}">
      <th:block th:if="${result.resultState eq 'DST002' and (apprvAuth eq 'APC004'||apprvAuth eq 'APC003')
                        or result.resultState eq 'DST004' and (apprvAuth eq 'APC002'||apprvAuth eq 'APC001')}">
        <form action="#" method="post" id="apprvForm">
          <div class="row">
            <div class="col-10">
              <input type="hidden" name="resultKey" th:value="${result.resultKey}">
              <input type="hidden" name="state" id="viewModalApprvValue">
              <input type="text" class="form-control form-control-sm" name="etc" placeholder="추가의견, 반려사유 기입">
              <input type="text" class="d-none" id="submitPrevention">
            </div>
            <div class="col-auto">
              <input type="button" class="btn btn-sm btn-success apprvBtn" th:data-resultstate="${apprvAuth eq 'APC004'||apprvAuth eq 'APC003'?'DST004':'DST006'}" value="승인">
            </div>
            <div class="col-auto">
              <input type="button" class="btn btn-sm btn-danger apprvBtn" th:data-resultstate="${apprvAuth eq 'APC004'||apprvAuth eq 'APC003'?'DST003':'DST005'}" value="반려">
            </div>
          </div>
        </form>
      </th:block>
    </div>
  </div>
</div>
<div class="modal-footer">
  <th:block th:unless="${result.resultState eq 'DST004' or result.resultState eq 'DST006'}"><!--승인 상태일때는 수정 불가-->
    <th:block th:if="${userSeq eq result.wrtUserSeq or accessAuth eq 'ACC003'}"><!--작성자일 경우 수정 허용--><!--관리자일 경우 수정 허용-->
      <button type="button" class="btn btn-warning" id="editResultBtn">수정</button>
    </th:block>
  </th:block>
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
</div>