<?= view('admin/layouts/header', ['title' => 'Data Jasa']) ?>
<?= view('admin/layouts/sidebar', [
    'activeMenu' => 'jasa',
    'userName'   => $userName,
    'userEmail'  => $userEmail,
]) ?>
<?= view('admin/layouts/topbar', [
    'pageTitle'    => 'Data Jasa',
    'pageSubtitle' => 'Kelola master biaya jasa untuk transaksi service.',
    'topbarAction' => '<a href="' . site_url('admin/jasa/create') . '" class="btn btn-dark"><i class="bi bi-plus-lg me-1"></i>Tambah Jasa</a>',
    'userName'     => $userName,
    'userRole'     => $userRole,
]) ?>

<section class="content-area">
    <?php if (session()->getFlashdata('success')) : ?>
        <div class="alert alert-success"><?= esc(session()->getFlashdata('success')) ?></div>
    <?php endif; ?>

    <?php if (session()->getFlashdata('error')) : ?>
        <div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
    <?php endif; ?>

    <div class="panel p-4">
        <div class="table-responsive">
            <table class="table table-hover align-middle datatable">
                <thead>
                    <tr>
                        <th>Nama Jasa</th>
                        <th class="text-end">Biaya</th>
                        <th class="text-end">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($jasa as $item) : ?>
                        <tr>
                            <td class="fw-semibold"><?= esc($item['nama_jasa']) ?></td>
                            <td class="text-end">Rp <?= esc(number_format((float) ($item['biaya'] ?? 0), 0, ',', '.')) ?></td>
                            <td class="text-end text-nowrap">
                                <a href="<?= site_url('admin/jasa/edit/' . $item['id']) ?>" class="btn btn-sm btn-primary btn-icon" title="Edit jasa" aria-label="Edit jasa">
                                    <i class="bi bi-pencil-square"></i>
                                </a>
                                <form action="<?= site_url('admin/jasa/delete/' . $item['id']) ?>" method="post" class="d-inline" data-confirm="Hapus data jasa ini?">
                                    <?= csrf_field() ?>
                                    <button type="submit" class="btn btn-sm btn-danger btn-icon" title="Hapus jasa" aria-label="Hapus jasa">
                                        <i class="bi bi-trash3"></i>
                                    </button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</section>

<?= view('admin/layouts/footer') ?>
