<div class="row mb-3">
    <div class="col-lg-12">
        <h3 class="page-header"><strong>Data Kelas</strong></h3>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        
        <div style="margin-bottom: 20px;">
            <a href="media.php?module=input_kelas" class="btn btn-success">
                <i class="fa fa-plus"></i> Tambah Kelas
            </a>
        </div>

        <div class="panel panel-primary">
            <div class="panel-heading">Daftar Semua Kelas</div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th class="text-center" width="50">No</th>
                                <th class="text-center">Nama Kelas</th>
                                <th class="text-center" width="200">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
<?php
$no = 1;
// Ambil data kelas dari database
$sql = mysqli_query($koneksi, "SELECT * FROM kelas ORDER BY nama ASC");
while ($r = mysqli_fetch_assoc($sql)) {
?>
                            <tr>
                                <td class="text-center"><?= $no++; ?></td>
                                <td class="text-center"><?= $r['nama']; ?></td>
                                <td class="text-center">
                                    <a href="media.php?module=input_kelas&act=edit&idk=<?= $r['idk']; ?>" class="btn btn-info btn-sm">
                                        <i class="fa fa-edit"></i> Edit
                                    </a>
                                    
                                    <a href="./module/simpan.php?act=hapus_kelas&idk=<?= $r['idk']; ?>" 
                                       class="btn btn-danger btn-sm" 
                                       onclick="return confirm('Yakin ingin menghapus kelas <?= $r['nama']; ?>?')">
                                        <i class="fa fa-trash"></i> Hapus
                                    </a>
                                </td>
                            </tr>
<?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>