Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3687fe98ce |
23
index.html
23
index.html
@ -87,6 +87,7 @@
|
|||||||
|
|
||||||
<div class="history-actions">
|
<div class="history-actions">
|
||||||
<span class="kt-ai-chip" id="historyCount">0 записей</span>
|
<span class="kt-ai-chip" id="historyCount">0 записей</span>
|
||||||
|
<button class="kt-ai-btn" data-variant="ghost" onclick="exportCsv()">Выгрузить в Excel</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="kt-ai-table-container">
|
<div class="kt-ai-table-container">
|
||||||
@ -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() {
|
function renderHistory() {
|
||||||
const history = getHistory();
|
const history = getHistory();
|
||||||
const tbody = document.getElementById('historyTable');
|
const tbody = document.getElementById('historyTable');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user