diff --git a/index.html b/index.html
index 45d0cf0..6c571c8 100644
--- a/index.html
+++ b/index.html
@@ -87,6 +87,7 @@
0 записей
+
@@ -193,6 +194,28 @@ function clearHistory() {
}
}
+function exportCsv() {
+ const history = getHistory();
+ if (history.length === 0) {
+ alert('История пуста — нечего выгружать');
+ return;
+ }
+ const head = ['Дата', 'Оборудование', 'Срок (мес)', 'Количество (шт)', 'Скидка (%)', 'Сумма (₸)'];
+ const body = history.map(r => [
+ r.date,
+ r.equipment,
+ r.months,
+ r.quantity,
+ r.discount,
+ r.total
+ ].map(v => '"' + String(v ?? '').replace(/"/g, '""') + '"').join(';'));
+ const csv = '\uFEFF' + [head.join(';'), ...body].join('\n');
+ const a = document.createElement('a');
+ a.href = URL.createObjectURL(new Blob([csv], { type: 'text/csv; charset=utf-8' }));
+ a.download = 'istoriya_arendy.csv';
+ a.click();
+}
+
function renderHistory() {
const history = getHistory();
const tbody = document.getElementById('historyTable');