<?php require admin_view('include/header'); ?>
<!-- DataTables -->
<link rel="stylesheet" href="<?= admin_public_url(); ?>plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="<?= admin_public_url(); ?>plugins/datatables-responsive/css/responsive.bootstrap4.min.css">


<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">

        <div class="col-sm-12">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="index">Görsel Panel</a></li> 
            <li class="breadcrumb-item active">İletişim</li>
          </ol>
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">
    <form action="" method="post" enctype="multipart/form-data">
     <div class="col-sm-12"> 
      <button type="submit" class="btn btn-danger" onclick="return confirm('Bu işlemi gerçekten yapmak istiyor musunuz?')"><i class="fa fa-trash"></i> Seçilenleri Sil</button>
    </div>
    <br> 
    <!-- Default box -->
    <div class="card">
      <div class="card-header">
        <h3 class="card-title">İletişim Mesajları</h3>
      </div>
      <!-- /.card-header -->
      <div class="card-body">
        <table id="example1" class="table table-bordered table-striped">
          <thead>
            <tr>
             <th id="checkbox-toggle" width="1%">Seç</th> 
             <th>Adı Soyadı</th>
             <th>Konu</th> 
             <th>Telefon</th> 
             <th>E-Mail</th>
             <th>İşlemler</th>
           </tr>
         </thead> 
         <tbody>
           <?php 
           while($row=$query->fetch(PDO::FETCH_ASSOC)) { ?>
            <tr <?php if ($row['durum']== 0) { ?>class="bg-danger"<?php } ?>> 
             <td align="center"><input type="checkbox" class="minimal" name="deleteiletisim[]" value="<?= $row['id'] ?>"></td> 
             <td><?= $row['isim_soyad'] ?></td>
             <td><?= $row['konu'] ?></td>
             <td><?= $row['telefon'] ?></td>
             <td><?= $row['email'] ?></td> 
             <td align="center"> 
              <button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal-xl<?= $row['id'] ?>">
               <i class="fa fa-eye"></i> Mesajı Oku...
             </button>
           </td>
         </tr>  

         <div class="modal fade" id="modal-xl<?= $row['id'] ?>">
          <div class="modal-dialog modal-xl">
            <div class="modal-content">
              <div class="modal-header">
                <h4 class="modal-title">Mesaj Gönderen: <?= $row['isim_soyad'] ?></h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                <p>Mesajı: <?= $row['message'] ?>&hellip;</p>
                Gönderim Tarihi: <?= tarih('j F Y - H:i:s',$row['save_date']); ?>
              </div>
              <?php if ($row['durum']==0) { ?>
                <div class="modal-footer justify-content-between">
                  <button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button> 
                  <input type="hidden" name="id" value="<?= $row['id'] ?>">
                  <button type="submit" name="read" class="btn btn-primary">Okundu.</button>
                </div>
              <?php } ?>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
      <?php } ?>
    </tbody>

  </table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</form>
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php require admin_view('include/footer'); ?>