<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/fipTarget/shipInfo.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <h4>국제여객선 목록</h4>
    <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="card text-center">
        <div class="card-body">    
        <ul class="nav nav-tabs" id="userTab" role="tablist">
            <li class="nav-item" role="presentation">
              <button class="nav-link" th:classappend="${searchParams.siType eq 'KRCN'?' active':''}" id="krcnTab" data-bs-toggle="tab" type="button" role="tab">한-중 국제여객선 현황</button>
            </li>
            <li class="nav-item" role="presentation">
              <button class="nav-link" th:classappend="${searchParams.siType eq 'KRJPRU'?' active':''}" id="krjpruTab" data-bs-toggle="tab" type="button" role="tab">한-일,러 국제여객선 현황</button>
            </li>          
          </ul>       
          <form id="searchFm" method="get" th:action="@{/target/ipShipList}">
            <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
            <input type="hidden" name="siType" th:value="${searchParams.siType}">
            <input type="hidden" name="excel">
            <input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색" style="display:none;">
          </form>
          <div class="row justify-content-start">
            <div class="col-12">
              <div class="card">
                <div class="card-body">
                  <div class="row">
                    <table class="table table-hover table-bordered">
                      <thead>
                      <tr class="table-secondary">
                        <th>항로</th>
                        <th>사업자<br>(한국대리점)</th>
                        <th>선명</th>
                        <th>국제<br>총톤수</th>
                        <th>수송능력</th>
                        <th>운항횟수</th>
                        <th>휴항</th>
                        <th>최종수정일</th>
                      </tr>
                      </thead>
                      <tbody class="table-group-divider">
                      <tr class="shipInfoTr" th:each="si:${shipInfoList}">
                      <th:block>
                      <input type="hidden" class="siSeq" th:value="${si.siSeq}">
                      <input type="hidden" class="siType" th:value="${si.siType}">
                      <input type="hidden" class="verNo" th:value="${si.versionNo}">
                      </th:block>
                      	<td th:inline="text">
                      		[[${si.startPoint}]]/[[${si.endPoint}]]
                      		<br/>
                      		([[${si.distanceNm}]],[[${si.distanceKm}]])
                      	</td>
                      	<td th:text="${si.ownerNm}"></td>
                      	<td th:text="${si.shipNm}"></td>
                      	<td th:text="${si.weightStr}"></td>
                      	<td th:inline="text">
                      		여객:[[${si.passengerCnt}]]명
                      		<br/>
                      		화물:[[${si.freightCnt}]]TEU
                      	</td>
                      	<td th:text="${si.operationCnt}"></td>
                      	<td th:text="${si.closeYn}"></td>
                      	<td th:text="${#temporals.format(si.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
                      </tr>
                      </tbody>
                    </table>
                  </div>                 
                  <div class="row justify-content-between">
                   <div class="col-auto">
	                  	<button class="btn btn-success" id="goExcel">엑셀 다운</button>
                  	</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==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-primary" value="등록" id="addKRCN" th:if="${accessAuth != 'ACC001'} and ${searchParams.siType eq 'KRCN'}">
                      <input type="button" class="btn btn-primary" value="등록" id="addKRJPRU" th:if="${accessAuth != 'ACC001'} and ${searchParams.siType eq 'KRJPRU'}">
                  	</div>
                  </div> 
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>

	<div class="modal fade" id="ipShipModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="userEditModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-dialog-scrollable">
      <div class="modal-content" id="ipShipModalContent">
      </div>
    </div>
  </div>

</div>
</html>