From 0d51f0b4512b1b8e89cc8d7958c3cfba818a35db Mon Sep 17 00:00:00 2001 From: tore Date: Fri, 4 Sep 2026 06:15:53 +0000 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D1=8B=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B2=20CSV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/index.html b/index.html index d7287dc..c8597da 100644 --- a/index.html +++ b/index.html @@ -64,6 +64,13 @@ +
+ + +
@@ -291,6 +298,35 @@ function refresh() { }, 600); } +function exportToCsv() { + const monthOffset = parseInt(document.getElementById('monthSelect').value) || 0; + const data = loadData(); + const monthName = MONTH_NAMES[new Date().getMonth() - monthOffset]; + + const head = ['Регион', 'План (₸)', 'Факт (₸)', 'Выполнение (%)', 'Статус', 'Сделки']; + const body = data.data.map(d => [ + d.region, + d.plan.toString().replace(',', '.'), + d.actual.toString().replace(',', '.'), + d.percent.toString(), + getStatusText(d.status), + d.deals.toString() + ]); + + const csv = '\uFEFF' + [head.join(';'), ...body.map(row => row.join(';'))].join('\n'); + const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'prodazhi_' + monthName + '.csv'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); +} + +document.getElementById('exportBtn').addEventListener('click', exportToCsv); + document.getElementById('monthSelect').addEventListener('change', function() { const data = loadData(); renderChart(data.data);