From 68dd7810f0ba0bbbc93370546875a48ff722d420 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Sun, 15 Mar 2026 19:15:22 +0000 Subject: [PATCH] Fix ricalcolo scadenza per freezer e sotto vuoto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - selectPurchaseType: non usa più date hardcoded, ricalcola sempre in base alla posizione e stato sotto vuoto corrente - Edit inventario: cambiare posizione o toggle sotto vuoto ricalcola la scadenza - Spostamento prodotto: ricalcola scadenza per la nuova posizione - Fix DB: fusi di pollo freezer 120gg, Bel Paese vacuum 21gg, Speck vacuum 75gg - Versione: 20260315j --- assets/js/app.js | 49 +++++++++++++++++++++++++++++++++++++++-------- data/dispensa.db | Bin 172032 -> 172032 bytes index.html | 2 +- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 6c34d4c..89a7032 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1367,6 +1367,18 @@ async function deleteInventoryItem(id) { } } +function recalcEditExpiry(locInputId, vacuumInputId, expiryInputId) { + const product = window._editingProduct; + if (!product) return; + const loc = document.getElementById(locInputId)?.value || ''; + const isVacuum = document.getElementById(vacuumInputId)?.checked; + let days = estimateExpiryDays(product, loc); + if (isVacuum) days = getVacuumExpiryDays(days); + const newDate = addDays(days); + const expiryInput = document.getElementById(expiryInputId); + if (expiryInput) expiryInput.value = newDate; +} + function editInventoryItem(id) { const item = currentInventory.find(i => i.id === id); if (!item) { @@ -1379,6 +1391,8 @@ function editInventoryItem(id) { const confSizeVal = (isConf && item.default_quantity > 0) ? item.default_quantity : ''; const confUnitVal = (isConf && item.package_unit) ? item.package_unit : 'g'; + window._editingProduct = { name: item.name, category: item.category || '' }; + // Rebuild modal content for editing (don't close and reopen - just replace content) document.getElementById('modal-content').innerHTML = `