<!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/partInfo.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="col-12 card text-center">
        <div class="card-body">
           <form id="searchFm" method="get" th:action="@{/target/partInfoList}">
            <input type="hidden" name="excel">
            <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
            <div class="row justify-content-between pe-3 py-1">
              <div class="col-auto">
                <select class="form-select" 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==num*10}"></option>
                  </th:block>
                </select>
              </div>
               <div class="col-auto">
                <div class="row justify-content-end">
                  <div class="col-auto">
                    <select class="form-select form-select-sm" name="mgtOrgan">
	               	   <option value="">-해경서 선택-</option>
	                   <th:block th:each="commonCode:${session.commonCode.get('OG')}">
	                    <th:block th:if="${#lists.contains(mgtOrganList, commonCode.itemCd)}">
	                      <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.mgtOrgan}"></option>
	                    </th:block>
	                  </th:block>
	                </select>
                  </div>
                  <div class="col-auto">
                    <input type="text" class="form-control form-control-sm" name="landPolice" th:value="${searchParams.landPolice}" placeholder="육경서">
                  </div>
                  <div class="col-auto">
                     <select class="form-select form-select-sm" name="mpWorkType">
	                    <option value="">해경서 근무방법</option>
	                    <th:block th:each="commonCode:${session.commonCode.get('PIS')}">
	                    <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.mpWorkType}"></option>
	                    </th:block>
	                 </select>
                  </div>
                  <div class="col-auto">
                     <select class="form-select form-select-sm" name="plWorkType">
	                    <option value="">육경서 근무방법</option>
	                    <th:block th:each="commonCode:${session.commonCode.get('PIS')}">
	                    <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.plWorkType}"></option>
	                    </th:block>
	                 </select>
                  </div>
                  <div class="col-auto">
                    <input type="text" class="form-control form-control-sm" name="terminalNm" th:value="${searchParams.terminalNm}" placeholder="터미널명">
                  </div>
                  <input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색">
                </div>
              </div> 
            </div>
            <div class="row justify-content-between py-1">          
            <div class="col-auto">
             <div class="row justify-content-end">
              <div class="col-auto">
                
              </div>
               <div class="col-auto">
               
              </div>
               <div class="col-auto">
                <input type="text" class="form-control form-control-sm" id="startDate" name="startDate" placeholder="최종수정일" autocomplete="off" readonly th:value="${searchParams.startDate}">
               </div>
             </div>           
            </div>
            </div>
          </form> 
          <div class="row justify-content-start">
            <div class="col-12">
              <div class="card">
                <div class="card-body">
                  <div class="row">
                  <input type="hidden" id="selectedKey">
                  <input type="hidden" id="selectedVerNo">
                    <table class="table table-striped">
                      <thead>
                      <tr>
                        <th rowspan="3">해경서</th>
                        <th rowspan="3">육경서</th>
                        <th rowspan="3">터미널명</th>
                        <th colspan="3">해경</th>               
                        <th colspan="3">육경</th>                                        
                        <th rowspan="3">담당자</th>
                        <th rowspan="3">임차료</th>
                        <th rowspan="3">공공요금</th>
                        <th rowspan="3">최종수정일</th>
                      </tr>
                      <tr>
                      	<th:block th:if="${not #strings.isEmpty(total)}">
                      	<th th:text="|상주 ${total.mp_sangju}개소 ${total.mp_sangju_total}명|"></th>
                      	<th th:text="|비상주 ${total.mp_bsangju}개소 ${total.mp_bsangju_total}명|"></th>
                      	<th th:text="|폐쇄 ${total.mp_closure}개소 ${total.mp_closure_total}명|"></th>
                      	<th th:text="|상주 ${total.pl_sangju}개소 ${total.pl_sangju_total}명|"></th>
                      	<th th:text="|비상주 ${total.pl_bsangju}개소 ${total.pl_bsangju_total}명|"></th>
                      	<th th:text="|폐쇄 ${total.pl_closure}개소 ${total.pl_closure_total}명|"></th>
                      	</th:block>
                      	<th:block th:unless="${not #strings.isEmpty(total)}">
                      	<th>상주 0개소 0명</th>
                      	<th>비상주 0개소 0명</th>
                      	<th>폐쇄 0개소 0명</th>
                      	<th>상주 0개소 0명</th>
                      	<th>비상주 0개소 0명</th>
                      	<th>폐쇄 0개소 0명</th>
                      	</th:block>
                      </tr>
                      <tr>
                      	<th>근무방법</th>
                      	<th>명</th>
                      	<th>비고</th>
                      	<th>근무방법</th>
                      	<th>명</th>
                      	<th>비고</th>
                      </tr>
                      </thead>
                      <tbody>
                      <tr class="partInfoTr" th:each="pi:${partInfoList}">
                      <th:block>
                      	<input type="hidden" class="piSeq" th:value="${pi.piSeq}">
                      	<input type="hidden" class="verNo" th:value="${pi.versionNo}">
                      </th:block>
                        <td th:text="${pi.mgtOrgan}"></td>
                    	<td th:text="${pi.landPolice}"></td>
                    	<td th:text="${pi.terminalNm}"></td>
                    	<td th:text="${pi.mpWorkType}"></td>
                    	<td th:text="${pi.mpPeopleCnt}"></td>
                    	<td th:text="${pi.mpDescription}"></td>
                    	<td th:text="${pi.plWorkType}"></td>
                    	<td th:text="${pi.plPeopleCnt}"></td>
                    	<td th:text="${pi.plDescription}"></td>                   	
                    	<td th:text="${pi.piManagerName}"></td>             
                    	<td th:text="|${pi.rentPrice}만|" th:if="${pi.rentType eq 'Y'}"></td>
                    	<td th:unless="${pi.rentType eq 'Y'}">무상</td>
                    	<td th:text="|${pi.utilityPrice}만|" th:if="${pi.utilityType eq 'Y'}"></td>
                    	<td th:unless="${pi.utilityType eq 'Y'}">무상</td>
                    	<td th:text="${#temporals.format(pi.wrtDt, 'yyyy-MM-dd')}"></td>
                      </tr>
                      </tbody>
                    </table>
                  </div>
                 <div class="row justify-content-center">
                    <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 class="col-auto">
			          <input type="button" class="btn btn-success" value="등록" id="addPartInfo" th:unless="${accessAuth eq 'ACC001'}">
			          <button id="goExcel">엑셀다운</button>
			        </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>
  
	
	<div class="modal fade" id="partInfoEditModal" 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="partInfoEditModalEditModalContent">
        <div class="modal-header">
        </div>
        <div class="modal-body">
          <div class="tab-content border border-top-0" id="configInfo">
          </div>
        </div>
      </div>
    </div>
  </div>



</div>
</html>