<?php require 'ust.php'; ?>
<main id="main" class="main">
  <section class="section dashboard">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-body">
            <h5 class="card-title"> Duyuru Listesi Paneli </h5>
            <div class="table-responsive">
            <table class="table table-striped datatable">
              <thead>
                <tr>
                  <th scope="col"> Duyuru Kime Yapılmış </th>
                  <th scope="col"> Duyuru </th>
                  <th scope="col"> Duyuru Tarihi </th>
                  <th scope="col"> Sil </th>
                </tr>
              </thead>
              <tbody>
                <?php
                $getir = mysqli_query($db, "SELECT * FROM duyurular");
                while ($listele = mysqli_fetch_array($getir)) {
                 ?>
                <tr>
                  <td><?php echo $listele["duyuru_kime"] ?></td>
                  <td><?php echo $listele["duyuru"]; ?></td>
                  <td><?php echo $listele["duyuru_tarihi"]; ?></td>
                  <td><button onclick="duyurusil_<?php echo $listele["id"]; ?>()" type="button" class="btn btn-danger btnl-sm">Sil</button></td>
                </tr>
                <script>
                function duyurusil_<?php echo $listele["id"]; ?>() {
                    swal({
                  title: "Duyuruyu Silmek Üzeresiniz",
                  text: "Bu İşlem Geri Alınamaz Duyuru Silinir.",
                  icon: "warning",
                  buttons: true,
                  dangerMode: true,
                })
                .then((willDelete) => {
                  if (willDelete) {
                    swal("Duyuru Silindi.", {
                      icon: "success",
                    });
                    window.location.href = "postlar/get.php?duyurusil=<?php echo $listele['id'] ?>";
                  } else {
                    swal("İşlem İptal Edildi.");
                  }
                });
                	}
                </script>
              <?php } ?>
              </tbody>
            </table>
          </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>
<?php require 'footer.php'; ?>
