Fix expiring section: show soonest 10 items instead of 7-day window
- Change query from 7-day threshold to soonest 10 items with expiry - Section now always visible when items have expiry dates - Improved badges: OGGI, Domani, N giorni, Ng, ~N mesi - Color coding: red (today), orange (≤7d), yellow (≤30d), grey (>30d) - Renamed section to 'Prossime Scadenze'
This commit is contained in:
+3
-2
@@ -509,12 +509,13 @@ function getStats(PDO $db): void {
|
||||
$recentIn = $db->query("SELECT COUNT(*) FROM transactions WHERE type='in' AND created_at >= datetime('now', '-7 days')")->fetchColumn();
|
||||
$recentOut = $db->query("SELECT COUNT(*) FROM transactions WHERE type='out' AND created_at >= datetime('now', '-7 days')")->fetchColumn();
|
||||
|
||||
// Expiring soon (next 7 days)
|
||||
// Expiring soonest (next items to expire, up to 10)
|
||||
$expiring = $db->query("
|
||||
SELECT i.*, p.name, p.brand
|
||||
FROM inventory i JOIN products p ON i.product_id = p.id
|
||||
WHERE i.expiry_date IS NOT NULL AND i.expiry_date <= date('now', '+7 days') AND i.expiry_date >= date('now')
|
||||
WHERE i.expiry_date IS NOT NULL AND i.expiry_date >= date('now') AND i.quantity > 0
|
||||
ORDER BY i.expiry_date ASC
|
||||
LIMIT 10
|
||||
")->fetchAll();
|
||||
|
||||
// Expired
|
||||
|
||||
Reference in New Issue
Block a user