<?php
session_start();
?>
<!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>Cetak Data Masyarakat</title>

  <!-- Fonts & CSS -->
  <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" onload="window.print();">

  <div class="container mt-4">
    <div class="text-center">
      <h3 class="font-weight-bold text-primary">PEMERINTAH KABUPATEN BOGOR</h3>
      <h4 class="font-weight-bold text-primary">DESA BOJONGGEDE KEC. BOJONGGEDE</h4>
      <h6 class="font-weight-bold text-primary">JL. Raya Bojong Gede Kode Pos. 17057</h6>
      <hr>
      <h5 class="font-weight-bold text-primary">LAPORAN MASYARAKAT</h5>
    </div>
    <br>

    <div class="table-responsive">
      <table class="table table-bordered">
        <thead class="thead-light">
          <tr>
            <th>NIK</th>
            <th>Nama Warga</th>
            <th>Username</th>
            <th>Password</th>
            <th>Telp</th>
          </tr>
        </thead>
        <tbody>
          <?php
          require '../koneksi.php';
          $conn = mysqli_connect("localhost", "root", "", "appem");

          if (!$conn) {
            die("Koneksi gagal: " . mysqli_connect_error());
          }

          $query = "SELECT * FROM masyarakat";
          $result = mysqli_query($conn, $query);
          while ($data = mysqli_fetch_assoc($result)) {
            echo "<tr>";
            echo "<td>" . htmlspecialchars($data['nik']) . "</td>";
            echo "<td>" . htmlspecialchars($data['nama']) . "</td>";
            echo "<td>" . htmlspecialchars($data['username']) . "</td>";
            echo "<td>" . htmlspecialchars($data['password']) . "</td>";
            echo "<td>" . htmlspecialchars($data['telp']) . "</td>";
            echo "</tr>";
          }

          mysqli_close($conn);
          ?>
        </tbody>
      </table>
    </div>

    <br><br>
    <div class="text-right">
      <h6 class="font-weight-bold text-primary">Bojong Gede, <?php echo date('d-m-Y'); ?></h6>
      <h6 class="font-weight-bold text-primary">Petugas,</h6>
      <br><br><br>
      <h6 class="font-weight-bold text-primary">
        <?php echo isset($_SESSION['nama']) ? htmlspecialchars($_SESSION['nama']) : '__________'; ?>
      </h6>
    </div>
  </div>

  <!-- JS Scripts -->
  <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>
