| 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'; ?>
<?php
include 'db.php';
require_once __DIR__ . '/brand_header.php';
// Get selected month from query string or default to current month
$selected_month = $_GET['month'] ?? date('Y-m');
// Build list of past 24 months
$months = [];
for ($i = 0; $i < 24; $i++) {
$months[] = date('Y-m', strtotime("-$i months"));
}
// Query sales summary for selected month
$stmt = $conn->prepare("
SELECT item_name, SUM(quantity) AS total_sold
FROM transactions
WHERE DATE_FORMAT(date, '%Y-%m') = ?
GROUP BY item_name
ORDER BY total_sold DESC
");
$stmt->bind_param("s", $selected_month);
$stmt->execute();
$result = $stmt->get_result();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Item Sales Stats - <?= htmlspecialchars($selected_month) ?></title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f4f4f4;
padding: 30px;
color: #333;
}
.container {
max-width: 900px;
margin: auto;
background: #fff;
padding: 30px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
h2 {
text-align: center;
margin-top: 0;
}
.month-links {
text-align: center;
margin-bottom: 20px;
}
.month-links a {
margin: 5px;
display: inline-block;
padding: 6px 10px;
background-color: #eee;
color: #333;
text-decoration: none;
border-radius: 4px;
}
.month-links a:hover {
background-color: #ddd;
}
.month-links .active {
background-color: #2196F3;
color: white;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 25px;
}
th, td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
th {
background-color: #f0f0f0;
}
.back-link {
display: inline-block;
margin-top: 20px;
text-decoration: none;
color: #2196F3;
}
a.item-link {
color: #337ab7;
text-decoration: none;
}
a.item-link:hover {
text-decoration: underline;
}
</style>
<?php echo appBrandStyles(); ?>
</head>
<body>
<div class="container">
<?php renderAppBrandHeader(); ?>
<h2>Item Sales Summary for <?= date('F Y', strtotime($selected_month . '-01')) ?></h2>
<div class="month-links">
<?php foreach ($months as $m): ?>
<a href="?month=<?= $m ?>" class="<?= ($m === $selected_month) ? 'active' : '' ?>">
<?= date('M Y', strtotime($m . '-01')) ?>
</a>
<?php endforeach; ?>
</div>
<table>
<tr>
<th>Item Name</th>
<th>Total Quantity Sold</th>
</tr>
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td>
<a class="item-link" href="item_customers.php?item=<?= urlencode($row['item_name']) ?>&month=<?= urlencode($selected_month) ?>">
<?= htmlspecialchars($row['item_name']) ?>
</a>
</td>
<td><?= number_format($row['total_sold'], 2) ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr><td colspan="2"><em>No sales recorded this month.</em></td></tr>
<?php endif; ?>
</table>
<a class="back-link" href="index.php">← Back to Dashboard</a>
</div>
</body>
</html>