86 lines
3.3 KiB
PHP
86 lines
3.3 KiB
PHP
<?php
|
|
include '../template/template1.php';
|
|
include '../template/header.php';
|
|
include '../template/sidebar.php';
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
<div class="pagetitle">
|
|
<h1>Daftar Transaksi</h1>
|
|
<nav>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="../index.php">Home</a></li>
|
|
<li class="breadcrumb-item active">Transaksi</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
|
|
<div class="card mt-2">
|
|
<div class="card-body">
|
|
<table class="table mt-3 datatable">
|
|
<thead>
|
|
<tr>
|
|
<th>No</th>
|
|
<th>ID Order</th>
|
|
<th>Nama</th>
|
|
<th>Total Harga</th>
|
|
<th>Status</th>
|
|
<th>Alamat</th>
|
|
<th>Tanggal</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$no = 1;
|
|
$result = mysqli_query($conn, "
|
|
SELECT orders.*, pembeli.nama_pembeli
|
|
FROM orders
|
|
JOIN pembeli ON orders.id_pembeli = pembeli.id_pembeli
|
|
WHERE orders.status_order NOT IN ('Selesai', 'Dibatalkan')
|
|
ORDER BY orders.tanggal_order DESC
|
|
");
|
|
while ($row = mysqli_fetch_assoc($result)) :
|
|
?>
|
|
<tr>
|
|
<td><?= $no++; ?></td>
|
|
<td><?= $row['id_order']; ?></td>
|
|
<td><?= substr($row['nama_pembeli'], 0, 10); ?><?= strlen($row['nama_pembeli']) > 20 ? '...' : '' ?></td>
|
|
<td>Rp <?= number_format($row['total_harga'], 0, ',', '.'); ?></td>
|
|
<td><?= substr($row['status_order'], 0, 10); ?><?= strlen($row['status_order']) > 15 ? '...' : '' ?></td>
|
|
<td><?= substr($row['alamat'], 0, 10); ?><?= strlen($row['alamat']) > 30 ? '...' : '' ?></td>
|
|
<td><?= date('d-m-Y', strtotime($row['tanggal_order'])); ?></td>
|
|
<td>
|
|
<a href="detail.php?id=<?= $row['id_order']; ?>" class="btn btn-info btn-sm">Detail</a>
|
|
<button class="btn btn-danger btn-sm" onclick="hapusOrder('<?= $row['id_order']; ?>')">Hapus</button>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php include '../template/footer.php'; ?>
|
|
<?php include '../template/template2.php'; ?>
|
|
|
|
<script>
|
|
function hapusOrder(id) {
|
|
Swal.fire({
|
|
title: 'Apakah Anda yakin?',
|
|
text: 'Transaksi ini akan dihapus secara permanen!',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#3085d6',
|
|
confirmButtonText: 'Ya, hapus!',
|
|
cancelButtonText: 'Batal'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = 'hapus.php?id=' + id;
|
|
}
|
|
});
|
|
}
|
|
</script>
|