<?= $this->extend('backend/layout/main'); ?>
<?= $this->section('css'); ?>
<link rel="stylesheet" type="text/css" href="<?= base_url() ?>assets/common/lightbox/css/lightbox.min.css">
<?= $this->endSection(); ?>
<?= $this->section('title'); ?>Dashboard<?= $this->endSection(); ?>
<?= $this->section('content'); ?>
<div class="container-fluid dashboard-content ">
    <!-- ============================================================== -->
    <!-- pageheader  -->
    <!-- ============================================================== -->
    <div class="row">
        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
            <div class="page-header">
                <h2 class="pageheader-title">Dashboard <?= env('APP_NAME') ?> </h2>
                <div class="page-breadcrumb">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">Dashboard</li>
                            <li class="breadcrumb-item active" aria-current="page">VRP</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>
    <!-- ============================================================== -->
    <!-- end pageheader  -->
    <!-- ============================================================== -->
    <div class="ecommerce-widget">

        <div class="row">
            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                <div class="card border-3 border-top border-top-primary">
                    <div class="card-body">
                        <h5 class="text-muted">Today</h5>
                        <div class="metric-value d-inline-block">
                            <h1 class="mb-1"><?= $today ?></h1>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                <div class="card border-3 border-top border-top-primary">
                    <div class="card-body">
                        <h5 class="text-muted">In Premises</h5>
                        <div class="metric-value d-inline-block">
                            <h1 class="mb-1"><?= $in_premises ?></h1>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                <div class="card border-3 border-top border-top-primary">
                    <div class="card-body">
                        <h5 class="text-muted">Yesterday</h5>
                        <div class="metric-value d-inline-block">
                            <h1 class="mb-1"><?= $yesterday ?></h1>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                <div class="card border-3 border-top border-top-primary">
                    <div class="card-body">
                        <h5 class="text-muted">Total Visitors</h5>
                        <div class="metric-value d-inline-block">
                            <h1 class="mb-1"><?= $total->count ?></h1>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xl-12 col-lg-12 col-md-6 col-sm-12 col-12">
                <div class="card">
                    <h5 class="card-header">Recent Visitors</h5>
                    <div class="card-body p-0">
                        <div class="table-responsive">
                            <table class="table">
                                <thead class="bg-light">
                                    <tr class="border-0">
                                        <th class="border-0">#</th>
                                        <th class="border-0">Name</th>
                                        <th class="border-0">Gender</th>
                                        <th class="border-0">Phone No</th>
                                        <th class="border-0">From</th>
                                        <th class="border-0">To</th>
                                        <th class="border-0">Purpose</th>
                                        <th class="border-0">Signature</th>
                                        <th class="border-0">Date</th>
                                        <th class="border-0">Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach ($visitors as $key => $visitor): ?>
                                        <tr>
                                            <td><?= $key + 1 ?>.</td>
                                            <td><?= join(' ', [$visitor->first_name, $visitor->last_name]) ?></td>
                                            <td><?= $visitor->gender ?> </td>
                                            <td><?= $visitor->phone ?> </td>
                                            <td><?= $visitor->coming_from ?> </td>
                                            <td><?= $visitor->going_to ?> </td>
                                            <td><?= $visitor->visit_purpose ?> </td>
                                            <td><?= view_cell('SignatureCell', ['visitor' => $visitor]) ?></td>
                                            <td><?= Carbon\Carbon::parse($visitor->created_at)->diffForHumans(null, null, true) ?> </td>
                                            <td><?= view_cell('StatusCell', ['status' => $visitor->status]) ?> </td>
                                        </tr>
                                    <?php endforeach; ?>

                                    <tr>
                                        <td colspan="9"><a href="<?= url_to('visitors') ?>" class="btn btn-outline-light float-right">View All</a></td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection(); ?>

<?= $this->section('js'); ?>
<script src="<?= base_url() ?>assets/common/lightbox/js/lightbox-plus-jquery.min.js"></script>
<?= $this->endSection(); ?>