Files
work-volume-tracker/app/templates/projects/daily_report_form.html
T
Арсентьев Александр bd64bb6307 feat: official KS-2 Excel/Word forms with template markers and single-table flow
Replace the simplified KS-2 exports with the official unified form:

- Excel: official blank as working template, merge-safe row insertion,
  compact layout, header/signer polish, 0.00 money format
- Word: official blank via named template markers (DOC-C4), one dynamic
  works table with repeating header rows, separate closing totals block
  (Итого / Всего по акту), system group rows merged across 8 columns
- Word money formatter (space thousands, comma decimals) and split
  contract date day/month/year boxes
- Issue persists both xlsx and docx artifacts; UI keeps Excel and adds
  Word download
- Daily reports: multi-system item selection in the form

Regression tests for renderers, artifacts and layout; docs/tasks +
docs/implementation for the DOC-C* series.
2026-10-03 19:48:29 +03:00

98 lines
8.3 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ 'Редактирование' if report else 'Новый' }} Daily Report — {{ project.name }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<main class="container py-4">
<nav class="mb-3"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="/projects/">Проекты</a></li><li class="breadcrumb-item"><a href="/projects/{{ project.id }}">{{ project.name }}</a></li><li class="breadcrumb-item"><a href="/projects/{{ project.id }}/daily-reports">Daily Reports</a></li><li class="breadcrumb-item active">{{ 'Редактирование' if report else 'Новый отчёт' }}</li></ol></nav>
<h1>{{ 'Редактировать Daily Report' if report else 'Новый Daily Report' }}</h1>
{% for error in errors %}<div class="alert alert-danger">{{ error }}</div>{% endfor %}
<form method="get" action="{% if report %}/projects/{{ project.id }}/daily-reports/{{ report.id }}/edit{% else %}/projects/{{ project.id }}/daily-reports/new{% endif %}" class="card card-body mb-3">
<label for="system-picker" class="form-label">Система</label>
<div class="d-flex gap-2"><select id="system-picker" name="system_id" class="form-select" required>
<option value="">Выберите систему</option>
{% for system in systems %}<option value="{{ system.id }}" {% if selected_system and selected_system.id == system.id %}selected{% endif %}>{{ system.name }}</option>{% endfor %}
{% if has_unclassified_items %}<option value="unclassified" {% if unclassified_selected %}selected{% endif %}>&#1055;&#1088;&#1086;&#1077;&#1082;&#1090;&#1085;&#1099;&#1077; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1080; &#1073;&#1077;&#1079; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1099;</option>{% endif %}
</select><button class="btn btn-outline-primary" type="submit">Показать позиции</button></div>
<div class="form-text">Выберите систему и нажмите «Показать позиции». Позиции разных систем можно добавлять в один отчёт — уже введённые количества сохраняются.</div>
</form>
{% if selected_system or unclassified_selected %}
<form method="post" action="{% if report %}/projects/{{ project.id }}/daily-reports/{{ report.id }}/edit{% else %}/projects/{{ project.id }}/daily-reports{% endif %}">
<input type="hidden" name="system_id" value="{{ selected_system.id if selected_system else 'unclassified' }}">
<div class="card card-body mb-3">
<div class="row g-3">
<div class="col-md-4"><label for="report-date" class="form-label">Дата отчёта</label><input id="report-date" class="form-control" type="date" name="report_date" required value="{{ report.report_date.isoformat() if report else '' }}"></div>
<div class="col-md-8"><label for="notes" class="form-label">Комментарий</label><input id="notes" class="form-control" name="notes" value="{{ report.notes if report and report.notes else '' }}"></div>
</div>
</div>
<div class="card">
<div class="card-header"><strong><span id="current-system-name">{{ selected_system.name if selected_system else '&#1055;&#1088;&#1086;&#1077;&#1082;&#1090;&#1085;&#1099;&#1077; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1080; &#1073;&#1077;&#1079; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1099;' }}</span></strong> — укажите фактическое количество хотя бы для одной позиции</div>
<div class="p-3 border-bottom">
<label class="form-label" for="position-search">Поиск позиций</label>
<input id="position-search" class="form-control" type="search" autocomplete="off" placeholder="Номер, наименование, модель или производитель">
<div id="position-search-empty" class="form-text text-muted" hidden>Совпадений нет.</div>
</div>
<div class="table-responsive"><table class="table table-sm table-hover align-middle mb-0">
<thead><tr><th>Раздел</th><th>№</th><th>Рабочая позиция</th><th>Ед.</th><th class="text-end">План</th><th class="text-end">Накоплено до отчёта</th><th style="width: 180px">Выполнено за дату</th></tr></thead>
<tbody>
{% for row in rows %}
<tr class="position-row {% if row.over_plan %}table-warning{% endif %}" data-number="{{ row.item.source_number or '' }}" data-name="{{ row.item.name or '' }}" data-model="{{ row.item.model or '' }}" data-manufacturer="{{ row.item.manufacturer or '' }}" data-system="{{ row.item.system_id if row.item.system_id is not none else 'unclassified' }}" {% if not row.in_selection and row.current_quantity is none %}hidden{% endif %}>
<td>{{ row.item.section.name if row.item.section else '—' }}<div class="small text-muted">{{ row.item.system.name if row.item.system else 'Без системы' }}</div></td><td>{{ row.item.source_number or '' }}</td><td>{{ row.item.name }}</td><td>{{ row.item.unit or '' }}</td>
<td class="text-end">{{ row.planned_quantity if row.planned_quantity is not none else '—' }}</td><td class="text-end">{{ row.accumulated }}</td>
<td><input class="form-control form-control-sm" type="number" min="0" step="0.0001" name="quantity_{{ row.item.id }}" value="{{ row.current_quantity if row.current_quantity is not none else '' }}" aria-label="Выполнено: {{ row.item.name }}"></td>
</tr>
{% else %}<tr><td colspan="7" class="text-center text-muted py-4">В ведомости нет рабочих позиций.</td></tr>{% endfor %}
</tbody>
</table></div>
<div class="card-footer d-flex justify-content-between"><a class="btn btn-outline-secondary" href="/projects/{{ project.id }}/daily-reports">Отмена</a><button class="btn btn-primary" type="submit">{{ 'Сохранить изменения' if report else 'Создать отчёт' }}</button></div>
</div>
</form>
<script>
(() => {
const search = document.getElementById('position-search');
if (!search) return;
const rows = [...document.querySelectorAll('.position-row')];
const empty = document.getElementById('position-search-empty');
const picker = document.getElementById('system-picker');
const pickerForm = picker ? picker.form : null;
const hiddenSystem = document.querySelector('form[method="post"] input[name="system_id"]');
const systemName = document.getElementById('current-system-name');
const normalize = value => (value || '').toLocaleLowerCase('ru-RU').trim();
const applyFilters = () => {
const selected = picker ? picker.value : '';
const query = normalize(search.value);
let visible = 0;
for (const row of rows) {
const filled = [...row.querySelectorAll('input')].some(input => input.value.trim() !== '');
const inSystem = !selected || row.dataset.system === selected || filled;
const haystack = normalize(['number', 'name', 'model', 'manufacturer']
.map(key => row.dataset[key]).join(' '));
row.hidden = !(inSystem && haystack.includes(query));
if (!row.hidden) visible++;
}
empty.hidden = visible !== 0;
};
if (pickerForm && picker) {
pickerForm.addEventListener('submit', event => {
event.preventDefault();
if (hiddenSystem) hiddenSystem.value = picker.value;
if (systemName && picker.selectedOptions.length) {
systemName.textContent = picker.selectedOptions[0].textContent;
}
applyFilters();
});
}
search.addEventListener('input', applyFilters);
applyFilters();
})();
</script>
{% endif %}
</main>
</body>
</html>