<?= $this->extend('layouts/main') ?>

<?= $this->section('content') ?>

<div class="row">
    <div class="col-md-12 col-xl-12">
        <div class="main-card mb-3 card">
            <div class="card-header bg-white border-bottom shadow-sm">
                <div class="d-flex flex-wrap align-items-center gap-3 card-header-tab">
                    <div>
                        <h4 class="mb-0 fw-bold text-dark">모바일 자동검증</h4>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form class="row align-items-end" id="frm_srch_info" onsubmit="return false;">

                    <div class="col-md-2">
                        <label class="form-label mb-1">매물번호</label>
                        <input type="text" class="form-control" name="atcl_no">
                    </div>

                    <!-- 검색 버튼 -->
                    <div class="col-md-1 d-grid">
                        <button type="button" class="btn btn-primary" id="btnSearch">
                            검색
                        </button>
                    </div>

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

    <div class="col-md-12 col-xl-12">
        <div class="main-card mb-3 card">
            <div class="card-header d-flex align-items-center">
                <div class="d-flex align-items-center flex-wrap" style="gap: 8px; flex: 1">
                </div>
                <div class="ml-auto">
                    <button class="btn btn-sm btn-outline-success" id="excel-download">
                        <i class="fa fa-fw" aria-hidden="true" title="file-excel-o"></i>
                        엑셀다운로드
                    </button>
                </div>
            </div>
            <div class="card-body">
                <table id="aptList" class="table table-hover table-striped table-bordered">
                    <thead>
                        <tr>
                            <th>매물번호</th>
                            <th>매물종류</th>
                            <th>거래종류</th>
                            <th>등록시간</th>
                            <th>노출일시</th>
                            <th>주소</th>
                            <th>상세주소</th>
                            <th>매체사</th>
                            <th>중개업소명</th>
                            <th>매물검증방식코드</th>
                            <th>자동검증통과여부</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>

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

<?= $this->endSection() ?>

<?= $this->section('page_styles') ?>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.7/css/dataTables.bootstrap5.min.css" />
<?= $this->endSection() ?>

<?= $this->section('page_scripts') ?>
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.bootstrap5.min.js"></script>
<script defer src="/architectui/assets/js/datatable.kor.js"></script>
<script type="text/javascript">

  const codes = [];

  $(function () {

    // Bootstrap tooltip 초기화
    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
      return new bootstrap.Tooltip(tooltipTriggerEl);
    });

    // localStorage에서 검색 조건 복원
    restoreFormData();

  });

  // localStorage에 검색 조건 저장
  function saveFormData() {
    const formData = $('#frm_srch_info').serializeArray();
    const formObject = {};
    formData.forEach(item => {
      formObject[item.name] = item.value;
    });
    localStorage.setItem('m711_search_form', JSON.stringify(formObject));
  }

  // localStorage에서 검색 조건 복원
  function restoreFormData() {
    const savedData = localStorage.getItem('m711_search_form');
    if (savedData) {
      const formObject = JSON.parse(savedData);
      Object.keys(formObject).forEach(key => {
        const $element = $('#frm_srch_info').find(`[name="${key}"]`);
        if ($element.length) {
          $element.val(formObject[key]);
        }
      });
    }
  }

</script>
<?= $this->endSection() ?>