<script type="text/javascript">
    $(function () {
        $("#slides-table").find("tbody").sortable({
            opacity: 0.6,
            cursor: "move",
            placeholder: "placeholder",
            helper: fixHelper,
            axis: "y",
            update: function() {
                var order = $(this).sortable("serialize");
                $.post(prefix + "slides/reorder", order, function(data) {
                });
            }
        });
    });
</script>

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

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

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

                <tbody>
                <?php foreach ($slides as $slide): ?>
                    <tr id="sequence_<?= $slide['id'] ?>" class="<?= $slide['active'] ? 'border-success' : 'border-error' ?>">
                        <td class="record-actions"><i class="fa fa-bars"></i> <img height="50" src="<?= upload_to('/slides/' . $slide['image']) ?>" /></td>
                        <td><?= $slide['title'] ?></td>
                        <td><?= $slide['url'] ?></td>
                        <td><?= ucfirst($slide['type']) ?></td>
                        <td class="record-actions">
                            <a data-ajax class="btn btn-xs btn-default" href="<?= admin_url_to('/slides/edit/' . $slide['id']) ?>"><?= __('Edit') ?></a>
                            <a data-ajax-delete class="btn btn-danger btn-xs" href="<?= admin_url_to('/slides/delete/' . $slide['id']) ?>"><?= __('Delete') ?></a>
                        </td>
                    </tr>
                <?php endforeach ?>
                </tbody>
            </table>
        </div>
    <?php endif ?>
</section>
