162 lines
7.1 KiB
PHP
162 lines
7.1 KiB
PHP
<!-- Main content -->
|
|
<section class="content" style="zoom: 90%;">
|
|
<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">
|
|
<ol class="float-sm-right mb-0">
|
|
<a type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#staticBackdrop">Kirim Ulang</a>
|
|
</lo>
|
|
</div>
|
|
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="modal-header bg-primary">
|
|
<h5 class="modal-title" id="staticBackdropLabel">Kirim Ulang Pesan GAGAL Terakhir</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
|
|
<?php
|
|
// Query dengan PDO
|
|
$stmt = $pdo->prepare("SELECT apikey_whatsapp FROM data_server WHERE id = :id");
|
|
$stmt->execute(['id' => $SvId]);
|
|
$pakw = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
$sekarang = date('Y-m-d H:i:s');
|
|
?>
|
|
<div class="modal-body">
|
|
<div class="input-group mb-3">
|
|
<select class="form-control" name="jamtam" required>
|
|
<option value="1">1</option>
|
|
<option value="3">3</option>
|
|
<option value="6">6</option>
|
|
<option value="12">12</option>
|
|
<option value="24">24</option>
|
|
<option value="36">36</option>
|
|
</select>
|
|
<span class="input-group-text" id="basic-addon2">Jam Terakhir Pesan Yang GAGAL Terkirim</span>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
<input type="submit" name="kirimulang" class="btn btn-primary" value="Submit">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Proses kirim ulang
|
|
if (isset($_POST['kirimulang'])) {
|
|
try {
|
|
$jamtam = (int) $_POST['jamtam'];
|
|
$mulaiulang = date('Y-m-d H:i:s', strtotime("$sekarang -$jamtam hours"));
|
|
|
|
// Update pesan yang gagal
|
|
$updatePesan = $pdo->prepare("UPDATE master_pesan SET status = 'PENDING' WHERE status = 'GAGAL' AND api_key = :api_key AND waktu >= :mulaiulang");
|
|
$updatePesan->execute([
|
|
'api_key' => $pakw['apikey_whatsapp'],
|
|
'mulaiulang' => $mulaiulang
|
|
]);
|
|
|
|
// Hitung jumlah pesan yang diupdate
|
|
$jumlahPesan = $updatePesan->rowCount();
|
|
|
|
if ($jumlahPesan > 0) {
|
|
sweetAlert("$jumlahPesan pesan berhasil masuk antrian pengiriman ulang", "success");
|
|
} else {
|
|
sweetAlert("Tidak ada pesan GAGAL yang ditemukan dalam $jamtam jam terakhir", "warning");
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
sweetAlert("Error: " . $e->getMessage(), "error");
|
|
}
|
|
}
|
|
?>
|
|
<!-- END Modal Tambah -->
|
|
</div>
|
|
</div>
|
|
<!-- /.card-header -->
|
|
<div class="card-body">
|
|
<table id="example22" class="table table-bordered table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Waktu</th>
|
|
<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 LIMIT 500");
|
|
while ($paket = mysqli_fetch_assoc($apaket))
|
|
{
|
|
?>
|
|
<tr>
|
|
<td style="max-width: 200px;"><?php echo $paket['waktu']; ?></td>
|
|
<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 style="max-width: 300px;"><?php echo $paket['pesan']; ?></td>
|
|
<td style="max-width: 200px;"><?php echo $paket['url_file']; ?></td>
|
|
<td><?php echo $paket['status']; ?></td>
|
|
<td>
|
|
<?php if($paket['status'] == 'GAGAL' || $paket['status'] == 'TERKIRIM') { ?>
|
|
<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 -->
|
|
<script>
|
|
$(function () {
|
|
$("#example22").DataTable({
|
|
"responsive": true,
|
|
"autoWidth": false,
|
|
"pageLength": 100,
|
|
"order": [[0, "desc"]] // Kolom pertama urut DESC
|
|
});
|
|
});
|
|
</script>
|