| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/thelittlebigshow/self-hosted/ |
Upload File : |
<?php
include 'protect.php';
include 'db.php';
require_once __DIR__ . '/brand_header.php';
$item = $_GET['item'] ?? '';
$month = $_GET['month'] ?? date('Y-m');
if (!$item) {
echo "Item not specified.";
exit;
}
$stmt = $conn->prepare("
SELECT c.first_name, c.last_name, SUM(t.quantity) AS total_quantity
FROM transactions t
JOIN customers c ON t.customer_id = c.id
WHERE t.item_name = ? AND DATE_FORMAT(t.date, '%Y-%m') = ?
GROUP BY c.id, c.first_name, c.last_name
ORDER BY c.last_name, c.first_name
");
$stmt->bind_param("ss", $item, $month);
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Customers Who Purchased <?= htmlspecialchars($item) ?></title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f4f4f4;
padding: 30px;
color: #333;
}
.container {
max-width: 800px;
margin: auto;
background: #fff;
padding: 25px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
h2 {
text-align: center;
margin-top: 0;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
padding: 10px;
border: 1px solid #ddd;
text-align: left;
}
th {
background-color: #f0f0f0;
}
.back-link {
display: inline-block;
margin-top: 20px;
text-decoration: none;
color: #2196F3;
}
</style>
<?php echo appBrandStyles(); ?>
</head>
<body>
<div class="container">
<?php renderAppBrandHeader(); ?>
<h2>Customers who purchased <?= htmlspecialchars($item) ?> in <?= date('F Y', strtotime($month . '-01')) ?></h2>
<table>
<tr>
<th>Customer</th>
<th>Total Quantity</th>
</tr>
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($row['last_name'] . ', ' . $row['first_name']) ?></td>
<td><?= number_format($row['total_quantity'], 2) ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr><td colspan="2"><em>No purchases found for this item in the selected month.</em></td></tr>
<?php endif; ?>
</table>
<a class="back-link" href="stats.php?month=<?= $month ?>">← Back to Stats</a>
</div>
</body>
</html>