TIF_NGANJUK_E41212020/admin/laporan/mingguan/index.php

71 lines
2.5 KiB
PHP

<?php
include '../../template/template1.php';
include '../../template/header.php';
include '../../template/sidebar.php';
// Mendapatkan tanggal satu minggu terakhir
$tanggal_awal = date('Y-m-d', strtotime('-7 days'));
$tanggal_akhir = date('Y-m-d');
// Query untuk mengambil data transaksi dalam satu minggu terakhir
$query = "SELECT id_order, id_pembeli, metode_pembayaran, total_harga, status_order, alamat, tanggal_order FROM orders WHERE tanggal_order BETWEEN ? AND ? ORDER BY tanggal_order DESC";
$stmt = $conn->prepare($query);
$stmt->bind_param("ss", $tanggal_awal, $tanggal_akhir);
$stmt->execute();
$result = $stmt->get_result();
?>
<main id="main" class="main">
<div class="pagetitle">
<h1>Laporan Mingguan</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="../index.php">Home</a></li>
<li class="breadcrumb-item active">Laporan Mingguan</li>
</ol>
</nav>
</div>
<div class="card mt-2">
<div class="card-body">
<h5 class="card-title">Data Transaksi Mingguan (<?php echo $tanggal_awal . " - " . $tanggal_akhir; ?>)</h5>
<table class="table">
<thead>
<tr>
<th>No</th>
<th>ID Order</th>
<th>ID Pembeli</th>
<th>Metode Pembayaran</th>
<th>Total Harga</th>
<th>Status Order</th>
<th>Alamat</th>
<th>Tanggal Order</th>
</tr>
</thead>
<tbody>
<?php $no = 1; while ($row = $result->fetch_assoc()) { ?>
<tr>
<td><?= $no++; ?></td>
<td><?= $row['id_order']; ?></td>
<td><?= $row['id_pembeli']; ?></td>
<td><?= $row['metode_pembayaran']; ?></td>
<td>Rp <?= number_format($row['total_harga'], 0, ',', '.'); ?></td>
<td><?= $row['status_order']; ?></td>
<td><?= $row['alamat']; ?></td>
<td><?= $row['tanggal_order']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</main>
<?php
$stmt->close();
$conn->close();
include '../../template/footer.php';
include '../../template/template2.php';
?>