<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Detail Pengaduan</title>

  <!-- Custom fonts for this template-->
  <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Nunito:300,400,700,900" rel="stylesheet">

  <!-- Custom styles for this template-->
  <link href="css/sb-admin-2.min.css" rel="stylesheet">
</head>

<body id="page-top">
  <div class="container mt-4">
    <div class="card shadow">
      <div class="card-header">
        <strong>DETAIL PENGADUAN</strong>
      </div>
      <div class="card-body">

        <a href="?url=lihat_pengaduan" class="btn btn-primary btn-sm mb-3">
          <i class="fas fa-arrow-left"></i> Kembali
        </a>

        <?php
        require 'koneksi.php';

        if (isset($_GET['id'])) {
            $id = intval($_GET['id']); // hindari SQL Injection
            $stmt = $conn->prepare("SELECT * FROM pengaduan WHERE id_pengaduan = ?");
            $stmt->bind_param("i", $id);
            $stmt->execute();
            $result = $stmt->get_result();
            if ($data = $result->fetch_assoc()) {
        ?>
          <div class="form-group">
            <label>Tanggal Pengaduan</label>
            <input type="text" class="form-control" value="<?= htmlspecialchars($data['tgl_pengaduan']) ?>" readonly>
          </div>

          <div class="form-group">
            <label>Isi Laporan</label>
            <textarea class="form-control" rows="6" readonly><?= htmlspecialchars($data['isi_laporan']) ?></textarea>
          </div>

          <div class="form-group">
            <label>Bukti Foto</label><br>
            <?php if (!empty($data['foto'])): ?>
              <img src="foto/<?= htmlspecialchars($data['foto']) ?>" class="img-fluid img-thumbnail" width="600">
            <?php else: ?>
              <p class="text-muted">Tidak ada foto dilampirkan.</p>
            <?php endif; ?>
          </div>
        <?php
            } else {
                echo "<div class='alert alert-danger'>Data tidak ditemukan.</div>";
            }
            $stmt->close();
        } else {
            echo "<div class='alert alert-warning'>ID pengaduan tidak valid.</div>";
        }
        ?>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
  <script src="js/sb-admin-2.min.js"></script>

</body>
</html>
