<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<script src="<c:url value="/js/admin/request.js"/>"></script>

<div class="section_content">
    <h1 class="h4 m-3">지도사용 요청</h1>
    <form:form commandName="useRequestSearchVO" name="searchForm" action="/admin/request" method="get">
    <input type="hidden" name="status" value="<c:out value="${useRequestSearchVO.status}" />"/>

    <div class="row justify-content-between bg-white mx-3 py-2">

        <div class="col-auto">
            <ul class="nav nav-pills" role="tablist">
                <li role="presentation" class="nav-item ms-2">
                  <a class="nav-link ${empty useRequestSearchVO.status?'active':''}" href="/admin/request">전체</a>
                </li>
                <li role="presentation" class="nav-item">
                  <a class="nav-link ${useRequestSearchVO.status eq '0'?'active':''}" href="/admin/request?status=0">승인</a>
                </li>
                <li role="presentation" class="nav-item">
                  <a class="nav-link ${useRequestSearchVO.status eq '-1'?'active':''}" href="/admin/request?status=-1">반려</a>
                </li>
                <li role="presentation" class="nav-item">
                  <a class="nav-link ${useRequestSearchVO.status eq '99'?'active':''}" href="/admin/request?status=99">승인대기(${statusCnt})</a>
                </li>
            </ul>
        </div>

        <div class="col-auto row">
            <div class="col-auto">
                <select class="form-select" name="searchCondition">
                    <option value="all" ${useRequestSearchVO.searchCondition eq 'all'?'selected':''}>통합검색</option>
                    <option value="title" ${useRequestSearchVO.searchCondition eq 'title'?'selected':''}>작업명</option>
                    <option value="name" ${useRequestSearchVO.searchCondition eq 'name'?'selected':''}>이름</option>
                    <option value="company" ${useRequestSearchVO.searchCondition eq 'company'?'selected':''}>소속</option>
                </select>
            </div>
            <div class="col-auto">
                <input type="text" class="form-control" name="searchKeyword" value="${userSearchVO.searchKeyword}"/>
            </div>
            <div class="col-auto">
                <input class="btn btn-outline-secondary" type="submit" value="검색"/>
            </div>
        </div>
    </div>

    <div class="row m-3 p-2 bg-white">
        <table class="table table-hover text-center">
            <thead>
            <tr>
                <th>번호</th>
                <th>작업명</th>
                <th>소속</th>
                <th>담당자</th>
                <th>날짜</th>
                <th>상태</th>
            </tr>
            </thead>
            <tbody>
            <c:if test="${count >= 1}">
                <c:forEach var="item" items="${useRequestList}" varStatus="idx">
                    <tr>
                        <td><c:out value="${item.idx}"/></td>
<%--                        <td ><a href="/admin/request/ <c:out value='${item.idx}' />"><c:out value="${item.title}"/></a>--%>
                        <td class="clickAbleObj title-td" data-idx="${item.idx}">${item.title}</td>
                        <td><c:out value="${item.company}"/></td>
                        <td><c:out value="${item.name}"/></td>
                        <td class="td_date"><c:out value="${item.r_date}"/></td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq '99'}"><span class="card-warning"><c:out
                                        value='승인대기'/></span></c:when>
                                <c:when test="${item.status eq '0'}"><span class="card-success"><c:out
                                        value='승인'/></span></c:when>
                                <c:when test="${item.status eq '-1'}"><span class="card-default"><c:out
                                        value='반려'/></span></c:when>
                            </c:choose>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            <c:if test="${count == 0}">
                <tr>
                    <td colspan="6">요청한 목록이 없습니다.</td>
                </tr>
            </c:if>
            </tbody>
        </table>
    </div>
    <div class="text-page">
        <form:hidden path="pageIndex"/></form:form>
        <nav aria-label="Page navigation">
            <ul class="pagination justify-content-center">
                <ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page"/>
            </ul>
        </nav>
    </div>
</div>


<div class="modal fade" id="adminRequestModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="adminRequestModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="adminRequestModalLabel">지도 사용 요청</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body" id="adminRequestModalBody">

            </div>
        </div>
    </div>
</div>


<div class="section_title">
    <!-- <p>현장 지원 시스템</p> -->
</div>