237 lines
20 KiB
HTML
237 lines
20 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>{{ project.name }} — Work Volume Tracker</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
.system-progress-table { min-width: 680px; table-layout: fixed; width: 100%; }
|
|
.system-progress-table .system-name-cell { overflow-wrap: anywhere; }
|
|
.system-progress-table .money-cell { min-width: 12rem; white-space: nowrap; }
|
|
.system-progress-table .progress-cell { min-width: 14rem; }
|
|
.system-progress-table .progress-summary { flex-wrap: nowrap; gap: .5rem; }
|
|
.system-progress-table .progress-summary > * { white-space: nowrap; }
|
|
</style>
|
|
</head>
|
|
<body class="bg-light">
|
|
<main class="container-fluid container-xxl py-4">
|
|
<nav class="mb-3"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="/projects/">Проекты</a></li><li class="breadcrumb-item active">{{ project.name }}</li></ol></nav>
|
|
|
|
<header class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4">
|
|
<div>
|
|
<h1 class="h2 mb-2">{{ project.name }}</h1>
|
|
<div class="d-flex flex-wrap gap-3 text-secondary">
|
|
<span>Договор: <strong class="text-dark">{{ project.contract_number or 'не указан' }}</strong></span>
|
|
<span>Заказчик: <strong class="text-dark">{{ project.customer or 'не указан' }}</strong></span>
|
|
<span>Валюта: <strong class="text-dark">{{ project.currency or 'RUB' }}</strong></span>
|
|
<span>Период: <strong class="text-dark">{{ project.start_date.strftime('%d.%m.%Y') if project.start_date else '—' }} — {{ project.end_date.strftime('%d.%m.%Y') if project.end_date else '—' }}</strong></span>
|
|
<span>Статус: <span class="badge text-bg-secondary">{{ project.status or 'не указан' }}</span></span>
|
|
</div>
|
|
{% if base_boq_documents|length == 1 %}<div class="small text-muted mt-2">Ведомость проекта: {{ base_boq_documents[0].name.replace('BOQ Import - ', 'Импорт ведомости — ').replace('BOQ Import — ', 'Импорт ведомости — ') }}</div>{% elif base_boq_documents|length > 1 %}<div class="small text-muted mt-2">Ведомостей проекта: {{ base_boq_documents|length }}</div>{% endif %}
|
|
</div>
|
|
<div class="d-flex flex-wrap gap-2">
|
|
<a class="btn btn-outline-secondary" href="/projects/{{ project.id }}/edit">Редактировать</a>
|
|
<a class="btn btn-outline-primary" href="/boq/{{ project.id }}">Ведомости</a>
|
|
<a class="btn btn-outline-primary" href="/projects/{{ project.id }}/daily-reports">Daily Reports{% if daily_reports_count %} ({{ daily_reports_count }}){% endif %}</a>
|
|
<a class="btn btn-primary" href="/projects/{{ project.id }}/daily-reports/new">Создать Daily Report</a>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="mt-3" aria-live="polite">
|
|
{% if over_plan_count %}
|
|
<div class="alert alert-warning py-2 mb-0">⚠ Проверка плана: {{ over_plan_count }} позиции превышают план · <button type="button" class="btn btn-link p-0 align-baseline" data-bs-toggle="modal" data-bs-target="#planWarningsModal">Подробнее</button></div>
|
|
{% else %}<div class="text-success small py-2">✓ Проверка плана: превышений нет</div>{% endif %}
|
|
</section>
|
|
|
|
<section class="mb-4" aria-labelledby="kpi-heading">
|
|
<h2 id="kpi-heading" class="h5 mb-3">План и выполнение</h2>
|
|
<div class="row g-3">
|
|
<div class="col-6 col-xl-3"><article class="card h-100 border-0 shadow-sm"><div class="card-body"><div class="text-muted small">Плановая стоимость</div><div class="fs-3 fw-semibold">{{ planned_cost|money(project.currency) }}</div><div class="small text-muted">по ведомостям проекта</div></div></article></div>
|
|
<div class="col-6 col-xl-3"><article class="card h-100 border-0 shadow-sm"><div class="card-body"><div class="text-muted small">Выполнено по Daily Reports</div><div class="fs-3 fw-semibold text-success">{{ performed_cost|money(project.currency) }}</div></div></article></div>
|
|
<div class="col-6 col-xl-3"><article class="card h-100 border-0 shadow-sm"><div class="card-body"><div class="text-muted small">Остаток</div><div class="fs-3 fw-semibold {% if remaining_cost < 0 %}text-danger{% endif %}">{{ remaining_cost|money(project.currency) }}</div></div></article></div>
|
|
<div class="col-6 col-xl-3"><article class="card h-100 border-0 shadow-sm"><div class="card-body"><div class="text-muted small">Выполнение</div><div class="fs-3 fw-semibold">{{ '%.4f'|format(completion_percent) }}%</div><div class="progress mt-2" role="progressbar" aria-valuenow="{{ '%.4f'|format(completion_percent) }}" aria-valuemin="0" aria-valuemax="100"><div class="progress-bar {% if completion_percent > 100 %}bg-warning{% endif %}" style="width: {{ 100 if completion_percent > 100 else completion_percent }}%"></div></div></div></article></div>
|
|
</div>
|
|
{% if not base_boq_documents %}<div class="alert alert-info mt-3 mb-0">Сначала импортируйте ведомость, чтобы сформировать план.</div>{% endif %}
|
|
</section>
|
|
|
|
<div class="row g-4">
|
|
<div class="col-lg-8">
|
|
<section class="card border-0 shadow-sm h-100">
|
|
<div class="card-header bg-white"><h2 class="h5 mb-0">Прогресс по системам</h2></div>
|
|
{% if system_progress %}
|
|
<div class="table-responsive"><table class="table align-middle mb-0 system-progress-table">
|
|
<colgroup><col><col style="width: 12rem"><col style="width: 12rem"><col style="width: 14rem"></colgroup>
|
|
<thead><tr><th>Система</th><th class="text-end money-cell">План</th><th class="text-end money-cell">Выполнено</th><th class="progress-cell">Прогресс</th></tr></thead>
|
|
<tbody>{% for row in system_progress %}
|
|
<tr>
|
|
<td class="system-name-cell">{{ row.system.name }}</td>
|
|
<td class="text-end money-cell">{{ row.planned_cost|money(project.currency) }}</td>
|
|
<td class="text-end money-cell">{{ row.performed_cost|money(project.currency) }}</td>
|
|
<td class="progress-cell"><div class="d-flex justify-content-between small mb-1 progress-summary"><span>{{ '%.4f'|format(row.completion_percent) }}%</span>{% if not row.planned_cost %}<span class="text-muted">нет плана</span>{% endif %}</div><div class="progress" role="progressbar" aria-valuenow="{{ '%.4f'|format(row.completion_percent) }}" aria-valuemin="0" aria-valuemax="100"><div class="progress-bar {% if row.completion_percent > 100 %}bg-warning{% endif %}" style="width: {{ 100 if row.completion_percent > 100 else row.completion_percent }}%"></div></div></td>
|
|
</tr>{% endfor %}</tbody>
|
|
</table></div>
|
|
{% else %}<div class="card-body text-muted">В проекте пока нет систем.</div>{% endif %}
|
|
</section>
|
|
</div>
|
|
|
|
<div class="col-lg-4">
|
|
<section class="card border-0 shadow-sm h-100">
|
|
<div class="card-header bg-white d-flex justify-content-between align-items-center">
|
|
<h2 class="h5 mb-0">Рабочий журнал</h2>
|
|
<button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#journalModal" id="journal-add">+</button>
|
|
</div>
|
|
<div class="card-body">
|
|
<h3 class="h6">Задачи</h3>
|
|
<div id="journal-task-list">
|
|
{% for entry in journal_tasks %}
|
|
<div class="journal-entry border-bottom py-2" id="journal-entry-{{ entry.id }}">
|
|
<div class="d-flex align-items-start gap-2">
|
|
<input class="form-check-input journal-toggle mt-1" type="checkbox" aria-label="Отметить задачу выполненной" data-entry-id="{{ entry.id }}">
|
|
<div class="flex-grow-1 min-w-0">
|
|
<div class="journal-entry-text">{{ entry.text }}</div>
|
|
{% if entry.due_date %}<small class="text-muted">Срок: {{ entry.due_date.strftime('%d.%m.%Y') }}</small>{% endif %}
|
|
</div>
|
|
<button type="button" class="btn btn-sm btn-link p-0 journal-edit" data-bs-toggle="modal" data-bs-target="#journalModal" data-entry-id="{{ entry.id }}" data-entry-type="task" data-entry-text="{{ entry.text }}" data-due-date="{{ entry.due_date.isoformat() if entry.due_date else '' }}" aria-label="Редактировать">✎</button>
|
|
<button type="button" class="btn btn-sm btn-link text-danger p-0 journal-delete" data-entry-id="{{ entry.id }}" aria-label="Удалить">×</button>
|
|
</div>
|
|
</div>
|
|
{% else %}<div class="small text-muted mb-3" id="journal-no-tasks">Незавершённых задач нет.</div>{% endfor %}
|
|
</div>
|
|
<h3 class="h6 mt-3">Заметки</h3>
|
|
{% for entry in journal_notes %}
|
|
<div class="journal-entry border-bottom py-2" id="journal-entry-{{ entry.id }}">
|
|
<div class="d-flex align-items-start gap-2">
|
|
<div class="flex-grow-1 journal-entry-text">{{ entry.text }}</div>
|
|
<button type="button" class="btn btn-sm btn-link p-0 journal-edit" data-bs-toggle="modal" data-bs-target="#journalModal" data-entry-id="{{ entry.id }}" data-entry-type="note" data-entry-text="{{ entry.text }}" data-due-date="" aria-label="Редактировать">✎</button>
|
|
<button type="button" class="btn btn-sm btn-link text-danger p-0 journal-delete" data-entry-id="{{ entry.id }}" aria-label="Удалить">×</button>
|
|
</div>
|
|
</div>
|
|
{% else %}<div class="small text-muted">Заметок пока нет.</div>{% endfor %}
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<section class="card border-0 shadow-sm mt-4">
|
|
<div class="card-header bg-white d-flex justify-content-between align-items-center"><h2 class="h5 mb-0">Последние Daily Reports</h2><a href="/projects/{{ project.id }}/daily-reports" class="btn btn-sm btn-outline-primary">Все отчёты</a></div>
|
|
{% if recent_reports %}
|
|
<div class="table-responsive"><table class="table table-hover mb-0"><thead><tr><th>Дата</th><th>Система</th><th class="text-end">Позиций</th><th class="text-end">Объём отчёта</th><th></th></tr></thead>
|
|
<tbody>{% for row in recent_reports %}<tr><td>{{ row.report.report_date.strftime('%d.%m.%Y') }}</td><td>{{ row.systems|join(', ') }}</td><td class="text-end">{{ row.item_count }}</td><td class="text-end">{{ row.volume|money(project.currency) }}</td><td class="text-end"><a href="/projects/{{ project.id }}/daily-reports/{{ row.report.id }}" class="btn btn-sm btn-outline-primary">Просмотр</a></td></tr>{% endfor %}</tbody>
|
|
</table></div>
|
|
{% else %}<div class="card-body text-muted">Daily Reports ещё не создавались. Выполненные объёмы пока равны нулю.</div>{% endif %}
|
|
</section>
|
|
|
|
<section class="card border-0 shadow-sm mt-4">
|
|
<div class="card-header bg-white d-flex justify-content-between align-items-center"><h2 class="h5 mb-0">Документы ведомости</h2><a href="/boq/{{ project.id }}" class="btn btn-sm btn-outline-primary">Список ведомостей</a></div>
|
|
{% if boq_docs %}<ul class="list-group list-group-flush">{% for doc in boq_docs %}<li class="list-group-item d-flex justify-content-between align-items-center"><span>{{ doc.name.replace('BOQ Import - ', 'Импорт ведомости — ').replace('BOQ Import — ', 'Импорт ведомости — ') }} <small class="text-muted">{{ doc.source_file or '' }}</small></span><a class="btn btn-sm btn-outline-primary" href="/boq/{{ project.id }}/documents/{{ doc.id }}">Открыть ведомость</a></li>{% endfor %}</ul>
|
|
{% else %}<div class="card-body"><span class="text-muted">Ведомость не импортирована.</span> <a href="/projects/{{ project.id }}/import">Импортировать ведомость</a></div>{% endif %}
|
|
</section>
|
|
<div class="modal fade" id="journalModal" tabindex="-1" aria-labelledby="journalModalTitle" aria-hidden="true">
|
|
<div class="modal-dialog"><form class="modal-content" id="journal-form" method="post">
|
|
<div class="modal-header"><h2 class="modal-title fs-5" id="journalModalTitle">Запись рабочего журнала</h2><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button></div>
|
|
<div class="modal-body">
|
|
<input type="hidden" id="journal-entry-id">
|
|
<div class="mb-3"><label class="form-label" for="journal-type">Тип записи</label><select class="form-select" id="journal-type" name="type"><option value="task">Задача</option><option value="note">Заметка</option></select></div>
|
|
<div class="mb-3"><label class="form-label" for="journal-text">Текст</label><textarea class="form-control" id="journal-text" name="text" rows="3" required maxlength="4000"></textarea></div>
|
|
<div class="mb-3" id="journal-due-wrap"><label class="form-label" for="journal-due-date">Срок</label><input class="form-control" id="journal-due-date" name="due_date" type="date"></div>
|
|
<div class="text-danger small" id="journal-error" role="alert" hidden></div>
|
|
</div>
|
|
<div class="modal-footer"><button class="btn btn-secondary" type="button" data-bs-dismiss="modal">Отмена</button><button class="btn btn-primary" type="submit">Сохранить</button></div>
|
|
</form></div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="planWarningsModal" tabindex="-1" aria-labelledby="planWarningsTitle" aria-hidden="true">
|
|
<div class="modal-dialog modal-xl modal-dialog-scrollable"><div class="modal-content">
|
|
<div class="modal-header"><h2 class="modal-title fs-5" id="planWarningsTitle">Превышения планового количества</h2><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button></div>
|
|
<div class="modal-body"><div class="table-responsive"><table class="table table-sm align-middle">
|
|
<thead><tr><th>Система</th><th>Позиция</th><th class="text-end">Плановое количество</th><th class="text-end">Фактическое количество</th><th class="text-end">Превышение</th></tr></thead>
|
|
<tbody>{% for warning in over_plan_items %}<tr><td>{{ warning.system.name if warning.system else '—' }}</td><td>{{ warning.item.source_number or '' }} {{ warning.item.name }}</td><td class="text-end">{{ warning.planned_quantity }}</td><td class="text-end">{{ warning.actual_quantity }}</td><td class="text-end">{{ warning.excess_quantity }}</td></tr>{% else %}<tr><td colspan="5" class="text-muted text-center">Превышений нет.</td></tr>{% endfor %}</tbody>
|
|
</table></div></div>
|
|
</div></div>
|
|
</div>
|
|
</main>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
(() => {
|
|
const projectId = {{ project.id }};
|
|
const form = document.getElementById('journal-form');
|
|
const modal = document.getElementById('journalModal');
|
|
const type = document.getElementById('journal-type');
|
|
const dueWrap = document.getElementById('journal-due-wrap');
|
|
const dueDate = document.getElementById('journal-due-date');
|
|
const entryId = document.getElementById('journal-entry-id');
|
|
const text = document.getElementById('journal-text');
|
|
const error = document.getElementById('journal-error');
|
|
|
|
function updateTypeFields() {
|
|
const isTask = type.value === 'task';
|
|
dueWrap.hidden = !isTask;
|
|
if (!isTask) dueDate.value = '';
|
|
}
|
|
type.addEventListener('change', updateTypeFields);
|
|
document.getElementById('journal-add').addEventListener('click', () => {
|
|
entryId.value = '';
|
|
type.value = 'task';
|
|
text.value = '';
|
|
dueDate.value = '';
|
|
error.hidden = true;
|
|
updateTypeFields();
|
|
});
|
|
document.querySelectorAll('.journal-edit').forEach(button => button.addEventListener('click', () => {
|
|
entryId.value = button.dataset.entryId;
|
|
type.value = button.dataset.entryType;
|
|
text.value = button.dataset.entryText;
|
|
dueDate.value = button.dataset.dueDate;
|
|
error.hidden = true;
|
|
updateTypeFields();
|
|
}));
|
|
form.addEventListener('submit', async event => {
|
|
event.preventDefault();
|
|
error.hidden = true;
|
|
const id = entryId.value;
|
|
const url = `/projects/${projectId}/journal${id ? `/${id}` : ''}`;
|
|
try {
|
|
const response = await fetch(url, {method: 'POST', body: new URLSearchParams(new FormData(form))});
|
|
if (!response.ok) throw new Error('Не удалось сохранить запись. Проверьте введённые данные.');
|
|
window.location.reload();
|
|
} catch (e) {
|
|
error.textContent = e.message;
|
|
error.hidden = false;
|
|
}
|
|
});
|
|
document.querySelectorAll('.journal-toggle').forEach(checkbox => checkbox.addEventListener('change', async () => {
|
|
checkbox.disabled = true;
|
|
try {
|
|
const response = await fetch(`/projects/${projectId}/journal/${checkbox.dataset.entryId}/toggle`, {method: 'POST'});
|
|
if (!response.ok) throw new Error('status');
|
|
checkbox.closest('.journal-entry').remove();
|
|
const list = document.getElementById('journal-task-list');
|
|
if (!list.querySelector('.journal-entry')) {
|
|
const empty = document.createElement('div');
|
|
empty.className = 'small text-muted mb-3';
|
|
empty.textContent = 'Незавершённых задач нет.';
|
|
list.append(empty);
|
|
}
|
|
} catch {
|
|
checkbox.checked = false;
|
|
checkbox.disabled = false;
|
|
}
|
|
}));
|
|
document.querySelectorAll('.journal-delete').forEach(button => button.addEventListener('click', async () => {
|
|
if (!window.confirm('Удалить запись?')) return;
|
|
button.disabled = true;
|
|
try {
|
|
const response = await fetch(`/projects/${projectId}/journal/${button.dataset.entryId}/delete`, {method: 'POST'});
|
|
if (!response.ok) throw new Error('status');
|
|
button.closest('.journal-entry').remove();
|
|
window.location.reload();
|
|
} catch {
|
|
button.disabled = false;
|
|
}
|
|
}));
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|