<?php require admin_view('include/iheader'); ?>
<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-6">
          <h1>İstek Paneli</h1>
        </div>
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="#">Genel Ayarlar</a></li>
            <li class="breadcrumb-item active">İstek Paneli</li>
          </ol>
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section> 
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <!-- Info boxes -->
      <div class="row">
        <div class="col-12 col-sm-6 col-md-3">
          <div class="info-box">
            <span class="info-box-icon bg-info elevation-1"><i class="fas fa-volume-up"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Çalan Parça:</span>
              <span class="info-box-number">
                <marquee direction=left>
                  <div id="song"></div>
                </marquee>

              </span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-12 col-sm-6 col-md-3">
          <div class="info-box mb-3">
            <span class="info-box-icon bg-danger elevation-1"><i class="fas fa-thumbs-up"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Dinleyici Zirvesi</span>
              <span class="info-box-number"><?php echo $peak; ?></span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>
        <!-- /.col -->

        <!-- fix for small devices only -->
        <div class="clearfix hidden-md-up"></div>

        <div class="col-12 col-sm-6 col-md-3">
          <div class="info-box mb-3">
            <span class="info-box-icon bg-success elevation-1"><i class="fas fa-sitemap"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Yayın Kalitesi</span>
              <span class="info-box-number"><?php echo $bit; ?> kbps</span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-12 col-sm-6 col-md-3">
          <div class="info-box mb-3">
            <span class="info-box-icon bg-warning elevation-1"><i class="fas fa-users"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Online Dinleyici</span>
              <span class="info-box-number"><?php echo $current; ?></span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
  </section>
    <!-- Main content -->
    <section class="content">
   <form action="" method="POST">
     <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">Gelen İstekler</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>İstek Parça</th>
               <th>ip Adresi</th>
               <th>Ülke</th>
               <th>Şehir</th>
               <th>Tellcom</th>
               <th>Tarih</th>
               <th>İşlemler</th> 
             </tr>
           </thead> 
           <tbody>
            <?php while($row=$query->fetch(PDO::FETCH_ASSOC)) { ?> 
                <?php if ( $query ){ $konum = @unserialize(file_get_contents('http://ip-api.com/php/'.$row["ip"])); ?>
                
                <tr <?php if ($row['durum']==0) { ?>class="bg-danger"<?php } ?>>
                  <td align="center">
                    <input type="checkbox" class="minimal" name="deleteistek[]" value="<?= $row['id'] ?>"></td> 
                    <td><?= $row['isim']. " ". $row['soyad']; ?></td>
                    <td><?= $row['istekparca'] ?></td> 
                    <td><kbd><?= $row['ip'] ?></kbd></td>
                    <td><?= $konum && $konum['status']=='success' ? $konum['country'] :'Bilinmiyor'?></td> 
                    <td><?= $konum && $konum['status']=='success' ? $konum['city'] :'Bilinmiyor'?></td> 
                    <td><?= $konum && $konum['status']=='success' ? $konum['isp'] :'Bilinmiyor'?></td>
                    <td><?= $row['save_date'] ?></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> İstek 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">İstek Gönderen: <?= $row['isim']." ".$row['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 -->
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php require admin_view('include/footer'); ?>