<!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/equip/equip.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <h4 th:text="|${equType}-${detailType} 세부현황|"></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 method="get" th:action="@{/equip/List}">
            <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
            <input type="hidden" name="detailType" th:value="${searchParams.detailType}">
            <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">
                    <input type="text" class="form-control form-control-sm">
                  </div>
                  <input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색">
                </div>
              </div>
            </div>
          </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-striped">
                      <thead>
                      <tr>
                        <th> <input type="checkbox" id="chk-all" class="equInfoCheckBox"></th>
                        <th>소속</th>
                        <th>세부소속</th>
                        <th>장비사진</th>
                        <th>취득년도</th>
                        <th>보유량</th>
                        <th>상태</th>
                        <th>비고</th>
                      </tr>
                      </thead>
                      <tbody>
                      <tr th:each="equ:${equipList}">
                      	<td>
                      		<input type="checkbox" name="equChk" class="equInfoCheckBox">
                      		<input type="hidden" class="equKey" th:value="${equ.equKey}">
                      		<input type="hidden" class="verNo" th:value="${equ.versionNo}">
                      	</td>
                      	<td th:text="${equ.sosok}"></td>
                      	<td th:text="${equ.detailSosok}"></td> 
                      	<td>
                      		<img id="imgId" th:src="|@{/equip/getEquipImg(equKey=${equ.equKey},versionNo=${equ.versionNo})}|" alt="첨부이미지" style="width: 100px; height: 50px;" onclick="window.open(this.src)" th:if="${equ.origNm != null}" />
                      	</td> 
                      	<td th:text="${equ.storedYear}"></td> 
                      	<td th:text="${equ.itemQty}"></td> 
                      	<td th:text="${equ.itemCondition}"></td> 
                      	<td th:text="${equ.note}"></td>                   
                        
                      </tr>
                      </tbody>
                    </table>
                  </div>
                  <div class="col-auto">
                      <input type="button" class="btn btn-success" value="삭제" id="equDeleteBtn" th:unless="${accessAuth eq 'ACC001'}">
                      <input type="button" class="btn btn-success" value="수정" id="equUpdateBtn" th:unless="${accessAuth eq 'ACC001'}">
                      <input type="button" class="btn btn-success" value="수정이력" id="historyBtn" th:unless="${accessAuth eq 'ACC001'}">
                  </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>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>

	<div class="modal fade" id="equipModifyModal" 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="equipEditModalContent">
        <div class="modal-header">
        </div>
        <div class="modal-body">
          <div class="tab-content border border-top-0" id="configEqu">
          </div>
        </div>
      </div>
    </div>
  </div>

</div>
</html>