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

$id = intval($_GET['id']);

$query = mysqli_query($conn, "SELECT * FROM kelas WHERE id_kelas='$id'");
$data  = mysqli_fetch_assoc($query);

if(!$data){
    echo "<script>
    alert('Data tidak ditemukan');
    window.location='index.php';
    </script>";
    exit;
}
?>

<div class="content-wrapper">

<section class="content-header">
<div class="container-fluid">

<div class="row mb-2">

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

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

<a href="index.php" class="btn btn-secondary">

<i class="fas fa-arrow-left"></i>

Kembali

</a>

</div>

</div>

</div>
</section>

<section class="content">

<div class="container-fluid">

<div class="card">

<div class="card-header">

<h3 class="card-title">

Form Edit Data Kelas

</h3>

</div>

<form action="update.php" method="POST">

<div class="card-body">

<input type="hidden"
name="id_kelas"
value="<?= $data['id_kelas']; ?>">

<div class="form-group">

<label>Nama Kelas</label>

<input
type="text"
name="nama_kelas"
class="form-control"
value="<?= htmlspecialchars($data['nama_kelas']); ?>"
required>

</div>

<div class="form-group">

<label>Wali Kelas</label>

<input
type="text"
name="wali_kelas"
class="form-control"
value="<?= htmlspecialchars($data['wali_kelas']); ?>">

</div>

<div class="form-group">

<label>Status</label>

<select
name="status"
class="form-control">

<option value="Aktif"
<?= $data['status']=="Aktif" ? "selected" : ""; ?>>
Aktif
</option>

<option value="Nonaktif"
<?= $data['status']=="Nonaktif" ? "selected" : ""; ?>>
Nonaktif
</option>

</select>

</div>

</div>

<div class="card-footer">

<button
type="submit"
class="btn btn-primary">

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

Update

</button>

<a
href="index.php"
class="btn btn-secondary">

Batal

</a>

</div>

</form>

</div>

</div>

</section>

</div>

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