<?= $this->extend('layout/default') ?>
<?= $this->section('content') ?>
<div class="container-fluid px-4">
    <h1 class="mt-4"><?= $title ?></h1>
    <?php if (session()->getFlashdata('success')) : ?>
    <div class="alert alert-success alert-dismissible fade show" role="alert">
        <?= session()->getFlashdata('success') ?>
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<?php endif; ?>

<?php if (session()->getFlashdata('error')) : ?>
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <?= session()->getFlashdata('error') ?>
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<?php endif; ?>
    <div class="card mb-4 shadow border-0">
        <div class="card-header bg-white py-3">
            <a href="<?= base_url('admin/slider/tambah') ?>" class="btn btn-primary btn-sm">
                <i class="fa fa-plus"></i> Tambah Slider
            </a>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered">
                    <thead class="bg-light">
                        <tr>
                            <th>No</th>
                            <th>Foto</th>
                            <th>Judul</th>
                            <th>Deskripsi</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $no = 1; foreach ($slider as $s) : ?>
                        <tr>
                            <td><?= $no++ ?></td>
                            <td><img src="<?= base_url('assets/img/slider/' . $s['foto']) ?>" width="150" class="img-thumbnail"></td>
                            <td><?= $s['judul'] ?></td>
                            <td><?= $s['deskripsi'] ?></td>
                            <td>
                                <a href="<?= base_url('admin/slider/hapus/' . $s['id_slider']) ?>" 
                                   class="btn btn-danger btn-sm" 
                                   onclick="return confirm('Hapus slider ini?')">Hapus</a>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>