${esc(t)}
${esc(d.desc)}
${iconSvg("chevron-right")} Создать · ${count}const DOC_TYPES = {
"NDA": {
icon: "lock",
desc: "Соглашение о неразглашении для переговорных партнёров и подрядчиков.",
fields: [
{ key: "party1", label: "Раскрывающая сторона", ph: "ТОО «Альфа Групп»" },
{ key: "party2", label: "Принимающая сторона", ph: "АО «ТехноКом»" },
{ key: "term", label: "Срок действия", type: "date", span: 2 },
{ key: "scope", label: "Сферa конфиденциальных данных", type: "textarea", span: 2, ph: "Прототипы, номенклатура, коммерческие условия…" },
{ key: "penalty", label: "Пеня за разглашение, %", type: "number", ph: "0.1" },
{ key: "currency", label: "Валюта", span: 2 }
]
},
"Договор аренды": {
icon: "building",
desc: "Аренда коммерческой недвижимости: офис, склад, участок.",
fields: [
{ key: "party1", label: "Арендодатель", ph: "ТОО «Недвижимость-К»" },
{ key: "party2", label: "Арендатор", ph: "ТОО «СтройМед»" },
{ key: "address", label: "Адрес объекта", span: 2, ph: "г. Алматы, пр. Абая 12, офис 415" },
{ key: "area", label: "Площадь, м²", type: "number", ph: "120" },
{ key: "rent", label: "Аренда, ₸/мес", type: "number", ph: "450000" },
{ key: "term", label: "Срок аренды", type: "date", span: 2 },
{ key: "deposit", label: "Залог (мес.)", type: "number", ph: "2" },
{ key: "purpose", label: "Назначение", span: 2 }
]
},
"Договор залога": {
icon: "scale",
desc: "Обеспечение обязательства залогом имущества или прав.",
fields: [
{ key: "party1", label: "Залогодатель", ph: "ТОО «АгроПлюс»" },
{ key: "party2", label: "Залоготребователь", ph: "БТА Банк" },
{ key: "property", label: "Издатель залога", span: 2, ph: "Земельный участок, кадастровый № 12:34:56:789" },
{ key: "value", label: "Стоимость залога, ₸", type: "number", ph: "8500000" },
{ key: "debt", label: "Обеспечиваемый долг, ₸", type: "number", ph: "6000000" },
{ key: "term", label: "Срок действия", type: "date", span: 2 },
{ key: "registration", label: "Договор будет зарегистрирован", type: "checkbox", span: 2 }
]
},
"Доверенность": {
icon: "user",
desc: "Одновременное полномочие на представительство.",
fields: [
{ key: "power", label: "Доверитель", span: 2, ph: "ТОО «Альфа Групп», БИН 1234567890" },
{ key: "attorney", label: "Представитель", ph: "Иванов И.И." },
{ key: "inn", label: "ИИН представителя", type: "number", ph: "980101300123" },
{ key: "powers", label: "Одновременные полномочия", type: "textarea", span: 2, ph: "Представление интересов в органах, подписание договоров…" },
{ key: "term", label: "Действительна", type: "date", span: 2 },
{ key: "notary", label: "С заверением нотариуса", type: "checkbox", span: 2 }
]
},
"Досудебная претензия": {
icon: "send",
desc: "Защита права до обращения в суд.",
fields: [
{ key: "claimant", label: "Кто предъявляет", ph: "ТОО «СтройМед»" },
{ key: "defendant", label: "Кому предъявляется", ph: "ТОО «Энергосбыт»" },
{ key: "reason", label: "Основание", type: "textarea", span: 2, ph: "Неисполнение договора № 12/26 от 15.02.2026, поставка задержана на 14 дней" },
{ key: "demand", label: "Требование", type: "textarea", span: 2, ph: "Устранить нарушение в 5 рабочих дней, компенсировать убытки 340 000 ₸" },
{ key: "deadline", label: "Срок устранения", type: "date", span: 2 },
{ key: "amount", label: "Сумма, ₸", type: "number", ph: "340000" },
{ key: "lawyer", label: "Фирма юриста", span: 2 }
]
}
};
const STATUS = {
"Черновик": { tone: "muted" },
"На согласовании": { tone: "warn" },
"На подписи": { tone: "blue" },
"Завершён": { tone: "ok" }
};
const DEMO_DOCS = [
{ id: "Д-1041/26", type: "NDA", counter: "ТОО «Казтелепорт»", created: "2026-09-18", due: "2026-09-28", status: "Черновик", data: { party1: "ТОО «Альфа Групп»", party2: "ТОО «Казтелепорт»", term: "2026-09-20", penalty: "0.1", currency: "₸" } },
{ id: "Д-1040/26", type: "Договор аренды", counter: "АО «Транстелеком»", created: "2026-09-17", due: "2026-09-25", status: "На согласовании", data: { party1: "ТОО «Недвижимость-К»", party2: "АО «Транстелеком»", address: "г. Алматы, ул. Толе би 40", area: "250", rent: "980000", term: "2026-10-01" } },
{ id: "Д-1039/26", type: "Договор залога", counter: "АО «АгроХолдинг»", created: "2026-09-16", due: "2026-09-30", status: "На согласовании", data: { party1: "АО «АгроХолдинг»", party2: "БТА Банк", value: "12400000", debt: "9800000" } },
{ id: "Д-1038/26", type: "Доверенность", counter: "ИП Маратбекова", created: "2026-09-16", due: "—", status: "Черновик", data: { power: "ИП Маратбекова А.С.", attorney: "Султанов Д.Ж.", powers: "Представление интересов в госорганах" } },
{ id: "Д-1037/26", type: "Досудебная претензия", counter: "ТОО «РемСтрой»", created: "2026-09-15", due: "2026-09-22", status: "На подписи", data: { claimant: "ТОО «СтройМед»", defendant: "ТОО «РемСтрой»", demand: "Компенсировать 1 250 000 ₸", deadline: "2026-09-22" } },
{ id: "Д-1036/26", type: "Договор аренды", counter: "ТОО «АйТи Сервис»", created: "2026-09-14", due: "2026-09-20", status: "Завершён", data: { party1: "ТОО «Недвижимость-К»", party2: "ТОО «АйТи Сервис»", area: "80", rent: "320000", term: "2026-10-01" } },
{ id: "Д-1035/26", type: "NDA", counter: "ТОО «Энергосервис»", created: "2026-09-12", due: "2026-09-26", status: "На согласовании", data: { party1: "ТОО «Альфа Групп»", party2: "ТОО «Энергосервис»", term: "2026-09-15" } },
{ id: "Д-1034/26", type: "Досудебная претензия", counter: "АО «КТЖ-Груз»", created: "2026-09-11", due: "2026-09-18", status: "На подписи", data: { claimant: "АО «Транстелеком»", defendant: "АО «КТЖ-Груз»", demand: "Взыскать пени 480 000 ₸" } },
{ id: "Д-1033/26", type: "Договор залога", counter: "ТОО «Жол Курылыс»", created: "2026-09-10", due: "2026-09-29", status: "На согласовании", data: { party1: "ТОО «Жол Курылыс»", party2: "Казахстан Кредит Bank", value: "4600000", debt: "3900000" } },
{ id: "Д-1032/26", type: "Доверенность", counter: "ТОО «СтройДеталь»", created: "2026-09-09", due: "—", status: "Завершён", data: { power: "ТОО «СтройДеталь»", attorney: "Абдуллинова Ж.А.", powers: "Подписание актов приёма-передачи" } },
{ id: "Д-1031/26", type: "Договор аренды", counter: "ТОО «МегаМаркет»", created: "2026-09-08", due: "—", status: "Завершён", data: { party1: "ТОО «Недвижимость-К»", party2: "ТОО «МегаМаркет»", area: "5400", rent: "21600000" } },
{ id: "Д-1030/26", type: "NDA", counter: "ТОО «АйТи Сервис»", created: "2026-09-07", due: "2026-09-21", status: "На согласовании", data: { party1: "ТОО «Альфа Групп»", party2: "ТОО «АйТи Сервис»", term: "2026-09-10" } },
{ id: "Д-1029/26", type: "Досудебная претензия", counter: "ТОО «ТрансЛогист»", created: "2026-09-05", due: "2026-09-15", status: "Завершён", data: { claimant: "ТОО «СтройМед»", defendant: "ТОО «ТрансЛогист»", demand: "Возвратить аванс 890 000 ₸" } },
{ id: "Д-1028/26", type: "Договор залога", counter: "ИП Сериков", created: "2026-09-04", due: "—", status: "Завершён", data: { party1: "ИП Сериков М.К.", party2: "Halyk Bank", value: "1500000", debt: "1200000" } },
{ id: "Д-1027/26", type: "NDA", counter: "АО «Казпочта»", created: "2026-09-03", due: "—", status: "Завершён", data: { party1: "ТОО «Альфа Групп»", party2: "АО «Казпочта»", term: "2026-09-05" } },
{ id: "Д-1026/26", type: "Доверенность", counter: "ТОО «АгроПлюс»", created: "2026-09-02", due: "—", status: "Завершён", data: { power: "ТОО «АгроПлюс»", attorney: "Бердибеков Н.Р.", powers: "Полномочия единоличного представителя" } },
{ id: "Д-1025/26", type: "Договор аренды", counter: "ТОО «Фабрика Керамика»", created: "2026-09-01", due: "—", status: "Завершён", data: { party1: "ТОО «Недвижимость-К»", party2: "ТОО «Фабрика Керамика»", area: "1200", rent: "4920000" } },
{ id: "Д-1024/26", type: "Досудебная претензия", counter: "ТОО «МеталлПром»", created: "2026-08-28", due: "—", status: "Завершён", data: { claimant: "АО «Транстелеком»", defendant: "ТОО «МеталлПром»", demand: "Компенсировать простой 3 100 000 ₸" } },
{ id: "Д-1023/26", type: "NDA", counter: "ТОО «Байтерек»", created: "2026-08-26", due: "—", status: "Завершён", data: { party1: "ТОО «Альфа Групп»", party2: "ТОО «Байтерек»", term: "2026-08-28" } },
{ id: "Д-1022/26", type: "Договор аренды", counter: "АО «Транстелеком»", created: "2026-08-24", due: "2026-09-14", status: "На согласовании", data: { party1: "ТОО «Недвижимость-К»", party2: "АО «Транстелеком»", area: "64", rent: "260000" } },
{ id: "Д-1021/26", type: "Договор залога", counter: "ТОО «АвтоТрейд»", created: "2026-08-22", due: "—", status: "Завершён", data: { party1: "ТОО «АвтоТрейд»", party2: "Freedom Finance", value: "7200000", debt: "6000000" } },
{ id: "Д-1020/26", type: "Досудебная претензия", counter: "ТОО «СтильДом»", created: "2026-08-20", due: "2026-09-05", status: "Завершён", data: { claimant: "ТОО «СтройМед»", defendant: "ТОО «СтильДом»", demand: "Устранить дефекты, штраф 220 000 ₸" } },
{ id: "Д-1019/26", type: "Доверенность", counter: "ТОО «АйТи Сервис»", created: "2026-08-18", due: "—", status: "Завершён", data: { power: "ТОО «АйТи Сервис»", attorney: "Ким Д.С.", powers: "Финансовые и кадровые действия" } },
{ id: "Д-1018/26", type: "NDA", counter: "ТОО «Энергосервис»", created: "2026-08-15", due: "—", status: "Завершён", data: { party1: "ТОО «Альфа Групп»", party2: "ТОО «Энергосервис»", term: "2026-08-17" } }
];
const WEEKS = [
{ label: "25.07", value: 2 },
{ label: "01.08", value: 4 },
{ label: "08.08", value: 3 },
{ label: "15.08", value: 5 },
{ label: "22.08", value: 4 },
{ label: "29.08", value: 6 }
];
let docs = DEMO_DOCS.map(d => ({ ...d, demo: true }));
let userDocs = JSON.parse(localStorage.getItem("ai_legal_docs") || "[]");
docs = userDocs.concat(docs);
let currentView = "dashboard";
let activeType = null;
let filterStatus = "all";
let filterType = "all";
let searchQuery = "";
function esc(s) {
return String(s || "").replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
}
function fmtDate(iso) {
if (!iso || iso === "—") return "—";
const [y, m, d] = iso.split("-");
return `${d}.${m}.${y}`;
}
function fmtMoney(n) {
const num = Number(n);
if (!Number.isFinite(num)) return esc(n);
return num.toLocaleString("ru-RU");
}
function statusPill(status) {
const s = STATUS[status] || { tone: "info" };
return `${esc(status)}`;
}
function iconSvg(name) {
return ``;
}
/* ======================= НАВИГАЦИЯ ======================= */
function setView(name) {
currentView = name;
document.querySelectorAll("#view .view").forEach(v => v.classList.toggle("is-active", v.id === "view-" + name));
document.querySelectorAll(".kt-ai-nav-item[data-view]").forEach(n => n.dataset.active = String(n.dataset.view === name));
const titles = {
dashboard: ["Обзор", "Документы юридической службы · сентябрь 2026"],
docs: ["Документы", "5 типов — от NDA до досудебной претензии"],
approval: ["Согласование", "Все документы службы по этапам"]
};
document.getElementById("pageTitle").textContent = titles[name][0];
document.getElementById("pageSub").textContent = titles[name][1];
if (name === "approval") { renderApproval(); }
closeSidebar();
}
document.querySelectorAll(".kt-ai-nav-item[data-view]").forEach(btn => {
btn.addEventListener("click", () => setView(btn.dataset.view));
});
/* ======================= Сайдбар (мобильный) ======================= */
function openSidebar() { document.getElementById("sidebar").dataset.open = "true"; }
function closeSidebar() { delete document.getElementById("sidebar").dataset.open; }
document.getElementById("btnBurger").addEventListener("click", e => {
e.stopPropagation();
const sb = document.getElementById("sidebar");
if (sb.dataset.open === "true") closeSidebar(); else { openSidebar(); }
});
document.addEventListener("click", e => {
const sb = document.getElementById("sidebar");
if (sb.dataset.open === "true" && !sb.contains(e.target)) closeSidebar();
});
/* ======================= Обзор ======================= */
function renderDocTypes(container, all) {
const types = Object.keys(DOC_TYPES);
const show = all ? types : types.slice(0, 5);
container.innerHTML = show.map(t => {
const d = DOC_TYPES[t];
const count = docs.filter(x => x.type === t).length;
return ` ${esc(d.desc)}${esc(t)}