<!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>Data Tanggapan</title>

  <!-- Fonts & Styles -->
  <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,300,400,600,700,800,900" rel="stylesheet">
  <link href="../css/sb-admin-2.min.css" rel="stylesheet">
  <link href="../vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
</head>

<body id="page-top">

  <div class="container-fluid mt-4">
    <!-- DataTales -->
    <div class="card shadow mb-4">
      <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary">Data Tanggapan</h6>
      </div>
      <div class="card-body">
        <div class="table-responsive">
          <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
            <thead class="thead-light">
              <tr>
                <th>ID Tanggapan</th>
                <th>ID Pengaduan</th>
                <th>Tanggal Tanggapan</th>
                <th>Tanggapan</th>
                <th>ID Petugas</th>
                <th>Aksi</th>
              </tr>
            </thead>
            <tbody>
              <?php
              require '../koneksi.php';
              $conn = mysqli_connect("localhost", "root", "", "appem");
              if (!$conn) {
                die("Koneksi gagal: " . mysqli_connect_error());
              }

              $sql = "SELECT * FROM tanggapan";
              $result = mysqli_query($conn, $sql);
              while ($data = mysqli_fetch_assoc($result)) {
              ?>
                <tr>
                  <td><?php echo htmlspecialchars($data['id_tanggapan']); ?></td>
                  <td><?php echo htmlspecialchars($data['id_pengaduan']); ?></td>
                  <td><?php echo htmlspecialchars($data['tgl_tanggapan']); ?></td>
                  <td><?php echo htmlspecialchars($data['tanggapan']); ?></td>
                  <td><?php echo htmlspecialchars($data['id_petugas']); ?></td>
                  <td>
                    <a href="edit_tanggapan.php?id=<?php echo $data['id_tanggapan']; ?>" class="btn btn-primary btn-circle">
                      <i class="fa fa-edit"></i>
                    </a>
                    <a href="delete_tanggapan.php?id=<?php echo $data['id_tanggapan']; ?>" class="btn btn-danger btn-circle" onclick="return confirm('Yakin ingin menghapus data ini?')">
                      <i class="fa fa-trash"></i>
                    </a>
                  </td>
                </tr>
              <?php } ?>
              <?php mysqli_close($conn); ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>

  <!-- Footer -->
  <footer class="sticky-footer bg-white">
    <div class="container my-auto text-center">
      <span>&copy; APPEM <?php echo date('Y'); ?></span>
    </div>
  </footer>

  <!-- Scroll to Top -->
  <a class="scroll-to-top rounded" href="#page-top"><i class="fas fa-angle-up"></i></a>

  <!-- Logout Modal -->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal"><span>&times;</span></button>
        </div>
        <div class="modal-body">Pilih "Logout" jika Anda ingin keluar dari sistem.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="login.html">Logout</a>
        </div>
      </div>
    </div>
  </div>

  <!-- 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>
  <script src="../vendor/datatables/jquery.dataTables.min.js"></script>
  <script src="../vendor/datatables/dataTables.bootstrap4.min.js"></script>
  <script src="../js/demo/datatables-demo.js"></script>

</body>
</html>
