<?php
$ids = $_GET['ids'] ?? null;

if (!$ids) {
    echo "<div class='alert alert-danger'>ID siswa tidak ditemukan</div>";
    exit;
}

$sql = mysqli_query(
    $koneksi,
    "SELECT siswa.*, kelas.nama AS nama_kelas, sekolah.nama AS nama_sekolah
     FROM siswa
     JOIN kelas ON siswa.idk = kelas.idk
     JOIN sekolah ON kelas.id = sekolah.id
     WHERE siswa.ids = '$ids'"
);

$data = mysqli_fetch_assoc($sql);

if (!$data) {
    echo "<div class='alert alert-danger'>Data siswa tidak ditemukan</div>";
    exit;
}
?>

<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header"><strong>Detail Siswa</strong></h3>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-primary">

            <div class="panel-heading">
                Data Lengkap Siswa
            </div>

            <div class="panel-body">
                <table class="table table-bordered">
                    <tr>
                        <th width="30%">NIS</th>
                        <td><?= $data['nis']; ?></td>
                    </tr>
                    <tr>
                        <th>Nama</th>
                        <td><?= $data['nama']; ?></td>
                    </tr>
                    <tr>
                        <th>Jenis Kelamin</th>
                        <td><?= ($data['jk'] == "L") ? "Laki - Laki" : "Perempuan"; ?></td>
                    </tr>
                    <tr>
                        <th>Kelas</th>
                        <td><?= $data['nama_kelas']; ?></td>
                    </tr>
                    <tr>
                        <th>Sekolah</th>
                        <td><?= $data['nama_sekolah']; ?></td>
                    </tr>
                    <tr>
                        <th>No Telepon</th>
                        <td><?= $data['tlp']; ?></td>
                    </tr>
                </table>

                <a href="media.php?module=siswa" class="btn btn-primary">
                    Kembali
                </a>
            </div>

        </div>
    </div>
</div>
