Files
WhatIDo/public/branches.html
T
dev 3c127b895e feat(datetime): timezone/time_format в настройках + единый хелпер дат
Часовой пояс и формат времени (24h/12h) перенесены из браузера в настройки
приложения: валидация IANA-зоны, сид в db/init.sql + db/migration.sql, отдача
в GET /api/public-settings, раздел #sec-datetime в настройках с живым превью.

Границы суток в SQL переведены на tzDayStart/tzDayEnd + bindTz ($TZ$) — раньше
$n::date по TIMESTAMPTZ считал дни в UTC (у контейнера TimeZone=UTC) и молча
сдвигал выборку на день; хардкод Europe/Moscow вычищен, now() заменён на
tzWall().

Новый public/js/datetime.js: три семейства хелперов (instant / чистая
DATE-строка без Date() / чистая TIME-строка), подключён на всех страницах
включая публичные share/report/index, initDateTime() встроен в checkAuth().
Прямые toLocale*/getFullYear/toISOString().slice(0,10) в public/ выпилены.

Попутно: bindTz добавляет параметр только при наличии $TZ$ в SQL (иначе запрос
виснет вечно без global error handler) — регрессия закрыта в api.smoketest.js;
починены off-by-one месяца в report.js и группировка по дате в share.js.
2026-10-04 10:49:48 +03:00

149 lines
4.1 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Филиалы — Админ-панель</title>
<link rel="stylesheet" href="admin.css">
</head>
<body data-page="branches">
<div class="layout">
<div class="sidebar" id="sidebar"></div>
<div class="main">
<div class="page-head">
<h2>Филиалы</h2>
<p class="page-sub">Управление филиалами и привязка групп</p>
</div>
<div class="actions-row" style="margin-bottom:16px">
<button class="btn-primary" id="addBranchBtn" type="button">
<span style="font-size:1.2rem">+</span> Добавить филиал
</button>
</div>
<div class="branches-grid" id="branchesGrid">
<div class="empty">Загрузка…</div>
</div>
</div>
</div>
<!-- Branch Modal -->
<div class="modal-overlay" id="branchModal">
<div class="edit-modal" style="max-width:480px">
<h3 id="branchModalTitle">Создать филиал</h3>
<form id="branchForm" class="settings-stack" style="gap:12px">
<input type="hidden" name="id" id="branchId">
<div class="settings-row">
<div class="settings-field" style="flex:1">
<label>Название <span style="color:#ef4444">*</span></label>
<input type="text" name="name" class="settings-input" required placeholder="Например: Центральный офис" autocomplete="off">
</div>
</div>
<div class="settings-row">
<div class="settings-field" style="flex:1">
<label>Адрес</label>
<input type="text" name="address" class="settings-input" placeholder="Улица, дом, офис">
</div>
</div>
<div class="settings-row">
<div class="settings-field" style="flex:1">
<label>Телефон</label>
<input type="text" name="phone" class="settings-input" placeholder="+7 (XXX) XXX-XX-XX">
</div>
</div>
<div class="card-foot" style="justify-content:flex-end;gap:8px">
<button type="button" class="btn-primary ghost" id="branchCancelBtn">Отмена</button>
<button type="submit" class="btn-primary" id="branchSubmitBtn">Создать</button>
</div>
</form>
</div>
</div>
<div class="modal-overlay" id="imgModal">
<img id="imgModalSrc" alt="">
</div>
<div class="toast" id="toast"></div>
<script src="vendor/lucide.min.js"></script>
<script src="js/datetime.js"></script>
<script src="admin.js"></script>
<script src="js/branches.js"></script>
<style>
.branches-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 12px;
}
.branch-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 16px;
display: flex;
flex-direction: column;
gap: 8px;
transition: box-shadow .15s, border-color .15s;
}
.branch-card:hover {
box-shadow: 0 4px 16px rgba(0,0,0,.08);
border-color: var(--accent);
}
.branch-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.branch-name {
font-weight: 600;
font-size: .95rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.branch-badge {
font-size: .7rem;
font-weight: 600;
color: var(--accent);
background: rgba(37,99,235,.1);
padding: 2px 8px;
border-radius: 999px;
white-space: nowrap;
flex-shrink: 0;
}
.branch-meta {
font-size: .78rem;
color: var(--muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.branch-actions {
display: flex;
justify-content: flex-end;
gap: 6px;
margin-top: 4px;
}
.branch-actions button {
background: none;
border: none;
color: var(--muted);
cursor: pointer;
font-size: 1rem;
padding: 6px 8px;
border-radius: 6px;
transition: background .15s, color .15s;
}
.branch-actions button:hover {
background: var(--bg);
color: var(--text);
}
.branch-actions .branch-delete:hover {
color: #ef4444;
background: rgba(239,68,68,.1);
}
@media (max-width: 640px) {
.branches-grid { grid-template-columns: 1fr; }
}
</style>
</body>
</html>