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

    <div class="actions">
        <a data-ajax class="btn btn-success btn-sm" href="<?= admin_url_to('/tracker/categories/add') ?>"><?= __('Add') ?></a>
    </div>
</section>

<section class="content">
    <?php if (empty($categories)): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No category found') ?></p>
        </div>
    <?php else: ?>
        <div class="box box-default table-responsive">
            <table class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th><?= __('Name') ?></th>
                        <th><?= __('Status') ?></th>
                        <th width="10"></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($categories as $category): ?>
                        <tr>
                            <td><?= $category['name'] ?></td>
                            <td>
                                <?= util('Text')->toList(util('Hash')->extract(json_decode($category['status'], true) ?? [], '{n}.name')) ?>
                            </td>
                            <td class="record-actions">
                                <a data-ajax class="btn btn-xs btn-default" href="<?= admin_url_to('/tracker/categories/edit/' . $category['id']) ?>"><?= __('Edit') ?></a>
                                <a data-ajax-delete class="btn btn-danger btn-xs" href="<?= admin_url_to('/tracker/categories/delete/' . $category['id']) ?>"><?= __('Delete') ?></a>
                            </td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
            </table>
        </div>
    <?php endif ?>
</section>