<section class="content-header">
    <h1><?= __('Logs') ?></h1>

    <div class="actions">
        <a data-load-with-modal data-modal="modal-search" class="btn btn-default btn-sm" href="<?= admin_url_to('/logs/search') ?>"><?= __('Search') ?></a>
    </div>
</section>

<div class="modal" id="modal-search"></div>
<div class="modal" id="modal-metadata"></div>

<section class="content">
    <?php if (!$total): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No logs found') ?></p>
        </div>
    <?php else: ?>
        <div class="box box-default table-responsive">
            <table id="products-table" class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th><?= __('Log') ?></th>
                        <th><?= __('Type') ?></th>
                        <th><?= __('When') ?></th>
                        <th width="10"></th>
                    </tr>
                </thead>

                <?php foreach ($logs as $log): ?>
                    <tr>
                        <td><?= $log['log'] ?></td>
                        <td><?= $log['type'] ?></td>
                        <td><?= util('Date')->dateTime($log['create_date']) ?></td>
                        <td>
                            <?php $metadata = json_decode($log['metadata'], true) ?>
                            <?php if (!empty($metadata)): ?>
                                <a data-load-with-modal data-modal="modal-metadata" href="<?= admin_url_to('/logs/metadata/' . $log['id']) ?>" class="btn btn-default btn-xs"><?= __('Metadata') ?></a>
                            <?php endif ?>
                        </td>
                    </tr>
                <?php endforeach ?>
            </table>

            <div class="paginator">
                <?= $paginator->toHtml() ?>
            </div>
        </div>
    <?php endif ?>
</section>
