<!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/use.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="@{/equip/pvreUseList}">
          <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 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==num*10}"></option>
                  </th:block>
                </select>
              </div>
              <div class="col-auto">
              <button type="button" class="btn btn-success" id="goExcel">엑셀다운</button>
              </div>
            </div>
            <div class="row justify-content-end pe-3 py-1">
              <div class="col-auto">
                  <div class="row justify-content-end">
                    <div class="col-auto" th:if="${accessAuth eq 'ACC003'}">
                      <select class="form-select form-select-sm" name="mgtOrgan">
                        <option value="">경찰서</option>
                        <th:block th:each="organList:${organList}">
				           <option th:value="${organList.item_cd}" th:text="${organList.item_value}" th:selected="${organList.item_cd eq searchParams.mgtOrgan}"></option>
				        </th:block>
                      </select>
                    </div>
                    <div class="col-auto">
                      <input type="text" class="form-control form-control-sm" placeholder="연번" name="useNo" th:value="${searchParams.useNo}">
                    </div>
                    <div class="col-auto">
						<select class="form-select form-select-sm" name="detailType">
							<option value="">사용사유</option>
							<th:block th:each="commonCode:${session.commonCode.get('PVREUSE')}">
								<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.detailType}"></option>
							</th:block>
						</select>
					</div>
                    <div class="col-4">
                      <div class="input-group w-auto input-daterange" id="dateSelectorDiv">
                        <select class="form-select form-select-sm" name="dateSelector">
                          <option value="">조건선택</option>
                          <option value="useDt" th:selected="${searchParams.dateSelector eq 'useDt'}">사용일</option>
                          <option value="wrtDt" th:selected="${searchParams.dateSelector eq 'wrtDt'}">최종수정일</option>
                        </select>
                        <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>
                    <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-hover table-bordered">
                      <thead>
                      <tr class="table-secondary">
                        <th> <input type="checkbox" id="chk-all" class="useCheckBox"></th>
                        <th>연번</th>
                        <th>경찰서</th>
                        <th>사용일시</th>
                        <th>사용사유</th>
                        <th>사용인원</th>
                        <th>비고</th>
                        <th>최종수정일</th>
                      </tr>
                      </thead>
                      <tbody class="table-group-divider">
                      <tr class="useTr" th:each="list:${useList}" th:data-useNo="${list.useNo}" th:data-mgtOrgan="${list.mgtOrgan}" th:data-useType="${list.useType}">
                      	<td class="useChk"><input type="checkbox" name="useChk" class="useCheckBox"></td>
                      	<td th:text="${list.useNo}"></td>
                      	<td th:text="${list.sosok}"></td>
                      	<td th:text="${list.useDt}"></td>
                      	<td th:text="${list.detailTypeName}" th:if="${list.detailType != 'PVREUSE007'}"></td>
                      	<td th:text="${list.detailSelf}" th:unless="${list.detailType != 'PVREUSE007'}"></td>
                      	<td th:text="${list.peopleCnt}"></td>                     	
                      	<td th:text="${list.description}"></td>
                      	<td th:text="${#temporals.format(list.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
                      	                                
                      </tr>
                      </tbody>
                    </table>
                  </div>                
                   <div class="row justify-content-between">
                   <div class="col-auto">
                  	<button type="button" class="btn btn-danger"id="deleteUse" th:if="${accessAuth eq 'ACC003'}">삭제</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">
                    <button type="button" class="btn btn-success"id="historyBtn">수정이력</button>
                    <button type="button" class="btn btn-success"id="addPvre" th:unless="${accessAuth eq 'ACC001'}">등록</button>
                  </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>

	<div class="modal fade" id="useEditModal" 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="useEditModalContent">
        <div class="modal-header">
        </div>
        <div class="modal-body">
          <div class="tab-content border border-top-0" id="configCellPhone">
          </div>
        </div>
      </div>
    </div>
  </div>


</div>
</html>