<?php

require_once "../config/koneksi.php";

include "../includes/header.php";
include "../includes/navbar.php";

if (!isset($_GET['id'])) {
    header("Location: pengumuman.php");
    exit;
}

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

$query = mysqli_query(
    $koneksi,
    "SELECT * FROM pengumuman WHERE id='$id'"
);

if (mysqli_num_rows($query) == 0) {
    echo "<div class='container py-5'><div class='alert alert-danger'>Pengumuman tidak ditemukan.</div></div>";
    include "../includes/footer.php";
    exit;
}

$data = mysqli_fetch_assoc($query);

?>

<div class="container py-5">

    <div class="card shadow">

        <div class="card-header bg-primary text-white">

            <h3 class="mb-0">

                📢 Detail Pengumuman

            </h3>

        </div>

        <div class="card-body p-4">

            <span class="badge bg-primary mb-3">

                Pengumuman

            </span>

            <h2>

                <?= htmlspecialchars($data['judul']); ?>

            </h2>

            <p class="text-muted">

                <?= date('d F Y', strtotime($data['tanggal'])); ?>

            </p>

            <hr>

            <p style="text-align:justify; line-height:1.8;">

                <?= nl2br(htmlspecialchars($data['isi'])); ?>

            </p>

            <a href="pengumuman.php" class="btn btn-primary mt-3">

                ← Kembali ke Pengumuman

            </a>

        </div>

    </div>

</div>

<?php

include "../includes/footer.php";

?>