<%@ 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" %>

<link href="<c:out value="/css/normalize.css" />" rel="stylesheet">
<link href="<c:out value="/css/openlayers/ol.css" />" rel="stylesheet">

<script src="<c:out value="/js/openlayers/ol.js" />"></script>
<script src="<c:out value="/js/openlayers/proj4.js" />"></script>

<script src="<c:url value="/js/admin/fieldData.js"/>"></script>
<style>
    .searchList > li {
        display: inline;
    }
</style>
<div class="mx-lg-2">
    <h1 class="h4 m-3"> 현장수집 데이터</h1>
    <form:form commandName="fieldDataSearchVO" name="searchForm" action="/admin/fieldData" method="get">
        <div class="row justify-content-between bg-white mx-3 py-2">
            <div class="col-auto">
                <ul class="nav">
                    <li class="nav-item statusTab">
                        <a class="nav-link ${fieldDataSearchVO.status0 eq 1?'active':'disabled'}" href="#">
                            <input type="checkbox" class="statusChkBox d-none" name="status0" id="status0"
                                   value="1" ${fieldDataSearchVO.status0 eq 1?'checked':''}>
                            <label for="status0">수집</label>
                        </a>
                    </li>
                    <li class="nav-item statusTab">
                        <a class="nav-link ${fieldDataSearchVO.status1 eq 1?'active':'disabled'}" href="#">
                            <input type="checkbox" class="statusChkBox d-none" name="status1" id="status1"
                                   value="1" ${fieldDataSearchVO.status1 eq 1?'checked':''}>
                            <label for="status1">검증실패</label>
                        </a>
                    </li>
                    <li class="nav-item statusTab">
                        <a class="nav-link ${fieldDataSearchVO.status2 eq 1?'active':'disabled'}" href="#">
                            <input type="checkbox" class="statusChkBox d-none" name="status2" id="status2"
                                   value="1" ${fieldDataSearchVO.status2 eq 1?'checked':''}>
                            <label for="status2">검증</label>
                        </a>
                    </li>
                    <li class="nav-item statusTab">
                        <a class="nav-link ${fieldDataSearchVO.status3 eq 1?'active':'disabled'}">
                            <input type="checkbox" class="statusChkBox d-none" name="status3" id="status3"
                                   value="1" ${fieldDataSearchVO.status3 eq 1?'checked':''}>
                            <label for="status3">반영실패</label>
                        </a>
                    </li>
                    <li class="nav-item statusTab">
                        <a class="nav-link ${fieldDataSearchVO.status4 eq 1?'active':'disabled'}" href="#">
                            <input type="checkbox" class="statusChkBox d-none" name="status4" id="status4"
                                   value="1" ${fieldDataSearchVO.status4 eq 1?'checked':''}>
                            <label for="status4">반영</label>
                        </a>
                    </li>
                </ul>
            </div>

            <div class="col-auto row">
                <div class="col-auto">
                    <select class="form-select" name="searchCondition">
                        <option <c:if test="${fieldDataSearchVO.searchCondition eq 'all'}"><c:out
                                value="selected"/></c:if> value="all">통합검색
                        </option>
                        <option <c:if test="${fieldDataSearchVO.searchCondition eq 'name'}"><c:out
                                value="selected"/></c:if> value="name">이름
                        </option>
                        <option <c:if test="${fieldDataSearchVO.searchCondition eq 'company'}"><c:out value="selected"/></c:if>
                                value="company">소속
                        </option>
                        <option <c:if test="${fieldDataSearchVO.searchCondition eq 'region'}"><c:out value="selected"/></c:if>
                                value="region">위치
                        </option>
                    </select>
                </div>

                <div class="col-auto">
                    <input type="text" class="form-control" name="searchKeyword"
                           value="${fieldDataSearchVO.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>Data ID</th>
                    <th>지역</th>
                    <th>소속</th>
                    <th>담당자</th>
                    <th>수집날짜</th>
                    <th>상태</th>
                </tr>
                </thead>
                <tbody>
                <c:if test="${count >= 1}">
                    <c:forEach var="item" items="${fieldDataList}">
                        <tr class="clickAbleObj fieldDataTr" data-id="${item.id}">
                          <%--<a href="/admin/fieldData/${item.id}">--%>
                            <td><c:out value="${item.id}"/></td>
                            <td><c:out value="${item.region}"/></td>
                            <td><c:out value="${item.userVO.company}"/></td>
                            <td><c:out value="${item.userVO.name}"/></td>
                            <td class="td_date"><c:out value="${item.save_date}"/></td>
                            <td>
                                <c:choose>
                                    <c:when test="${item.status eq '0'}"><span class="card-warning">수집</span> </c:when>
                                    <c:when test="${item.status eq '1'}"><span
                                            class="card-default">검증실패</span> </c:when>
                                    <c:when test="${item.status eq '2'}"><span class="card-warning">검증</span> </c:when>
                                    <c:when test="${item.status eq '3'}"><span
                                            class="card-default">반영실패</span> </c:when>
                                    <c:when test="${item.status eq '4'}"><span class="card-success">반영</span> </c:when>
                                </c:choose>
                            </td>
                        </tr>
                    </c:forEach>
                </c:if>
                <c:if test="${count == 0}">
                    <tr>
                        <td colspan="4">요청한 목록이 없습니다.</td>
                    </tr>
                </c:if>
                </tbody>
            </table>
        </div>

        <div class="text-page">
            <form:hidden path="pageIndex"/>
            <nav aria-label="Page navigation">
                <ul class="pagination justify-content-center">
                    <ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page"/>
                </ul>
            </nav>
        </div>
    </form:form>
</div>


<div class="modal fade" id="fieldViewModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
     aria-labelledby="fieldViewModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="fieldViewModalLabel">현장수집 데이터</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body" id="fieldViewModalBody">

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