<?= $this->extend('layouts/admin') ?><?= $this->section('content') ?>
<form class="panel mb-4" method="post" enctype="multipart/form-data" action="<?= base_url('admin/galeri') ?>"><?= csrf_field() ?><div class="row g-3 align-items-end"><div class="col-md-5"><label class="form-label">Foto (bisa banyak)</label><input class="form-control" type="file" name="foto[]" accept="image/*" multiple required></div><div class="col-md-4"><label class="form-label">Caption</label><input class="form-control" name="caption"></div><div class="col-md-1"><label class="form-label">Urutan</label><input class="form-control" type="number" name="urutan" value="0"></div><div class="col-md-2"><button class="btn btn-emerald w-100">Upload</button></div></div></form>
<div class="row g-3"><?php foreach($items as $item): ?><div class="col-6 col-md-4 col-xl-3"><div class="panel p-2"><img class="gallery-thumb" src="<?= base_url($item['foto']) ?>" alt="<?= esc($item['caption'] ?: 'Foto galeri') ?>"><div class="d-flex justify-content-between align-items-center gap-2 p-2"><small class="text-truncate"><?= esc($item['caption'] ?: 'Tanpa caption') ?></small><div class="d-flex gap-1"><a class="btn btn-sm btn-outline-warning" href="<?= base_url('admin/galeri/'.$item['id'].'/edit') ?>"><i class="bi bi-pencil"></i></a><form method="post" action="<?= base_url('admin/galeri/'.$item['id']) ?>"><?= csrf_field() ?><input type="hidden" name="_method" value="DELETE"><button class="btn btn-sm btn-outline-danger" onclick="return confirm('Hapus foto?')"><i class="bi bi-trash"></i></button></form></div></div></div></div><?php endforeach ?></div>
<?= $this->endSection() ?>
