<%@ 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>
  field_data = JSON.parse('${fieldDataVO.field_data}');
</script>
<div class="section_content">
  <div class="row bg-white py-2">
    <div class="col-12 row justify-content-end">
      <div class="col-auto">
        <input type="button" class="btn btn-sm btn-info" id="collectionInfoBtn" value="수집 정보 확인">
      </div>
    </div>

    <div class="col-12 col-sm-4 collectionInfo" style="display: none;">
      <h5><i class="bi bi-dot"></i> 작성자 정보</h5>
      <div class="row mb-3 mx-2 border border-dark border-start-0 border-end-0">
        <label for="company" class="col-4 col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">소속</label>
        <div class="col-8 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="company" placeholder="col-form-label" value="${userVO.company}" readonly>
        </div>
        <label for="name" class="col-4 col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">이름</label>
        <div class="col-8 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="name" placeholder="col-form-label" value="${userVO.name}" readonly>
        </div>
        <label for="phonenum" class="col-4 col-form-label fw-bold text-end bg-secondary" style="--bs-bg-opacity: .5">연락처</label>
        <div class="col-8 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="phonenum" placeholder="col-form-label" value="${userVO.phonenum}" readonly>
        </div>
      </div>
    </div>

    <div class="col-12 col-sm-8 collectionInfo" style="display: none;">
      <h5><i class="bi bi-dot"></i> 지도 정보</h5>
      <div class="row mb-3 mx-2 border border-dark border-start-0 border-end-0">
        <label for="layer_id" class="col-4 col-sm-2 col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">레이어 ID</label>
        <div class="col-8 col-sm-4 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="layer_id" placeholder="col-form-label" value="${fieldDataVO.layer_id}" readonly>
        </div>
        <label for="save_date" class="col-4 col-sm-2  col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">수집일</label>
        <div class="col-8 col-sm-4 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="save_date" placeholder="col-form-label" value="${fieldDataVO.save_date}" readonly>
        </div>
        <label for="region" class="col-4 col-sm-2  col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">지역</label>
        <div class="col-8 col-sm-4 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="region" placeholder="col-form-label" value="${fieldDataVO.region}" readonly>
        </div>
        <label class="col-4 col-sm-2  col-form-label fw-bold text-end bg-secondary border-bottom" style="--bs-bg-opacity: .5">상태</label>
        <div class="col-8 col-sm-4 border-bottom my-auto">
          <c:choose>
            <c:when test="${fieldDataVO.status eq '0'}">
              <span class="status-bar status-warning ms-2 w-50 text-center">수집</span>
            </c:when>
            <c:when test="${fieldDataVO.status eq '1'}">
              <span class="status-bar status-danger ms-2 w-50 text-center">검증실패</span>
            </c:when>
            <c:when test="${fieldDataVO.status eq '2'}">
              <span class="status-bar status-success ms-2 w-50 text-center">검증성공</span>
            </c:when>
            <c:when test="${fieldDataVO.status eq '3'}">
              <span class="status-bar status-danger ms-2 w-50 text-center">반영실패</span>
            </c:when>
            <c:when test="${fieldDataVO.status eq '4'}">
              <span class="status-bar status-success ms-2 w-50 text-center">반영</span>
            </c:when>
          </c:choose>
        </div>
        <label for="description" class="col-4 col-sm-2  col-form-label fw-bold text-end bg-secondary" style="--bs-bg-opacity: .5">설명</label>
        <div class="col-8 col-sm-4 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="description" readonly>
        </div>
        <label for="errInfo" class="col-4 col-sm-2  col-form-label fw-bold text-end bg-secondary" style="--bs-bg-opacity: .5">오류내용</label>
        <div class="col-8 col-sm-4 border-bottom">
          <input type="text" class="form-control bg-white border-0" id="errInfo" readonly>
        </div>
      </div>
    </div>

    <div class="col-12 row">
      <div class="col-12 col-sm-7">
        <h5><i class="bi bi-dot"></i> 측량 데이터</h5>
        <div class="map mx-2" id="map">

        </div>
      </div>
      <div class="col-12 col-sm-5">
        <h5><i class="bi bi-dot"></i> 속성 정보</h5>
        <div id="fieldDataDiv" class="mx-2 border border-dark border-start-0 border-end-0">
          <table class="table table-hover">
            <tbody id="fieldDataBody">

            </tbody>
          </table>
        </div>
      </div>
      <div class="col-12">
        <ul id="fieldDataPaging" class="fieldDataPaging"></ul>
      </div>
    </div>
  </div>
  <div class="row justify-content-between">
    <p class="col-auto">
      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
    </p>
    <p class="col-auto">
      <input class="btn btn-secondary" type="button" value="표준DB변환 및 검증" onclick="fieldVerify();"/>
      <input class="btn btn-success" type="button" value="반영" onclick="fieldReflect();"/>
    </p>
  </div>
</div>