<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<th:block layout:fragment="css">
  <style>
    .ws-normal{
      white-space: normal;
    }
    .ws-nowrap{
      white-space: nowrap;
    }
    .min-width-300{
      min-width: 300px!important;
    }
  </style>
</th:block>
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/faStatistics/fishingBoatMgt.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <div class="row justify-content-between">
      <div class="col-auto"><h4>불법조업 외국어선 정보</h4></div>
      <div class="col-auto"><p>외사통계 > 불법조업외국어선 > 불법조업 외국어선 정보</p></div>
    </div>
    <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
    <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
    <div class="row mx-0">
      <div class="col-12 card text-center">
        <div class="card-body">
          <form method="get" th:action="@{/faStatistics/fishingBoat}">
            <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
            <div class="row pe-3 py-1">
              <div class="col-1">
                <select class="form-select form-select-sm" name="rowCnt" id="rowCnt">
                  <th:block th:each="num : ${#numbers.sequence(1,5)}">
                    <option th:value="${num*10}" th:text="${num*10}" th:selected="${searchParams.rowCnt eq num*10}"></option>
                  </th:block>
                </select>
                <select class="form-select form-select-sm">
                  <option value="">연도</option>
                  <th:block th:each="year : ${#numbers.sequence(2020, 2030)}">
                    <option th:value="${year}" th:text="${year}" th:selected="${searchParams.fishingBoat.year eq year}"></option>
                  </th:block>
                </select>
              </div>
              <div class="col-10">
                <div class="row justify-content-end pb-1">
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">사건담당경찰서</option>
                      <th:block th:each="commonCode:${session.commonCode.get('OG')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.caseAgency}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">단속경찰서</option>
                      <th:block th:each="commonCode:${session.commonCode.get('OG')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.crackdownPolice}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">단속함정</option>
                      <th:block th:each="commonCode:${session.commonCode.get('CDB')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.crackdownBoat}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <div class="input-group w-auto input-daterange" id="dateSelectorDiv">
                      <input type="text" class="form-control form-control-sm" id="startDate" name="startDate" placeholder="단속기간 시작일" autocomplete="off" readonly th:value="${searchParams.startDate}">
                      <input type="text" class="form-control form-control-sm" id="endDate" name="endDate" placeholder="단속기간 종료일" autocomplete="off" readonly th:value="${searchParams.endDate}">
                    </div>
                  </div>
                  <div class="col-auto">
                    <input type="text" class="form-control form-control-sm" placeholder="선적지" name="boatNny" th:value="${searchParams.fishingBoat.boatNny}">
                  </div>
                </div>
                <div class="row justify-content-end">
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">선질</option>
                      <th:block th:each="commonCode:${session.commonCode.get('BM')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.fishingBoat.boatMaterial}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <input type="text" class="form-control form-control-sm" placeholder="톤수" name="tonCnt" th:value="${searchParams.fishingBoat.tonCnt}">
                  </div>
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">어업종류</option>
                      <th:block th:each="commonCode:${session.commonCode.get('FT')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.fishingBoat.fisheryType}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">처리현황</option>
                      <th:block th:each="commonCode:${session.commonCode.get('PR')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.processResult.processStatus}"></option>
                      </th:block>
                    </select>
                  </div>
                  <div class="col-auto">
                    <select class="form-select form-select-sm">
                      <option value="">위반형태</option>
                      <th:block th:each="commonCode:${session.commonCode.get('VT')}">
                        <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.fishingBoat.violation}"></option>
                      </th:block>
                    </select>
                  </div>
                </div>
              </div>
              <div class="col-1 d-grid gap-2">
                <input type="submit" class="btn btn-lg btn-primary col-auto" id="searchBtn" value="검색">
              </div>
            </div>
          </form>
          <div class="row justify-content-start">
            <div class="col-12">
              <div class="card">
                <div class="card-body">
                  <div class="row overflow-auto">
                    <table class="table table-hover table-bordered ws-nowrap">
                      <thead>
                      <tr class="table-secondary">
                        <th></th>
                        <th>나포일시</th>
                        <th>나포해점</th>
                        <th>사건담당기관</th>
                        <th>단속경찰서</th>
                        <th>단속함정</th>
                        <th>선명</th>
                        <th>선장명</th>
                        <th>어업종류</th>
                        <th>선적지</th>
                        <th>톤수</th>
                        <th>선질</th>
                        <th>위반형태</th>
                        <th>처리결과</th>
                        <th>작성자</th>
                        <th>수정일</th>
                      </tr>
                      </thead>
                      <tbody class="table-group-divider">
                      <tr class="crackdownStatusTr" th:each="crackdownStatus:${crackdownStatusList}">
                        <input type="hidden" class="cdsKey" th:value="${crackdownStatus.cdsKey}">
                        <td><input type="checkbox" class="trChkBox"></td>
                        <td th:text="${#temporals.format(crackdownStatus.napoDt, 'yyyy-MM-dd HH:mm')}"></td>
                        <td>
                          <th:block th:text="${crackdownStatus.napoSeaPointLon}"></th:block>
                          <br>
                          <th:block th:text="${crackdownStatus.napoSeaPointLat}"></th:block>
                        </td>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.caseAgency)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.caseAgency)}">
                          <th:block th:each="commonCode:${session.commonCode.get('ATA')}">
                            <td th:if="${crackdownStatus.caseAgency eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.crackdownPolice)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.crackdownPolice)}">
                          <th:block th:each="commonCode:${session.commonCode.get('CPO')}">
                            <td th:if="${crackdownStatus.crackdownPolice eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.crackdownBoat)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.crackdownBoat)}">
                          <th:block th:each="commonCode:${session.commonCode.get(crackdownStatus.crackdownPolice)}">
                            <td th:if="${crackdownStatus.crackdownBoat eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <td th:text="${crackdownStatus.boatNameKr}"></td>
                        <td th:text="${crackdownStatus.sailorNameKr}"></td>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.fisheryType)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.fisheryType)}">
                          <th:block th:each="commonCode:${session.commonCode.get('FT')}">
                            <td th:if="${crackdownStatus.fisheryType eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <td th:text="|${crackdownStatus.boatNnySung} ${crackdownStatus.boatNnySi}|"></td>
                        <td th:text="|${crackdownStatus.tonCnt}t|"></td>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.boatMaterial)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.boatMaterial)}">
                          <th:block th:each="commonCode:${session.commonCode.get('BM')}">
                            <td th:if="${crackdownStatus.boatMaterial eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <td class="ws-normal min-width-300" th:text="${crackdownStatus.violationStr}"></td>
                        <th:block th:if="${#strings.isEmpty(crackdownStatus.processStatus)}">
                          <td></td>
                        </th:block>
                        <th:block th:unless="${#strings.isEmpty(crackdownStatus.processStatus)}">
                          <th:block th:each="commonCode:${session.commonCode.get('PR')}">
                            <td th:if="${crackdownStatus.processStatus eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
                          </th:block>
                        </th:block>
                        <td>
                          <th:block th:each="commonCode:${session.commonCode.get('OG')}">
                            <th:block th:if="${crackdownStatus.wrtOrgan eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></th:block>
                          </th:block>
                          <th:block th:each="commonCode:${session.commonCode.get('JT')}">
                            <th:block th:if="${crackdownStatus.wrtUserGrd eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></th:block>
                          </th:block>
                          <th:block th:text="${crackdownStatus.wrtUserNm}"></th:block>
                        </td>
                        <td th:text="${#temporals.format(crackdownStatus.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
                      </tr>
                      </tbody>
                    </table>
                  </div>
                  <div class="row justify-content-between">
                    <div class="col-auto"></div>
                    <div class="col-auto">
                      <nav aria-label="Page navigation">
                        <ul class="pagination">
                          <th:block th:if="${searchParams.pageIndex>3}">
                            <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)-3}">
                              <a class="page-link" href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                              </a>
                            </li>
                          </th:block>
                          <th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
                            <li class="page-item" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex eq num?'active':''}">
                              <a class="page-link" href="#" th:text="${num}"></a>
                            </li>
                          </th:block>
                          <th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
                            <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)+3}">
                              <a class="page-link" href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                              </a>
                            </li>
                          </th:block>
                        </ul>
                      </nav>
                    </div>
                    <div class="col-auto">
                      <input type="button" class="btn btn-success" value="등록" id="getFishingBoatEditModalBtn">
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>

  <div class="modal fade" id="fishingBoatEditModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="fishingBoatEditModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xxl modal-dialog-scrollable">
      <div class="modal-content" id="fishingBoatEditModalContent">

      </div>
    </div>
  </div>
  <div class="modal fade" id="fishingBoatViewModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="fishingBoatViewModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xxl modal-dialog-scrollable">
      <div class="modal-content" id="fishingBoatViewModalContent">

      </div>
    </div>
  </div>

  <div class="modal fade" id="crackdownSubModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="crackdownSubModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-scrollable">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="crackdownSubModalLabel">단속현황 불러오기</h5>
          <input type="hidden" id="modalUrl" value="/modal/crackdownStatusModal">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body" id="subModalBody">
          <div class="row">
            <div class="col-12">
              <form method="get" action="#" id="modalSearchForm">
                <input type="hidden" name="pageIndex" id="modalPageIndex" value="1">
                <input type="hidden" name="rowCnt" value="10">
              </form>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" id="getCrackdownBtn">불러오기</button>
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
        </div>
      </div>
    </div>
  </div>
</div>
</html>