155 lines
6.4 KiB
HTML
155 lines
6.4 KiB
HTML
{% 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 %}
|