<?php
include "../../config/koneksi.php";
include "../../templates/header.php";
include "../../templates/navbar.php";
include "../../templates/sidebar.php";
?>

<div class="content-wrapper">

    <section class="content-header">

        <div class="container-fluid">

            <div class="row mb-2">

                <div class="col-sm-6">
                    <h1>Data Kelas</h1>
                </div>

                <div class="col-sm-6 text-right">

                    <a href="tambah.php" class="btn btn-primary">

                        <i class="fas fa-plus"></i>

                        Tambah Kelas

                    </a>

                </div>

            </div>

        </div>

    </section>

    <section class="content">

        <div class="container-fluid">

            <div class="card">

                <div class="card-header">

                    <h3 class="card-title">

                        Daftar Kelas

                    </h3>

                </div>

                <div class="card-body">

                    <table class="table table-bordered table-hover">

                        <thead>

                        <tr>

                            <th width="60">No</th>

                            <th>Nama Kelas</th>

                            <th>Wali Kelas</th>

                            <th width="120">Status</th>

                            <th width="150">Aksi</th>

                        </tr>

                        </thead>

                        <tbody>

                        <?php

                        $no=1;

                        $kelas=mysqli_query($conn,"SELECT * FROM kelas ORDER BY nama_kelas ASC");

                        while($row=mysqli_fetch_assoc($kelas)){

                        ?>

                        <tr>

                            <td><?= $no++; ?></td>

                            <td><?= htmlspecialchars($row['nama_kelas']); ?></td>

                            <td><?= htmlspecialchars($row['wali_kelas']); ?></td>

                            <td>

                                <?php

                                if($row['status']=="Aktif"){

                                    echo '<span class="badge badge-success">Aktif</span>';

                                }else{

                                    echo '<span class="badge badge-danger">Nonaktif</span>';

                                }

                                ?>

                            </td>

                            <td>

                                <a href="edit.php?id=<?= $row['id_kelas']; ?>"

                                   class="btn btn-warning btn-sm">

                                    <i class="fas fa-edit"></i>

                                </a>

                                <a href="hapus.php?id=<?= $row['id_kelas']; ?>"

                                   class="btn btn-danger btn-sm"

                                   onclick="return confirm('Yakin ingin menghapus kelas ini?')">

                                    <i class="fas fa-trash"></i>

                                </a>

                            </td>

                        </tr>

                        <?php } ?>

                        </tbody>

                    </table>

                </div>

            </div>

        </div>

    </section>

</div>

<?php
include "../../templates/footer.php";
?>