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

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

<section class="content">
    <?php if (empty($posts)): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No posts found') ?></p>
        </div>
    <?php else: ?>

        <div class="box box-default table-responsive">
            <table class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th width="100"><?= __('Category') ?></th>
                        <th><?= __('Title') ?></th>
                        <th><?= __('Locale') ?></th>
                        <th width="200"><?= __('Author') ?></th>
                        <th width="100"><?= __('Views') ?></th>
                        <th width="200"><?= __('Posted in') ?></th>
                        <th width="10"></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($posts as $post): ?>
                        <tr>
                            <td><?= util('Posts.Posts')->postType($post['type']) ?></td>
                            <td><?= $post['title'] ?></td>
                            <td><?= $post['locale'] ?></td>
                            <td><?= $post['username'] ?></td>
                            <td><?= $post['views'] ?></td>
                            <td><?= util('Date')->dateTime($post['create_date']) ?></td>
                            <td class="record-actions">
                                <a data-ajax class="btn btn-default btn-xs" href="<?= admin_url_to('/posts/edit/' . $post['id']) ?>"><?= __('Edit') ?></a>
                                <a data-ajax-delete class="btn btn-danger btn-xs" href="<?= admin_url_to('/posts/delete/' . $post['id']) ?>"><?= __('Delete') ?></a>
                            </td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
            </table>
        </div>
    <?php endif ?>
</section>