<div class="row">
    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="card">
            <h5 class="card-header">Results</h5>
            <div class="card-body">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th scope="col">#</th>
                            <th scope="col">Name</th>
                            <th scope="col">Phone No</th>
                            <th scope="col">Time In</th>
                            <th scope="col">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($visitors as $key => $visitor): ?>
                            <tr>
                                <th scope="row"><?= $key + 1 ?>.</th>
                                <td><?= join(' ', [$visitor->first_name, $visitor->last_name]) ?></td>
                                <td><?= $visitor->phone ?></td>
                                <td><?= date('H:i', strtotime($visitor->created_at)) ?></td>
                                <td>
                                    <a href="#" class="btn btn-rounded btn-primary btn-xs" data-bs-toggle="modal" data-bs-target="#signout_<?= $visitor->id ?>">Signout</a>
                                    <!-- Modal -->
                                    <div class="modal fade" id="signout_<?= $visitor->id ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Sign Out <?= join(' ', [$visitor->first_name, $visitor->last_name]) ?></h5>
                                                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                                </div>
                                                <div class="modal-body">
                                                    <p>Are you sure you want to sign out </p>
                                                </div>
                                                <div class="modal-footer">
                                                    <a href="#" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</a>
                                                    <a href="<?= url_to('visitor_signout', $visitor->id) ?>" class="btn btn-primary">Confirm</a>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>