From 76c43447200b032d982a6ca8af85f675f5a8bcd8 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Mon, 27 Apr 2026 05:50:22 +0000 Subject: [PATCH] feat: show last 3 barcode digits in finished-product banner title --- api/index.php | 3 ++- assets/js/app.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/index.php b/api/index.php index 7f77756..1612d0d 100644 --- a/api/index.php +++ b/api/index.php @@ -1167,7 +1167,7 @@ function deleteInventory(PDO $db): void { */ function getFinishedItems(PDO $db): void { $rows = $db->query(" - SELECT p.id AS product_id, p.name, p.brand, p.unit, p.default_quantity, p.package_unit, p.image_url, + SELECT p.id AS product_id, p.name, p.brand, p.unit, p.default_quantity, p.package_unit, p.image_url, p.barcode, MIN(i.location) AS location, MAX(i.updated_at) AS updated_at, COALESCE(SUM(CASE WHEN t.type = 'in' AND t.undone = 0 THEN t.quantity ELSE 0 END), 0) AS total_in, @@ -1200,6 +1200,7 @@ function getFinishedItems(PDO $db): void { 'default_quantity' => $r['default_quantity'], 'package_unit' => $r['package_unit'], 'image_url' => $r['image_url'], + 'barcode' => $r['barcode'], 'location' => $r['location'], 'updated_at' => $r['updated_at'], 'expected_qty' => round($expected, 3), diff --git a/assets/js/app.js b/assets/js/app.js index 3415783..08f0e18 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2556,7 +2556,8 @@ function renderBannerItem() { const fin = entry.data; banner.className = 'alert-banner banner-finished'; iconEl.textContent = '📦'; - titleEl.textContent = `${fin.name}${fin.brand ? ' (' + fin.brand + ')' : ''} — ${t('dashboard.banner_finished_title')}`; + const barcodeSuffix = fin.barcode && fin.barcode.length >= 3 ? ' …' + fin.barcode.slice(-3) : ''; + titleEl.textContent = `${fin.name}${fin.brand ? ' (' + fin.brand + ')' : ''}${barcodeSuffix} — ${t('dashboard.banner_finished_title')}`; const expectedText = fin.expected_qty ? ` Secondo le registrazioni dovresti averne ancora ${fin.expected_qty} ${fin.unit}.` : ''; detailEl.innerHTML = `L'inventario segna zero, ma i movimenti registrati dicono che non dovrebbe essere finito.${expectedText} Puoi controllare?`; let btns = ``;