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

<?= $this->section('content') ?>
<style>
    th {
        text-align: center;
    }

    .text-center {
        text-align: center;
    }

    table tbody tr {
        cursor: pointer;
    }
</style>

<h1>Dashboard</h1>

<div class="row">
    <div class="col-md-4 col-xl-4">
        <div class="main-card mb-3 card">
            <div class="card-header">
                <h5 class="card-title">예약 미확정 매물 목록</h5>
                <div class="ms-auto d-flex align-items-center gap-3">
                    <a href="">
                        더보기 <small>></small>
                    </a>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="mb-0 table">
                        <thead>
                            <tr>
                                <th>접수일자</th>
                                <th>예약일자</th>
                                <th>오전/오후</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (empty($statistics['reserve'])): ?>
                                <tr>
                                    <td class="text-center" colspan="3">데이터가 없습니다.</td>
                                </tr>
                            <?php else: ?>
                                <?php
                                $nRow = 1;
                                foreach ($statistics['reserve'] as $row):
                                    ?>
                                    <tr>
                                        <th scope="row"> <?= substr($row['rcpt_tm'], 0, 10) ?></th>
                                        <td class="text-center"><?= substr($row['rsrv_date'], 0, 10) ?></td>
                                        <td class="text-center"><?= $row['rsrv_tm_ap'] ?></td>
                                    </tr>
                                    <?php
                                    $nRow++;
                                endforeach;
                                ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4 col-xl-4">
        <div class="main-card mb-3 card">
            <div class="card-header">
                <h5 class="card-title">공지사항</h5>
                <div class="ms-auto d-flex align-items-center gap-3">
                    <a href="/board/notice/lists">
                        더보기 <small>></small>
                    </a>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="mb-0 table">
                        <colgroup>
                            <col width="10%" />
                            <col width="70%" />
                            <col width="20%" />
                        </colgroup>
                        <thead>
                            <tr>
                                <th>순번</th>
                                <th>제목</th>
                                <th>등록일자</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (empty($notice)): ?>
                                <tr>
                                    <td class="text-center" colspan="3">데이터가 없습니다.</td>
                                </tr>
                            <?php else: ?>
                                <?php foreach ($notice as $key => $n): ?>
                                    <tr onclick="location.href='board/notice/detail/<?= $n['bbs_sq'] ?>'">
                                        <th scope="row"><?= ($key + 1) ?></th>
                                        <td><?= $n["subject"] ?></td>
                                        <td class="text-center"><?= $n["update_tm"] ?></td>
                                    </tr>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-4 col-xl-4">
        <div class="main-card mb-3 card">
            <div class="card-header">
                <h5 class="card-title">검수지연내역(녹취필요)</h5>
                <div class="ms-auto d-flex align-items-center gap-3">
                    <a href="">
                        더보기 <small>></small>
                    </a>
                </div>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="mb-0 table">
                        <thead>
                            <tr>
                                <th>접수일자</th>
                                <th>촬영일자</th>
                                <th>경과일</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (empty($statistics['status2'])): ?>
                                <tr>
                                    <td class="text-center" colspan="3">데이터가 없습니다.</td>
                                </tr>
                            <?php else: ?>
                                <?php
                                $nRow = 1;
                                foreach ($statistics['status2'] as $row):
                                    ?>
                                    <tr>
                                        <th scope="row"> <?= substr($row['rcpt_tm'], 0, 10) ?></th>
                                        <td class="text-center"><?= substr($row['photo_save_dt'], 0, 10) ?></td>
                                        <td class="text-center"><?= $row['elapsed_dt'] ?></td>
                                    </tr>
                                    <?php
                                    $nRow++;
                                endforeach;
                                ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 col-xl-4">
            <div class="main-card mb-3 card">
                <div class="card-header">
                    <h5 class="card-title">검수지연내역(홍보확인서)</h5>
                    <div class="ms-auto d-flex align-items-center gap-3">
                        <a href="">
                            더보기 <small>></small>
                        </a>
                    </div>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="mb-0 table">
                            <thead>
                                <tr>
                                    <th>접수일자</th>
                                    <th>촬영일자</th>
                                    <th>경과일</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if (empty($statistics['status3'])): ?>
                                    <tr>
                                        <td class="text-center" colspan="3">데이터가 없습니다.</td>
                                    </tr>
                                <?php else: ?>
                                    <?php
                                    $nRow = 1;
                                    foreach ($statistics['status3'] as $row):
                                        ?>
                                        <tr>
                                            <th scope="row"> <?= substr($row['rcpt_tm'], 0, 10) ?></th>
                                            <td class="text-center"><?= substr($row['photo_save_dt'], 0, 10) ?></td>
                                            <td class="text-center"><?= $row['elapsed_dt'] ?></td>
                                        </tr>
                                        <?php
                                        $nRow++;
                                    endforeach;
                                    ?>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>


    </div>
</div>

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