83 lines
3.6 KiB
PHP
83 lines
3.6 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
|
|
header("Location: ../login.php");
|
|
exit();
|
|
}
|
|
|
|
require_once '../db/config.php';
|
|
|
|
$pdo = db();
|
|
|
|
// Fetch sales with user and car details
|
|
$bookings = $pdo->query("
|
|
SELECT b.*, u.username, c.make, c.model, c.year
|
|
FROM bookings b
|
|
JOIN users u ON b.user_id = u.id
|
|
JOIN cars c ON b.car_id = c.id
|
|
ORDER BY b.booking_date DESC
|
|
")->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$projectName = 'Sales History';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title><?= htmlspecialchars($projectName) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="../assets/css/custom.css?v=<?= time() ?>">
|
|
</head>
|
|
<body>
|
|
<div class="admin-wrapper">
|
|
<?php include 'partials/sidebar.php'; ?>
|
|
<main class="admin-main-content">
|
|
<h1 class="h2 mb-4">Sales History</h1>
|
|
|
|
<div class="card border-0 shadow-sm">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Customer</th>
|
|
<th>Car Details</th>
|
|
<th>Price</th>
|
|
<th>Bank Details</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($bookings)): ?>
|
|
<tr><td colspan="6" class="text-center">No sales records found.</td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($bookings as $sale): ?>
|
|
<tr>
|
|
<td><?= date("M d, Y", strtotime($sale['booking_date'])) ?></td>
|
|
<td>
|
|
<div class="fw-bold"><?= htmlspecialchars($sale['username']) ?></div>
|
|
</td>
|
|
<td><?= htmlspecialchars($sale['year'] . ' ' . $sale['make'] . ' ' . $sale['model']) ?></td>
|
|
<td class="fw-bold text-success">$<?= number_format($sale['sale_price'] ?? 0, 2) ?></td>
|
|
<td>
|
|
<small class="d-block text-muted">Prov: <?= htmlspecialchars($sale['bank_province'] ?? 'N/A') ?></small>
|
|
<small class="d-block text-muted">Acc: <?= htmlspecialchars($sale['bank_account_number'] ?? 'N/A') ?></small>
|
|
</td>
|
|
<td>
|
|
<span class="badge rounded-pill bg-success">SOLD</span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|