"use strict"; /* CyberReport: отчёт за период — печать/сохранение в PDF. */ CR.Reports = {}; CR.Reports.period = () => CR.state.report; function esc(s) { return String(s == null ? "" : s); } CR.Reports.render = function (view) { const s = CR.state; const all = s.online ? s.attacks : []; const allTotal = all.length; const inWorkAll = all.filter(a => a.status === "progress").length; const closedAll = allTotal - inWorkAll; const fromInput = s.report.from; const toInput = s.report.to; let list = all.slice(); if (fromInput) list = list.filter(a => a.date >= fromInput); if (toInput) list = list.filter(a => a.date <= toInput); list.sort((a, b) => a.date.localeCompare(b.date) || (a.title || "").localeCompare(b.title || "")); const listTotal = list.length; const inWork = list.filter(a => a.status === "progress").length; const closed = list.filter(a => a.status === "closed").length; const fresh = list.filter(a => a.status === "new").length; const byType = CR.ATTACK_TYPES.map(t => ({ t, n: list.filter(a => a.type === t.id).length })).filter(x => x.n); const periodText = CR.fmtDate(fromInput) + " — " + CR.fmtDate(toInput); const rows = list.map(a => "" + "" + CR.fmtDate(a.date) + "" + "" + esc(a.title) + "" + "" + esc(CR.typeLabel(a.type)) + "" + "" + esc(CR.statusLabel(a.status)) + "" + "" + esc(a.description) + "" + "" + esc(a.measures) + "" + "" ).join("") || 'Нет атак за выбранный период'; const byTypeRows = byType.map(x => "" + esc(x.t.label) + "" + x.n + "").join("") || 'Нет данных'; view.innerHTML = '
' + '
Период—
' + '' + '' + '
' + '" + '" + "
" + '
' + "

Отчёт по кибератакам

" + '

Период: ' + periodText + " · сформирован " + CR.fmtDateTime(CR.todayIso()) + "

" + '

Общее количество

' + "" + "" + "" + "" + (fresh ? "" : "") + "
ПоказательЗа периодВсего
Всего атак" + listTotal + "" + allTotal + "
В работе" + inWork + "" + inWorkAll + "
Закрыто" + closed + "" + closedAll + "
Новых за период" + fresh + "—
" + "

По типам

" + "" + byTypeRows + "
Тип атакиЗа период
" + "

Список атак

" + '' + rows + "
ДатаНазваниеТипСтатусОписаниеПринятые меры
" + "
"; const setPeriod = (f, t) => { CR.state.report.from = f; CR.state.report.to = t; CR.renderView(); }; document.getElementById("r-from").addEventListener("change", (e) => setPeriod(e.target.value, CR.state.report.to)); document.getElementById("r-to").addEventListener("change", (e) => setPeriod(CR.state.report.from, e.target.value)); document.getElementById("r-preset-month").addEventListener("click", () => setPeriod(CR.daysAgoIso(30), CR.todayIso())); document.getElementById("r-preset-all").addEventListener("click", () => setPeriod("", CR.todayIso())); document.getElementById("r-attack").addEventListener("click", () => CR.navigate("attacks")); document.getElementById("r-print").addEventListener("click", () => { CR.toast("Откроется диалог печати — выберите «Сохранить как PDF»"); setTimeout(() => window.print(), 250); }); };