<!-- Main content -->
<section class="content" style="zoom: 80%;">
  <div class="container-fluid">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-header">
            <div class="row">
              <div class="col-sm-6">
                <h3 class="card-title">Log Pesan</h3>
              </div>
              <div class="col-sm-6">
              </div>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <table id="example2" class="table table-bordered table-striped">
              <thead>
              <tr>
                <th>Nama Server</th>
                <th>Nomor</th>
                <th>Pesan</th>
                <th>Url Image</th>
                <th>Status</th>
                <th>Action</th>
              </tr>
              </thead>
              <tbody>
              <?php
                $apaket = mysqli_query($con, "SELECT * FROM master_pesan $SqlDataWHId ORDER BY waktu DESC, id DESC LIMIT 500");
                while ($paket = mysqli_fetch_assoc($apaket)) 
                { 
              ?>
              <tr>
                <td>
                  <?php
                    $asv = mysqli_query($con,"SELECT nama_server FROM data_server WHERE id = '$paket[id_data_server]'");
                    $sv = mysqli_fetch_assoc($asv);
                      echo $sv['nama_server']; 
                  ?>
                </td>
                <td><?php echo $paket['nomor']; ?></td>
                <td><?php echo $paket['pesan']; ?></td>
                <td><?php echo $paket['url_file']; ?></td>
                <td><?php echo $paket['status']; ?></td>
                <td>
                  <?php if($paket['status'] == 'GAGAL') { ?>
                  <form method="post">
                      <input type="submit" name="ulangi<?php echo $paket['id']; ?>" class="btn btn-primary btn-sm" value="Ulangi">
                  </a>
                  </form>
                  <?php } 
                  if(isset($_POST['ulangi'.$paket['id']])){
                    $up = mysqli_query($con,"UPDATE master_pesan SET status = 'PENDING' WHERE id = '$paket[id]'");
                    if($up){
                        sweetAlert("Pesan ke Nomor ".$paket['nomor']." Akan Segera Di Kirim", "success");
                    }
                  }
                  ?>
                </td>
              </tr>
            <?php } ?>
              </tbody>
            </table>
          </div>
          <!-- /.card-body -->
        </div>
        <!-- /.card -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </div>
  <!-- /.container-fluid -->
</section>
<!-- /.content -->