Initial commit

This commit is contained in:
Alex
2026-10-07 19:57:07 +00:00
commit 6e6035c789
131 changed files with 23101 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Specs UI{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { padding-top: 60px; }
.navbar-brand { font-weight: bold; }
.page-header { margin-bottom: 30px; }
.stat-card { padding: 15px; margin: 10px 0; background: #f8f9fa; border-radius: 5px; }
.stat-value { font-size: 2em; font-weight: bold; color: #0d6efd; }
.stat-label { color: #6c758d; }
.section-title { margin-top: 30px; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #dee2e6; }
</style>
{% block extra_css %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('home') }}">Specs System</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('projects_list') }}">Проекты</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('systems_list') }}">Системы</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('specifications_list') }}">Спецификации</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('purchases_list') }}">Закупки</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('resources_list') }}">Ресурсы</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
{% block content %}{% endblock %}
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
{% block extra_js %}{% endblock %}
</body>
</html>
+75
View File
@@ -0,0 +1,75 @@
{% extends "base.html" %}
{% block title %}{{ guardian.name }} - Guardian{% endblock %}
{% block content %}
<div class="page-header">
<h1>Guardian: {{ guardian.name }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('systems_list') }}">Системы</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('system_detail', system_id=guardian.system_id) }}">{{ guardian.system.name if guardian.system else 'N/A' }}</a></li>
<li class="breadcrumb-item active">{{ guardian.name }}</li>
</ol>
</nav>
<p class="text-muted">
<strong>System:</strong> {{ guardian.system.name if guardian.system else 'N/A' }}<br>
<strong>Serial:</strong> {{ guardian.serial_number if guardian.serial_number else 'N/A' }}<br>
<strong>Location:</strong> {{ guardian.location if guardian.location else 'N/A' }}
</p>
</div>
<div class="alert alert-info">
<strong>Структура Guardian:</strong>
<pre class="mb-0" style="background: #e9ecef; padding: 10px;">Guardian {{ guardian.name }}
├── Core: 1
└── Modules: {{ modules|length }}
{% for m in modules %}
- {{ m.module.name }} × {{ m.quantity }}
{% endfor %}</pre>
</div>
<div class="section-title">Core</div>
{% if core %}
<div class="stat-card">
<div class="stat-value">{{ core.quantity }}</div>
<div class="stat-label">Количество Core (только 1 допускается)</div>
</div>
{% else %}
<div class="alert alert-warning">Core отсутствует! Guardian должен иметь ровно один Core.</div>
{% endif %}
<div class="section-title">Модули</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Модуль</th>
<th>Количество</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for m in modules %}
<tr>
<td><strong>{{ m.module.name }}</strong></td>
<td>{{ m.quantity }}</td>
<td>{{ m.module.description if m.module.description else 'N/A' }}</td>
</tr>
{% else %}
<tr>
<td colspan="3" class="text-center">Модули отсутствуют</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('system_detail', system_id=guardian.system_id) }}" class="btn btn-secondary">
К System
</a>
</div>
{% endblock %}
+61
View File
@@ -0,0 +1,61 @@
{% extends "base.html" %}
{% block title %}Specs UI - Главная{% endblock %}
{% block content %}
<div class="page-header">
<h1>Система учета спецификаций</h1>
<p class="text-muted">Версия 1.0 - Прототип UI для визуальной проверки предметной модели</p>
</div>
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
<strong>Навигация:</strong> Используйте меню сверху для перехода между разделами.
Откройте <a href="{{ url_for('projects_list') }}">проекты</a> или <a href="{{ url_for('systems_list') }}">системы</a> для начала работы.
</div>
</div>
</div>
<div class="section-title">Проекты</div>
{% if projects %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Название</th>
<th>Заказчиков</th>
<th>Систем</th>
<th>Всего получено</th>
<th>Распределено</th>
<th>Свободно</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for project in projects %}
<tr>
<td>{{ project.id }}</td>
<td><a href="{{ url_for('project_detail', project_id=project.id) }}">{{ project.name }}</a></td>
<td>{{ project.customers|length }}</td>
<td>{{ stats.get(project.id, {}).get('systems_count', 0) }}</td>
<td>{{ stats.get(project.id, {}).get('total_received', 0) }}</td>
<td>{{ stats.get(project.id, {}).get('total_allocated', 0) }}</td>
<td>{{ stats.get(project.id, {}).get('total_remaining', 0) }}</td>
<td>
<a href="{{ url_for('project_detail', project_id=project.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-warning">Нет проектов. <a href="{{ url_for('seed_demo_data') }}">Создать демо-данные</a>.</div>
{% endif %}
{% endblock %}
+189
View File
@@ -0,0 +1,189 @@
{% extends "base.html" %}
{% block title %}{{ project.name }} - Проект{% endblock %}
{% block content %}
<div class="page-header">
<h1>Проект: {{ project.name }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('projects_list') }}">Проекты</a></li>
<li class="breadcrumb-item active">{{ project.name }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-3">
<div class="stat-card">
<div class="stat-value">{{ stats.total_received }}</div>
<div class="stat-label">Всего получено</div>
</div>
</div>
<div class="col-md-3">
<div class="stat-card">
<div class="stat-value">{{ stats.total_allocated }}</div>
<div class="stat-label">Распределено</div>
</div>
</div>
<div class="col-md-3">
<div class="stat-card">
<div class="stat-value">{{ stats.total_remaining }}</div>
<div class="stat-label">Свободно</div>
</div>
</div>
<div class="col-md-3">
<div class="stat-card">
<div class="stat-value">{{ stats.systems_count }}</div>
<div class="stat-label">Систем</div>
</div>
</div>
</div>
<div class="section-title">Заказчики</div>
<ul class="list-group">
{% for customer in customers %}
<li class="list-group-item">{{ customer.name }}{% if customer.description %} - {{ customer.description }}{% endif %}</li>
{% else %}
<li class="list-group-item">Нет заказчиков</li>
{% endfor %}
</ul>
<div class="section-title">Системы</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Название</th>
<th>Заказчик</th>
<th>Гарданты</th>
<th>Модули</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for system in systems %}
<tr>
<td>{{ system.id }}</td>
<td><a href="{{ url_for('system_detail', system_id=system.id) }}">{{ system.name }}</a></td>
<td>{{ system.customer.name if system.customer else 'N/A' }}</td>
<td>{{ system.guardians|length }}</td>
<td>{{ system.system_modules|length }}</td>
<td>
<a href="{{ url_for('system_detail', system_id=system.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="6">Нет систем в этом проекте</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="section-title">Спецификации</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Номер</th>
<th>Дата</th>
<th>Договор</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for contract in contracts %}
{% for spec in contract.specifications %}
<tr>
<td><a href="{{ url_for('specification_detail', specification_id=spec.id) }}">{{ spec.specification_number }}</a></td>
<td>{{ spec.specification_date.strftime('%Y-%m-%d') if spec.specification_date else 'N/A' }}</td>
<td>{{ contract.contract_number }}</td>
<td><a href="{{ url_for('specification_detail', specification_id=spec.id) }}" class="btn btn-sm btn-secondary">Открыть</a></td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="4">Нет спецификаций</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="section-title">Закупки</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Номер</th>
<th>Дата</th>
<th>Поставщик</th>
<th>Позиций</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for purchase in purchases %}
<tr>
<td><a href="{{ url_for('purchase_detail', purchase_id=purchase.id) }}">{{ purchase.purchase_number }}</a></td>
<td>{{ purchase.purchase_date.strftime('%Y-%m-%d') if purchase.purchase_date else 'N/A' }}</td>
<td>{{ purchase.vendor.name if purchase.vendor else 'N/A' }}</td>
<td>{{ purchase.purchase_items|length }}</td>
<td>
<a href="{{ url_for('purchase_detail', purchase_id=purchase.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="5">Нет закупок</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="section-title">Ресурсы</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Модуль</th>
<th>Получено</th>
<th>Invoice</th>
<th>Specification</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for resource in resources %}
<tr>
<td><a href="{{ url_for('resource_detail', resource_id=resource.id) }}">{{ resource.id }}</a></td>
<td>{{ resource.module.name if resource.module else 'N/A' }}</td>
<td>{{ resource.quantity }}</td>
<td>{{ resource.invoice_number if resource.invoice_number else 'N/A' }}</td>
<td>{{ resource.specification_number if resource.specification_number else 'N/A' }}</td>
<td>
<a href="{{ url_for('resource_detail', resource_id=resource.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="6">Нет ресурсов</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+101
View File
@@ -0,0 +1,101 @@
{% extends "base.html" %}
{% block title %}{{ purchase.purchase_number }} - Закупка{% endblock %}
{% block content %}
<div class="page-header">
<h1>Закупка: {{ purchase.purchase_number }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('purchases_list') }}">Закупки</a></li>
<li class="breadcrumb-item active">{{ purchase.purchase_number }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-8">
<div class="card">
<div class="card-header">Реквизиты закупки</div>
<div class="card-body">
<p><strong>ID:</strong> {{ purchase.id }}</p>
<p><strong>Номер:</strong> {{ purchase.purchase_number }}</p>
<p><strong>Дата:</strong> {{ purchase.purchase_date.strftime('%Y-%m-%d') if purchase.purchase_date else 'N/A' }}</p>
<p><strong>Поставщик:</strong> {{ purchase.vendor.name if purchase.vendor else 'N/A' }}</p>
<p><strong>Проект:</strong> {{ purchase.project.name if purchase.project else 'N/A' }}</p>
<p><strong>Описание:</strong> {{ purchase.description or 'N/A' }}</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">Связанные спецификации</div>
<div class="card-body">
{% if specifications %}
<ul class="list-group">
{% for spec in specifications %}
<li class="list-group-item">
<a href="{{ url_for('specification_detail', specification_id=spec.id) }}">
{{ spec.specification_number }}
</a>
</li>
{% endfor %}
</ul>
{% else %}
<div class="text-muted">Нет связанных спецификаций</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="section-title">Позиции закупки (PurchaseItems)</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Модуль</th>
<th>Количество</th>
<th>Цена</th>
<th>Invoice</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td><strong>{{ item.module.name }}</strong></td>
<td>{{ item.quantity }}</td>
<td>${{ "%.2f"|format(item.unit_price) if item.unit_price else 'N/A' }}</td>
<td>
{% set invoices = item.purchase.invoices | selectattr('invoice_id', 'equalto', item.id) %}
{% for inv in invoices %}
{{ inv.invoice_number }}<br>
{% endfor %}
<span class="text-muted">N/A</span>
</td>
</tr>
{% else %}
<tr>
<td colspan="5" class="text-center">Нет позиций в закупке</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="section-title">Информация о закупках</div>
<p class="text-muted">Закупки связаны со спецификациями через PurchaseSpecification. Invoice относится к Purchase.</p>
<div class="mt-4">
<a href="{{ url_for('purchases_list', project_id=purchase.project_id) }}" class="btn btn-secondary">
К списку закупок
</a>
<a href="{{ url_for('project_detail', project_id=purchase.project_id) }}" class="btn btn-secondary">
К проекту
</a>
</div>
{% endblock %}
+67
View File
@@ -0,0 +1,67 @@
{% extends "base.html" %}
{% block title %}Список закупок{% endblock %}
{% block content %}
<div class="page-header">
<h1>Закупки</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item active">Закупки</li>
</ol>
</nav>
</div>
{% if project_id %}
<div class="alert alert-info">
Фильтр: Проект #{{ project_id }}
<a href="{{ url_for('purchases_list') }}" class="btn btn-sm btn-link">Показать все</a>
</div>
{% endif %}
<div class="section-title">Список закупок</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Номер</th>
<th>Дата</th>
<th>Поставщик</th>
<th>Позиций</th>
<th>Спецификации</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for purchase in purchases %}
<tr>
<td>{{ purchase.id }}</td>
<td><a href="{{ url_for('purchase_detail', purchase_id=purchase.id) }}">{{ purchase.purchase_number }}</a></td>
<td>{{ purchase.purchase_date.strftime('%Y-%m-%d') if purchase.purchase_date else 'N/A' }}</td>
<td>{{ purchase.vendor.name if purchase.vendor else 'N/A' }}</td>
<td>{{ purchase.purchase_items|length }}</td>
<td>{{ purchase.specifications|length }}</td>
<td>
<a href="{{ url_for('purchase_detail', purchase_id=purchase.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="7" class="text-center">Нет закупок</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('projects_list') }}" class="btn btn-secondary">
К проектам
</a>
</div>
{% endblock %}
@@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block title %}Ошибка распределения{% endblock %}
{% block content %}
<div class="page-header">
<h1>Ошибка распределения</h1>
</div>
<div class="alert alert-danger">
<h4 class="alert-heading">Ошибка при распределении Resource</h4>
<p><strong>{{ error }}</strong></p>
<hr>
<p class="mb-0">Пожалуйста, проверьте выбранные параметры и попробуйте снова.</p>
</div>
<div class="mt-4">
<a href="{{ url_for('resource_detail', resource_id=resource_id) }}" class="btn btn-primary">
Назад к Resource
</a>
<a href="{{ url_for('resources_list') }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+33
View File
@@ -0,0 +1,33 @@
{% extends "base.html" %}
{% block title %}Resource allocated{% endblock %}
{% block content %}
<div class="page-header">
<h1>Resource успешно распределено!</h1>
</div>
<div class="alert alert-success">
<h4 class="alert-heading">Успех!</h4>
<p>Resource было успешно распределено.</p>
<hr>
<h5>Детали:</h5>
<ul>
<li>Resource ID: {{ resource_id }}</li>
<li>System: {{ allocation.system.name if allocation.system else 'N/A' }}</li>
<li>Guardian: {{ allocation.guardian.name if allocation.guardian else 'Общая часть' }}</li>
<li>Количество: <strong>{{ allocation.quantity }}</strong></li>
<li>Дата: {{ allocation.allocation_date.strftime('%Y-%m-%d') if allocation.allocation_date else 'N/A' }}</li>
</ul>
</div>
<div class="mt-4">
<a href="{{ url_for('resource_detail', resource_id=resource_id) }}" class="btn btn-primary">
К Resource
</a>
<a href="{{ url_for('resources_list') }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+154
View File
@@ -0,0 +1,154 @@
{% extends "base.html" %}
{% block title %}Resource #{{ resource.id }}{% endblock %}
{% block content %}
<div class="page-header">
<h1>Resource #{{ resource.id }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('resources_list') }}">Ресурсы</a></li>
<li class="breadcrumb-item active">#{{ resource.id }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-3">
<div class="card">
<div class="card-header bg-primary text-white">Получено</div>
<div class="card-body">
<h2 class="card-title">{{ resource.quantity }}</h2>
<p class="card-text">{{ resource.module.name if resource.module else 'N/A' }}</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-info text-white">Распределено</div>
<div class="card-body">
<h2 class="card-title">{{ allocations|length }}</h2>
<p class="card-text">Операций</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-success text-white">Остаток</div>
<div class="card-body">
<h2 class="card-title text-success">{{ remaining }}</h2>
<p class="card-text">Свободно</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header bg-secondary text-white">Происхождение</div>
<div class="card-body">
<p class="card-text"><strong>Invoice:</strong> {{ resource.invoice_number or 'N/A' }}</p>
<p class="card-text"><strong>Specification:</strong> {{ resource.specification_number or 'N/A' }}</p>
</div>
</div>
</div>
</div>
<div class="section-title">Распределения (ResourceAllocations)</div>
<p class="text-muted">Resource находится в общем пуле проекта. Распределение выполняется через ResourceAllocation.</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>System</th>
<th>Guardian</th>
<th>Количество</th>
<th>Дата</th>
<th>Описание</th>
</tr>
</thead>
<tbody>
{% for data in allocations %}
<tr>
<td>{{ data.allocation.id }}</td>
<td>{{ data.system.name if data.system else 'N/A' }}</td>
<td>
{% if data.is_common %}
<span class="badge bg-info">Общая часть</span>
{% else %}
<a href="{{ url_for('guardian_detail', guardian_id=data.guardian.id) }}">{{ data.guardian.name if data.guardian else 'N/A' }}</a>
{% endif %}
</td>
<td><strong>{{ data.allocation.quantity }}</strong></td>
<td>{{ data.allocation.allocation_date.strftime('%Y-%m-%d') if data.allocation.allocation_date else 'N/A' }}</td>
<td>{{ data.allocation.description or 'N/A' }}</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">Нет распределений</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if remaining > 0 %}
<div class="section-title">Распределить Resource</div>
<div class="card">
<div class="card-header">Новое распределение</div>
<div class="card-body">
<form action="{{ url_for('allocate_resource', resource_id=resource.id) }}" method="GET">
<div class="mb-3">
<label class="form-label">Свободно: <strong>{{ remaining }}</strong></label>
</div>
<div class="mb-3">
<label class="form-label" for="system_id">Система:</label>
<select class="form-select" name="system_id" id="system_id" required>
<option value="">-- Выберите систему --</option>
{% for system in resource.project.systems %}
<option value="{{ system.id }}">{{ system.name }} ({{ system.customer.name if system.customer else 'N/A' }})</option>
{% else %}
<option disabled>Нет систем в проекте</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label" for="guardian_id">Guardian (опционально):</label>
<select class="form-select" name="guardian_id" id="guardian_id">
<option value="">Общая часть (NULL)</option>
{% for system in resource.project.systems %}
{% for guardian in system.guardians %}
<option value="{{ guardian.id }}">{{ guardian.name }}</option>
{% endfor %}
{% else %}
<option disabled>Нет Guardian для выбора</option>
{% endfor %}
</select>
<small class="form-text text-muted">Оставьте пустым для распределения в общую часть</small>
</div>
<div class="mb-3">
<label class="form-label" for="quantity">Количество:</label>
<input type="number" class="form-control" name="quantity" id="quantity" min="1" max="{{ remaining }}" required>
</div>
<button type="submit" class="btn btn-primary">Распределить</button>
</form>
</div>
</div>
{% else %}
<div class="alert alert-warning">
Нет свободного ресурса для распределения.
</div>
{% endif %}
<div class="mt-4">
<a href="{{ url_for('resources_list', project_id=resource.project_id) }}" class="btn btn-secondary">
К пулу ресурсов
</a>
</div>
{% endblock %}
+83
View File
@@ -0,0 +1,83 @@
{% extends "base.html" %}
{% block title %}Ресурсы - Pool{% endblock %}
{% block content %}
<div class="page-header">
<h1>Общий пул ресурсов</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item active">Ресурсы</li>
</ol>
</nav>
</div>
{% if project_id %}
<div class="alert alert-info">
Фильтр: Проект #{{ project_id }}
<a href="{{ url_for('resources_list') }}" class="btn btn-sm btn-link">Показать все</a>
</div>
{% endif %}
<div class="section-title">Сводка ресурсов</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Module</th>
<th>Получено</th>
<th>Распределено</th>
<th>Свободно</th>
<th>Invoice</th>
<th>Specification</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for resource in resources %}
<tr>
<td><a href="{{ url_for('resource_detail', resource_id=resource.id) }}">{{ resource.id }}</a></td>
<td>{{ resource.module.name if resource.module else 'N/A' }}</td>
<td>{{ resource.quantity }}</td>
<td>
{% set allocated = resource.resource_allocations|sum(attribute='quantity', default=0) %}
{{ allocated }}
</td>
<td>
{% set allocated = resource.resource_allocations|sum(attribute='quantity', default=0) %}
{% set remaining = resource.quantity - allocated %}
<span class="badge {% if remaining <= 0 %}bg-danger{% elif remaining < 100 %}bg-warning{% else %}bg-success{% endif %}">
{{ remaining }}
</span>
</td>
<td>{{ resource.invoice_number if resource.invoice_number else 'N/A' }}</td>
<td>{{ resource.specification_number if resource.specification_number else 'N/A' }}</td>
<td>
<a href="{{ url_for('resource_detail', resource_id=resource.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="text-center">Нет ресурсов</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('projects_list') }}" class="btn btn-secondary">
К проектам
</a>
{% if not project_id %}
<a href="{{ url_for('seed_demo_data') }}" class="btn btn-success">
Seed demo data
</a>
{% endif %}
</div>
{% endblock %}
+89
View File
@@ -0,0 +1,89 @@
{% extends "base.html" %}
{% block title %}{{ specification.specification_number }} - Спецификация{% endblock %}
{% block content %}
<div class="page-header">
<h1>Спецификация: {{ specification.specification_number }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('specifications_list') }}">Спецификации</a></li>
<li class="breadcrumb-item active">{{ specification.specification_number }}</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">Реквизиты</div>
<div class="card-body">
<p><strong>ID:</strong> {{ specification.id }}</p>
<p><strong>Номер:</strong> {{ specification.specification_number }}</p>
<p><strong>Дата:</strong> {{ specification.specification_date.strftime('%Y-%m-%d') if specification.specification_date else 'N/A' }}</p>
<p><strong>Договор:</strong> {{ specification.contract.contract_number if specification.contract else 'N/A' }}</p>
<p><strong>Проект:</strong> {{ specification.project.name if specification.project else 'N/A' }}</p>
<p><strong>Описание:</strong> {{ specification.description or 'N/A' }}</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">Связанные закупки</div>
<div class="card-body">
{% if specification.purchases %}
<ul class="list-group">
{% for purchase in specification.purchases %}
<li class="list-group-item">
<a href="{{ url_for('purchase_detail', purchase_id=purchase.id) }}">{{ purchase.purchase_number }}</a>
({{ purchase.purchase_date.strftime('%Y-%m-%d') if purchase.purchase_date else 'N/A' }})
</li>
{% endfor %}
</ul>
{% else %}
<div class="text-muted">Нет связанных закупок</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="section-title">Позиции спецификации (SpecificationItems)</div>
<p class="text-muted">Потребность заказчика по каждому модулю.</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Модуль</th>
<th>Требуется</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td><strong>{{ item.module.name }}</strong></td>
<td>{{ item.quantity }}</td>
<td>{{ item.description or 'N/A' }}</td>
</tr>
{% else %}
<tr>
<td colspan="3" class="text-center">Нет позиций</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('specifications_list', project_id=specification.project_id) }}" class="btn btn-secondary">
К списку спецификаций
</a>
<a href="{{ url_for('project_detail', project_id=specification.project_id) }}" class="btn btn-secondary">
К проекту
</a>
</div>
{% endblock %}
+65
View File
@@ -0,0 +1,65 @@
{% extends "base.html" %}
{% block title %}Список спецификаций{% endblock %}
{% block content %}
<div class="page-header">
<h1>Спецификации</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item active">Спецификации</li>
</ol>
</nav>
</div>
{% if project_id %}
<div class="alert alert-info">
Фильтр: Проект #{{ project_id }}
<a href="{{ url_for('specifications_list') }}" class="btn btn-sm btn-link">Показать все</a>
</div>
{% endif %}
<div class="section-title">Список спецификаций</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Номер</th>
<th>Дата</th>
<th>Договор</th>
<th>Проект</th>
<th>Позиций</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for spec in specifications %}
<tr>
<td><a href="{{ url_for('specification_detail', specification_id=spec.id) }}">{{ spec.specification_number }}</a></td>
<td>{{ spec.specification_date.strftime('%Y-%m-%d') if spec.specification_date else 'N/A' }}</td>
<td>{{ spec.contract.contract_number if spec.contract else 'N/A' }}</td>
<td>{{ spec.project.name if spec.project else 'N/A' }}</td>
<td>{{ spec.specification_items|length }}</td>
<td>
<a href="{{ url_for('specification_detail', specification_id=spec.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">Нет спецификаций</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('projects_list') }}" class="btn btn-secondary">
К проектам
</a>
</div>
{% endblock %}
+122
View File
@@ -0,0 +1,122 @@
{% extends "base.html" %}
{% block title %}{{ system.name }} - Система{% endblock %}
{% block content %}
<div class="page-header">
<h1>Система: {{ system.name }}</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('home') }}">Главная</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('systems_list') }}">Системы</a></li>
<li class="breadcrumb-item active">{{ system.name }}</li>
</ol>
</nav>
<p class="text-muted">
<strong>Заказчик:</strong> {{ system.customer.name if system.customer else 'N/A' }}<br>
<strong>Проект:</strong> {{ system.project.name if system.project else 'N/A' }}
</p>
</div>
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
<strong>Структура системы:</strong>
<pre class="mb-0" style="background: #e9ecef; padding: 10px;">System {{ system.name }}
├── Common (guardian_id = NULL)
│ └── Modules × N
└── Guardians
├── Core × 1
└── Modules × N</pre>
</div>
</div>
</div>
<div class="section-title">Общая часть (Common)</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Модуль</th>
<th>Количество</th>
</tr>
</thead>
<tbody>
{% for module in common_modules %}
<tr>
<td>{{ module.module.name }}</td>
<td><strong>{{ module.quantity }}</strong></td>
</tr>
{% else %}
<tr>
<td colspan="2" class="text-center">В общей части нет модулей</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="section-title">Guardians</div>
<p class="text-muted">Каждый Guardian имеет ровно один Core и дополнительные модули.</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Guardian</th>
<th>Core</th>
<th>Модули</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for data in guardian_data %}
<tr>
<td>
<a href="{{ url_for('guardian_detail', guardian_id=data.guardian.id) }}">
{{ data.guardian.name }}
</a>
</td>
<td>
{% if data.core %}
<span class="badge bg-success">{{ data.core.quantity }}</span>
{% else %}
<span class="badge bg-warning">Отсутствует</span>
{% endif %}
</td>
<td>
{% if data.modules %}
<ul class="list-unstyled mb-0">
{% for m in data.modules %}
<li><strong>{{ m.module.name }}</strong>: {{ m.quantity }}</li>
{% endfor %}
</ul>
{% else %}
<span class="text-muted">Нет дополнительных модулей</span>
{% endif %}
</td>
<td>
<a href="{{ url_for('guardian_detail', guardian_id=data.guardian.id) }}" class="btn btn-sm btn-primary">
Открыть
</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center">Нет Guardian</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4">
<a href="{{ url_for('resources_list', project_id=system.project_id) }}" class="btn btn-secondary">
Ресурсы проекта
</a>
<a href="{{ url_for('project_detail', project_id=system.project_id) }}" class="btn btn-secondary">
К проекту
</a>
</div>
{% endblock %}