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

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

<section class="content">
    <?php if (empty($downloads)): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No downloads found') ?></p>
        </div>
    <?php else: ?>
        <div class="box box-default table-responsive">
            <table data-table class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th width="200"><?= __('Name') ?></th>
                        <th><?= __('Description') ?></th>
                        <th width="100"><?= __('Size') ?></th>
                        <th><?= __('Links') ?></th>
                        <th width="80"></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($downloads as $id => $download): ?>
                        <tr>
                            <td><?= $download['name'] ?></td>
                            <td><?= $download['desc'] ?></td>
                            <td><?= $download['size'] ?></td>
                            <td>
                                <?php $i = 0; foreach ($download['links'] as $name => $url): ?>
                                    <a href="<?= $url ?>" target="_blank"><?= $name ?></a><?= ++$i < count($download['links']) ? ', ' : '' ?>
                                <?php endforeach ?>
                            </td>
                            <td class="record-actions">
                                <a data-ajax class="btn btn-xs btn-default" href="<?= admin_url_to('/downloads/edit/' . $id) ?>"><?= __('Edit') ?></a>
                                <a data-ajax-delete class="btn btn-xs btn-danger" href="<?= admin_url_to('/downloads/delete/' . $id) ?>"><?= __('Delete') ?></a>
                            </td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
            </table>
        </div>
    <?php endif ?>
</section>
