<%@ 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="../../../js/admin/fieldData.js"></script>


<style>
	.searchList > li{
		display: inline;
	}
</style>

		<div class="section_title">
			<!-- <p>현장 지원 시스템</p> -->
		</div>
		<div class="section_content">
			<form:form commandName="fieldDataSearchVO" name="searchForm" action="/admin/fieldData" method="get">

			<div class="d-flex justify-content-end">
				<div class="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="search_div">
					<div class="search_menu">&nbsp;</div>
					<div class="search_keyword">
						<select class="form-control search_selectbox" 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>
						<input type="text" class="form-control search_inputbox" name="searchKeyword" value="<c:out value="${fieldDataSearchVO.searchKeyword}" />" />
						<input class="btn btn-outline-secondary" type="submit" value="검색" />
					</div>
				</div>--%>
				
				<table class="list-table">
					<thead>
						<tr><th colspan="6">현장수집 데이터</th></tr>
						<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>
									<td><a href="/admin/fieldData/${item.id}"><c:out value="${item.id}" /></a></td>
									<td><a href="/admin/fieldData/${item.id}"><c:out value="${item.region}" /></a></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 class="text-page">
					<nav aria-label="Page navigation">
						<ul class="pagination justify-content-center">
							<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fn_link_page" />
							<form:hidden path="pageIndex" />
							</form:form>
						</ul>
					</nav>
				</div>
		</div>
