<?php
/*
 * *************************************************
 * Copyright (C) 2021 Earworks.                    *
 * Codeigniter Project Template Modification       *
 * Please contact our email for more information : *
 * contact@earworks.co.id                          *
 * *************************************************
 */

defined('BASEPATH') OR exit('No direct script access allowed');
Ci::set_title(lang('absen'));
?>
<section class="profile" style="position:relative;">
    <div style="display:flex;width:100%;justify-content: center;align-items:center;flex-direction: column;">
        <div class="table-responsive">
            <table class="table table-hover table-bordered sort">
                <thead>
                    <tr>
                        <th data-order="absen.nama" class="both" style="text-align:center;"><?= lang('nama_absen') ?></th>
                        <th colspan="2" data-order="visitor_absen.created_at" class="both" style="text-align:center;"><?= lang('created_at') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php if ($query_pagination['data']->count() > 0) : ?>
                        <?php foreach ($query_pagination['data'] as $data) : ?>
                            <tr>
                                <td><?= $data->nama_absen ?></td>
                                <td><?= $data->created_at ? date('d-m-Y', strtotime($data->created_at)) : '-' ?></td>
                                <td><?= $data->created_at ? date('H:i', strtotime($data->created_at)) : '-' ?></td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="5" style="text-align: center;">
                                Data tidak tersedia
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <div class="pagination-wrapper">
            <?= $pagination->create_links(); ?>
        </div>
    </div>
</section>
<?php
Ci::set_script(<<<EOD
     var page_script = function () {
        var the;
        return {
            init: function () {
                the = this;
                script.orderTable('{$query_pagination["order"]}');
                script.handleOrder();
                console.log('asd');
            }
        };
    }();
    $(document).ready(function () {
        page_script.init();
    });
EOD
        , 'embed');
