Files
manjapro_v6/pages/order_list.php
T
2026-10-01 14:24:41 +07:00

262 lines
8.6 KiB
PHP

<!-- Main content -->
<section class="content" style="zoom : 85%;">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-6">
<h3 class="card-title">List Order</h3>
</div>
<div class="col-6">
<ol class="float-sm-right mb-0">
<?php
if(in_array("Tambah", $json_array[18]['sub_menu'])){ ?>
<a href="?<?php echo encrypt_url('order_list_tambah'); ?>" type="button" class="btn btn-danger btn-sm">Tambah</a>
<?php } ?>
</ol>
</div>
</div>
</div>
<!-- /.card-header -->
<div class="card-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>No</th>
<th>Order Time</th>
<th>Nama</th>
<th>Alamat</th>
<th>Desa</th>
<th>Koordinat</th>
<th>Nomor WhatsApp</th>
<th>Server</th>
<th>Paket</th>
<th>Dibuat Oleh</th>
<th>Status</th>
<th>Catatan</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$aserver = mysqli_query($con,"SELECT * FROM v_order_list WHERE $SqlSvData status = 'order' ORDER BY time_start ASC, status_proses ASC");
while ($server = mysqli_fetch_assoc($aserver))
{
if ($server['status_proses'] == 'handling') {
$borderColor = '#dc3545'; // Bootstrap danger
$color = 'danger';
} elseif ($server['status_proses'] == 'request') {
$borderColor = '#ffc107'; // Bootstrap warning
$color = 'warning';
} elseif ($server['status_proses'] == 'ready') {
$borderColor = '#198754'; // Bootstrap success
$color = 'success';
} else {
$borderColor = '#0dcaf0'; // Bootstrap info
$color = 'info';
}
?>
<tr>
<td style="max-width: 20px; border-left: 8px solid <?php echo $borderColor; ?>;"><?php echo $no; ?></td>
<td class="align-middle" style="max-width: 100px;">
<?php echo $server['time_start']; ?>
</td>
<td><?php echo $server['nama']; ?></td>
<td style="max-width: 200px;"><?php echo $server['alamat']; ?></td>
<td><?php echo $server['nama_desa']; ?></td>
<td style="max-width: 200px;"><a href="https://www.google.com/maps/search/?api=1&query=<?php echo $server['latitude'].','.$server['longitude']; ?>" target="_blank"><?php echo $server['latitude'].', '.$server['longitude']; ?></a></td>
<td><?php echo $server['nomor_whatsapp']; ?> <a href="https://wa.me/<?php echo $server['nomor_whatsapp']; ?>" target="_blank" style="border-radius: 20px; " class="btn btn-sm btn-success">Chat</a></td>
<td><?php echo $server['nama_server']; ?></td>
<td><?php echo $server['nama_paket']; ?></td>
<td><?php echo $server['create_with']; ?></td>
<td>
<span class="badge bg-<?php echo $color; ?> p-2">
<?php echo ucfirst($server['status_proses']); ?>
</span>
</td>
<td style="max-width: 200px;"><?php echo $server['catatan']; ?></td>
<td>
<form method="post">
<?php if(in_array("Survey", $json_array[18]['sub_menu'])){ ?>
<a href="?<?php echo encrypt_url('order_list_update|'.$server['id']); ?>" type="button" class="btn btn-primary btn-sm m-1">Proses Order</a>
<?php } if(in_array("Ubah", $json_array[18]['sub_menu'])){ ?>
<a href="?<?php echo encrypt_url('order_list_ubah|'.$server['id']); ?>" type="button" class="btn btn-secondary btn-sm m-1">Edit</a>
<?php } if(in_array("Hapus", $json_array[18]['sub_menu'])){ ?>
<input type="submit" name="hapus<?php echo $server['id'];?>" value="Hapus" class="btn btn-danger btn-sm ml-1" />
<?php } ?>
</form>
<button type="button"
class="btn btn-warning btn-sm m-1 btnUpdateStatus"
data-id="<?php echo $server['id']; ?>"
data-status="<?php echo $server['status_proses']; ?>">
Update Status
</button>
</td>
</tr>
<?php
if (isset($_POST['hapus'.$server['id']]))
{
$iddata = $server['id'];
deleteAlert("order_list",$iddata );
}
$no++;
} ?>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
<!-- Modal Update Status -->
<div class="modal fade" id="modalUpdateStatus" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
<form method="post">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Update Status Proses</h5>
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<input type="hidden"
name="id_order"
id="id_order">
<div class="form-group">
<label>Status Proses</label>
<select name="status_proses"
id="status_proses"
class="form-control"
required>
<option value="">-- Pilih Status --</option>
<option value="ready">
Siap Pasang
</option>
<option value="handling">
Perlu Penanganan
</option>
<option value="pending">
Pending
</option>
<option value="request">
Request Pelanggan
</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-secondary"
data-dismiss="modal">
Batal
</button>
<button type="submit"
name="update_status_proses"
class="btn btn-primary">
Simpan Status
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>
<!-- /.content -->
<script>
$(document).on('click', '.btnUpdateStatus', function () {
var id = $(this).data('id');
var status = $(this).data('status');
$('#id_order').val(id);
$('#status_proses').val(status);
$('#modalUpdateStatus').modal('show');
});
</script>
<?php
if (isset($_POST['update_status_proses'])) {
$id_order = mysqli_real_escape_string(
$con,
$_POST['id_order']
);
$status_proses = mysqli_real_escape_string(
$con,
$_POST['status_proses']
);
$allowed_status = [
'ready',
'handling',
'pending',
'request'
];
if (in_array($status_proses, $allowed_status)) {
mysqli_query(
$con,
"UPDATE order_list
SET status_proses = '$status_proses'
WHERE id = '$id_order'"
);
echo "
<script>
window.location.href = window.location.href;
</script>
";
}
}
?>