From df85618b038f611e30f7afb44cbf82375e1dc380 Mon Sep 17 00:00:00 2001 From: Dauren777 Date: Fri, 19 Jun 2026 06:20:11 +0000 Subject: [PATCH] v7 - budget form saves data to localStorage --- budget-form.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/budget-form.html b/budget-form.html index 4e450a9..1aa507e 100644 --- a/budget-form.html +++ b/budget-form.html @@ -290,6 +290,34 @@ document.getElementById('budget-form').addEventListener('submit', async function submitBtn.textContent = 'Отправка...'; submitBtn.disabled = true; + // Save to localStorage for dashboard + const branch = document.getElementById('branch').value; + const month = document.getElementById('month').value; + const year = document.getElementById('year').value; + + let budgetData = JSON.parse(localStorage.getItem('budget-data')) || []; + + document.querySelectorAll('#articles-body tr').forEach(row => { + const articleName = row.querySelector('[name="article_name[]"]').value; + const articleCode = articleName.split(' - ')[0]; + const plan = parseInt(row.querySelector('[name="article_plan[]"]').value) || 0; + const fact = parseInt(row.querySelector('[name="article_fact[]"]').value) || 0; + const cumulative = parseInt(row.querySelector('[name="article_cumulative[]"]').value) || 0; + + budgetData.push({ + branch: branch, + month: month, + year: year, + article: articleName, + articleCode: articleCode, + plan: plan, + fact: fact, + cumulative: cumulative + }); + }); + + localStorage.setItem('budget-data', JSON.stringify(budgetData)); + try { const response = await fetch(form.action, { method: 'POST',