<?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('history'));
?> 
<h1 class="page-title">
    <?= Ci::$title ?>
    <hr class="hiasan-judul blue" />
</h1>
<div class="row">
    <div class="col-xs-12 text-right">
        <a href="<?= base_url('dashboard/excel/' . $user_absen->absen_id . $redir) ?>" class="btn btn-primary">
            Download Excel
        </a>   
    </div>
</div>
<br /><br />
<div class="row">
    <div class="col-sm-8">
        <?= $pagination->create_forms($query_pagination) ?>
        <p>
            Total: <?= isset($query_pagination['total_row']) ? $query_pagination['total_row'] : '-' ?>
            Absen Point: <?= $user_absen ? $user_absen->absen->nama : '-' ?>
        </p>
        <?= form_open('absen/check-all' . $redir, ['class' => 'check-all-form']) ?>
        <button type="submit" name="submit" value="delete_all" class="btn red btn-xs check-all-confirm" style="display:none;" onclick="return script.deletePrompt();">
            <i class="fa fa-times"></i> Delete All
        </button>
        <div class="table-responsive">
            <table class="table table-hover table-bordered sort">
                <thead>
                    <tr>
                        <?php // $pagination->check_all_header() ?>
                        <!--<th data-order="user_profile.name" class="both" style="text-align:center;"><?= lang('nama_user') ?></th>-->
                        <th data-order="visitor_profile.name" class="both"  style="text-align:center;"><?= lang('nama_visitor') ?></th>
                          <!--<th data-order="visitor_profile.card_name" class="both"  style="text-align:center;">Name Tag</th>-->
                        <th data-order="visitor_profile.optic" class="both"  style="text-align:center;"><?= lang('optic') ?></th>
                        <!--<th data-order="visitor_profile.table" class="both"  style="text-align:center;"><?= lang('table') ?></th>-->
                        <th data-order="visitor_absen.souvenir" class="both"  style="text-align:center;"><?= lang('souvenir') ?></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>
                                <?php // $pagination->check_all($data->id) ?>
                                <!--<td><?= $data->nama_user ?></td>-->
                                <td><?= $data->nama_visitor ?></td>
                                <!--<td><?= $data->card ?></td>-->
                                <td><?= $data->nama_optic ?></td>
                                <!--<td><?= $data->table_number ?></td>-->
                                <td><?= $data->souvenir == 1 ? 'Yes' : 'No' ?></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)) : '-' ?>
                                    <div class="table-button" style="display:none;">
                                        <a href="<?= base_url('dashboard/update/' . $user_absen->absen_id . '/' . $user_absen->user_id . '/' . $data->visitor_id . $redir) ?>" class="table-button-action blue" title="Edit">
                                            <i class="fa fa-pencil"></i>
                                        </a>
                                        <a href="<?= base_url('dashboard/delete/' . $user_absen->absen_id . '/' . $user_absen->user_id . '/' . $data->visitor_id . $redir) ?>" class="table-button-action red" onclick="return script.deletePrompt();" title="<?= lang('remove') ?>">
                                            <i class="fa fa-times"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="5" style="text-align: center;">
                                Data tidak tersedia
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?= form_close() ?>
        <div class="pagination-wrapper">
            <?= $pagination->create_links(); ?>
        </div>
    </div>
    <div class="col-sm-4">

        <?= form_open('dashboard/visitor-absen?redir=' . urlencode(current_url() . url_query()), ['class' => 'form-horizontal']) ?>
        <div class="form-group">
            <?= lang('name', [], 'name', ['class' => 'col-sm-3 control-label']) ?>
            <div class="col-sm-9">
                <div class="form-control">
                    <?= $user ? $user['profile']['name'] : '-' ?>
                </div>
            </div>
        </div>
        <div class="form-group">
            <?= lang('absen', [], 'absen', ['class' => 'col-sm-3 control-label']) ?>
            <div class="col-sm-9">
                <div class="form-control">
                    <?= $user_absen ? $user_absen->absen->nama : '-' ?>
                </div>
            </div>
        </div>
        <div class="form-group">
            <?= lang('souvenir', [], 'souvenir', ['class' => 'col-sm-3 control-label']) ?>
            <div class="col-sm-9">
                <div class="mt-checkbox-list">
                    <label class="mt-checkbox">
                        <?= form_checkbox('souvenir', '1', true) ?>
                        <span></span>
                    </label>
                </div>

            </div>
        </div>
        <div class="form-group">
            <?= lang('scan_code', [], 'scan_code', ['class' => 'col-sm-3 control-label']) ?>
            <div class="col-sm-9">
                <?= form_input('scan_code', '', ['class' => 'form-control', 'autofocus' => 'autofocus']) ?>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-9 col-sm-offset-3">
                <?= form_submit('submit', lang('Submit'), ['class' => 'btn btn-primary']) ?>
            </div>
        </div>
        <?= form_close() ?>
    </div>
</div>
<?php
Ci::set_script(<<<EOD
     var page_script = function () {
        var the;
        return {
            init: function () {
                the = this;
                script.orderTable('{$query_pagination["order"]}');
                script.handleOrder();
            }
        };
    }();
    $(document).ready(function () {
        page_script.init();
    });
EOD
    , 'embed');
