<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
  <h5 class="modal-title" id="sailorEditModalLabel">선원 세부 현황</h5>
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<!-- 탭 메뉴 -->
<ul class="nav nav-tabs" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link sailorTab active" id="sailor-tab" data-bs-toggle="tab"
            data-bs-target="#sailor" type="button" role="tab" aria-controls="sailor" data-sailor-type="sailor"
            aria-selected="true">상세</button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link sailorTab" id="history-tab" data-bs-toggle="tab"
            data-bs-target="#history" type="button" role="tab" data-history-type="history"
            aria-controls="history">수정이력</button>
  </li>
</ul>

<!-- 내용 -->
<div class="tab-content" style="overflow-y: auto;">
  <div class="tab-pane fade show active" id="sailor" role="tabpanel" aria-labelledby="sailor-tab">
    <div class="modal-body" id="sailorEditBody">
      <form action="#" method="post" id="sailorEditForm">
        <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
        <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="cdsKey" th:value="${sailor.crackdownStatus.cdsKey}">
        <input type="hidden" name="fbKey" th:value="${sailor.fishingBoat.fbKey}">
        <input type="hidden" name="sailorKey" th:value="${sailor.sailorKey}">
        <input type="hidden" name="wrtOrgan" th:value="${sailor.wrtOrgan}">
        <input type="hidden" name="wrtUserNm" th:value="${sailor.wrtUserNm}">
        <input type="hidden" name="wrtDt" th:value="${#temporals.format(sailor.wrtDt, 'yyyy-MM-dd HH:mm')}">
        <input type="hidden" id="saveYn" name="saveYn">
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">선박명</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="boatNameKr" id="boatNameKr" th:value="${sailor.fishingBoat.boatNameKr}" readonly>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">단속경찰서</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="crackdownPolice" id="crackdownPolice" disabled>
              <option value="">선택</option>
              <th:block th:each="commonCode:${session.commonCode.get('CPO')}">
                <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                        th:selected="${sailor.crackdownStatus.crackdownPolice eq commonCode.itemCd}"></option>
              </th:block>
              <option value="etc" th:selected="${sailor.crackdownStatus.crackdownPolice ne null && sailor.crackdownStatus.crackdownPolice ne '' && !#strings.contains(sailor.crackdownStatus.crackdownPolice, 'CPO')}">직접입력</option>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">단속함정</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="crackdownBoat" id="crackdownBoat" disabled>
              <option value="">선택</option>
              <th:block th:each="num : ${#numbers.sequence(1,#lists.size(session.commonCode.get('CPO')))}">
                <th:block th:if="${'CPO'+num == sailor.crackdownStatus.crackdownPolice}" th:each="commonCode:${session.commonCode.get('CPO'+num)}">
                  <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                          th:selected="${commonCode.itemCd eq sailor.crackdownStatus.crackdownBoat}"></option>
                </th:block>
              </th:block>
              <option value="etc" th:selected="${sailor.crackdownStatus.crackdownBoat ne null && sailor.crackdownStatus.crackdownBoat ne '' && !#strings.contains(sailor.crackdownStatus.crackdownBoat, 'CPO')}">직접입력</option>
            </select>
          </div>
        </div>
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">위반장소</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" placeholder="위도" name="napoSeaPointLat" th:value="${sailor.crackdownStatus.napoSeaPointLat}" readonly>
            <input class="form-control form-control-sm" placeholder="경도" name="napoSeaPointLon" th:value="${sailor.crackdownStatus.napoSeaPointLon}" readonly>
            <input class="form-control form-control-sm" placeholder="상세내용" name="napoSeaPointDetail" th:value="${sailor.crackdownStatus.napoSeaPointDetail}" readonly>
          </div>
        </div>
        <div class="mb-3 row">
          <div class="col-sm-1">
            <label class="col-form-label col-form-label-sm text-center">위반내용</label>
          </div>
          <div class="col-sm-2" id="violationDiv">
            <th:block th:if="${#lists.isEmpty(sailor.violationList)}">
              <div class="row">
                <select class="form-select form-select-sm violation" name="violation" disabled>
                  <option value="">선택</option>
                  <th:block th:each="commonCode:${session.commonCode.get('VT')}">
                    <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"></option>
                  </th:block>
                  <option value="etc">직접입력</option>
                </select>
              </div>
            </th:block>
            <th:block th:if="${!#lists.isEmpty(sailor.violationList)}">
              <th:block th:each="violation, i : ${sailor.violationList}">
                <div class="row">
                  <input type="hidden" name="violationKey" th:value="${violation.violationKey}">
                  <select class="form-select form-select-sm violation" name="violation" disabled>
                    <option value="">선택</option>
                    <th:block th:each="commonCode:${session.commonCode.get('VT')}">
                      <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                              th:selected="${sailor.violationList != null and commonCode.itemCd eq violation.violation}"></option>
                    </th:block>
                    <option th:selected="${violation.violation ne null && !#strings.contains(violation.violation, 'VT')}" value="etc">직접입력</option>
                  </select>
                  <th:block th:if="${violation.violation ne null and !#strings.contains(violation.violation, 'VT')}">
                    <div class="col-auto">
                      <input type="text" class="form-control form-control-sm" name="violationEtc" th:value="${violation.violation}" readonly>
                    </div>
                  </th:block>
                </div>
              </th:block>
            </th:block>
          </div>
        </div>
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">선원명(한글)</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="sailorNameKr" id="sailorNameKr" th:value="${sailor.sailorNameKr}" readonly>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">선원명(중문)</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="sailorNameCn" id="sailorNameCn" th:value="${sailor.sailorNameCn}" readonly>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">생년월일</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="birthdate" id="birthdate" th:value="${#temporals.format(sailor.birthdate, 'yyyy-MM-dd')}" readonly>
          </div>
        </div>
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">거주지</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="residence" disabled>
              <option value="">선택</option>
              <th:block th:each="commonCode:${session.commonCode.get('RSC')}">
                <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                        th:selected="${commonCode.itemCd eq sailor.residence}"></option>
              </th:block>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">학력</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="residence" disabled>
              <option value="">선택</option>
              <th:block th:each="commonCode:${session.commonCode.get('SED')}">
                <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                        th:selected="${commonCode.itemCd eq sailor.education}"></option>
              </th:block>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">선박 내 직책</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="residence" disabled>
              <option value="">선택</option>
              <th:block th:each="commonCode:${session.commonCode.get('POS')}">
                <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                        th:selected="${commonCode.itemCd eq sailor.position}"></option>
              </th:block>
            </select>
          </div>
        </div>
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">승선경력</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="career" disabled>
              <option value="">선택</option>
              <th:block th:each="commonCode:${session.commonCode.get('BE')}">
                <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
                        th:selected="${commonCode.itemCd eq sailor.career}"></option>
              </th:block>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">동종 범죄경력</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="similarCriminalHistory" disabled>
              <option value="">선택</option>
              <option value="1" th:selected="${sailor.similarCriminalHistory == 1}">1건</option>
              <option value="2" th:selected="${sailor.similarCriminalHistory == 2}">2건</option>
              <option value="3" th:selected="${sailor.similarCriminalHistory == 3}">3건</option>
              <option value="4" th:selected="${sailor.similarCriminalHistory == 4}">4이상</option>
              <option value="0" th:selected="${sailor.similarCriminalHistory == 0}">없음</option>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">이종 범죄경력</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="heterogeneousCriminalHistory" disabled>
              <option value="">선택</option>
              <option value="1" th:selected="${sailor.heterogeneousCriminalHistory == 1}">1건</option>
              <option value="2" th:selected="${sailor.heterogeneousCriminalHistory == 2}">2건</option>
              <option value="3" th:selected="${sailor.heterogeneousCriminalHistory == 3}">3건</option>
              <option value="4" th:selected="${sailor.heterogeneousCriminalHistory == 4}">4이상</option>
              <option value="0" th:selected="${sailor.heterogeneousCriminalHistory == 0}">없음</option>
            </select>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">검거이력<br>(나포이력, 선원 포함)</label>
          <div class="col-sm-2">
            <select class="form-select form-select-sm" name="arrestHistory" disabled>
              <option value="">선택</option>
              <option value="1" th:selected="${sailor.arrestHistory == 1}">1건</option>
              <option value="2" th:selected="${sailor.arrestHistory == 2}">2건</option>
              <option value="3" th:selected="${sailor.arrestHistory == 3}">3건</option>
              <option value="4" th:selected="${sailor.arrestHistory == 4}">4이상</option>
              <option value="0" th:selected="${sailor.arrestHistory == 0}">없음</option>
            </select>
          </div>
        </div>
        <div class="mb-3 row">
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">범죄경력<br>세부내용</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="note" th:value="${sailor.criminalHistoryDetail}" readonly>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">임금<br>(월급여)</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="note" th:value="${sailor.monthlyWages}" readonly>
          </div>
          <label class="col-sm-1 col-form-label col-form-label-sm text-center">비고</label>
          <div class="col-sm-2">
            <input class="form-control form-control-sm" name="note" th:value="${sailor.note}" readonly>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal-footer">
  <th:block th:if="${userSeq eq sailor.wrtUserSeq or accessAuth eq 'ACC003'}"><!--작성자일 경우 수정 허용--><!--관리자일 경우 수정 허용-->
    <button type="button" class="btn btn-warning" id="sailorEditBtn">수정</button>
  </th:block>
  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
</div>
</html>