410 lines
13 KiB
HTML
410 lines
13 KiB
HTML
{% extends "base.html" %}
|
||
|
||
{% block title %}Список заказов{% endblock %}
|
||
|
||
{% block content %}
|
||
<!-- Заголовок и кнопка добавления -->
|
||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||
<h2 class="page-title">Список заказов</h2>
|
||
<div class="btn-group">
|
||
<select class="form-select me-2" id="supplierSelect" style="width: 250px;">
|
||
<option value="">Выберите поставщика</option>
|
||
{% for client in clients %}
|
||
<option value="{{ client.id }}">{{ client.name }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
<button class="btn btn-primary" id="addOrderBtn" onclick="addOrder()">
|
||
<i class="fas fa-plus"></i> Добавить заказ
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Статистика -->
|
||
<div class="row mb-4">
|
||
<div class="col-md-6">
|
||
<div class="stats-card">
|
||
<div class="stat-item">
|
||
<h5 class="stat-label">Всего заказов</h5>
|
||
<p class="stat-number">{{ total_stats.total_orders or 0 }}</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="stats-card">
|
||
<div class="stat-item">
|
||
<h5 class="stat-label">Общая сумма</h5>
|
||
<p class="stat-number">{{ (total_stats.total_amount or 0)|int }} руб.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Таблица заказов -->
|
||
{% if orders %}
|
||
<div class="table-responsive">
|
||
<table class="table table-striped table-hover">
|
||
<thead>
|
||
<tr>
|
||
<th>ID</th>
|
||
<th>Дата</th>
|
||
<th>Поставщик</th>
|
||
<th>ИНН</th>
|
||
<th>Товары</th>
|
||
<th>Сумма</th>
|
||
<th>Статус</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for order in orders %}
|
||
<tr>
|
||
<td>{{ order.id }}</td>
|
||
<td>{{ order.order_date }}</td>
|
||
<td>
|
||
<a href="{{ url_for('order_history', client_id=order.client_id) }}">
|
||
{{ order.client_name }}
|
||
</a>
|
||
</td>
|
||
<td>{{ order.client_inn or '-' }}</td>
|
||
<td>
|
||
{% if order.product_name %}
|
||
<!-- Старая структура - один товар -->
|
||
<small>{{ order.product_name }}</small>
|
||
{% elif order.products_list %}
|
||
<!-- Новая структура - несколько товаров -->
|
||
<small>{{ order.products_list|truncate(50) }}</small>
|
||
{% else %}
|
||
<span class="text-muted">—</span>
|
||
{% endif %}
|
||
</td>
|
||
<td class="fw-bold">{{ order.total_amount|int }} руб.</td>
|
||
<td>
|
||
<span class="badge
|
||
{% if order.status == 'Выполнен' %}bg-success
|
||
{% elif order.status == 'Отменен' %}bg-danger
|
||
{% elif order.status == 'В обработке' %}bg-warning
|
||
{% else %}bg-secondary{% endif %}">
|
||
{{ order.status }}
|
||
</span>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{% else %}
|
||
<div class="alert alert-info">
|
||
<i class="fas fa-info-circle"></i>
|
||
Нет данных о заказах. <a href="{{ url_for('index') }}" class="alert-link">Вернуться к поставщикам</a>.
|
||
</div>
|
||
{% endif %}
|
||
|
||
<script>
|
||
function addOrder() {
|
||
const supplierId = document.getElementById('supplierSelect').value;
|
||
if (!supplierId) {
|
||
alert('Пожалуйста, выберите поставщика');
|
||
return;
|
||
}
|
||
window.location.href = "{{ url_for('add_order', client_id=0) }}".replace('0', supplierId);
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
:root {
|
||
--antique-white: #FAEBD7;
|
||
--light-brown: #DEB887;
|
||
--brown: #A0522D;
|
||
--dark-brown: #8B4513;
|
||
--text-dark: #2c3e50;
|
||
}
|
||
|
||
.page-title {
|
||
color: var(--brown);
|
||
font-size: 1.8rem;
|
||
font-weight: 600;
|
||
font-family: 'Verdana', sans-serif;
|
||
}
|
||
|
||
.btn-group {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.form-select {
|
||
border: 2px solid var(--light-brown);
|
||
border-radius: 8px;
|
||
padding: 10px 15px;
|
||
font-family: 'Verdana', sans-serif;
|
||
background-color: white;
|
||
}
|
||
|
||
.form-select:focus {
|
||
border-color: var(--brown);
|
||
box-shadow: 0 0 0 0.2rem rgba(160, 82, 45, 0.25);
|
||
}
|
||
|
||
.btn-primary {
|
||
background: linear-gradient(135deg, var(--brown) 0%, var(--dark-brown) 100%);
|
||
border: none;
|
||
border-radius: 8px;
|
||
padding: 10px 20px;
|
||
font-family: 'Verdana', sans-serif;
|
||
color: white;
|
||
}
|
||
|
||
.btn-primary:hover {
|
||
background: linear-gradient(135deg, var(--dark-brown) 0%, var(--brown) 100%);
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 4px 10px rgba(160, 82, 45, 0.3);
|
||
}
|
||
|
||
/* Статистика */
|
||
.stats-card {
|
||
background: linear-gradient(135deg, var(--antique-white) 0%, #F5DEB3 100%);
|
||
border: 1px solid var(--light-brown);
|
||
border-radius: 15px;
|
||
padding: 15px;
|
||
box-shadow: 0 4px 10px rgba(160, 82, 45, 0.1);
|
||
height: 100%;
|
||
}
|
||
|
||
.stat-item {
|
||
text-align: center;
|
||
padding: 15px;
|
||
background: linear-gradient(135deg, white 0%, #f8f9fa 100%);
|
||
border: 2px solid var(--light-brown);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 8px rgba(160, 82, 45, 0.15);
|
||
transition: all 0.2s ease;
|
||
height: 100%;
|
||
}
|
||
|
||
.stat-item:hover {
|
||
transform: translateY(-3px);
|
||
box-shadow: 0 8px 15px rgba(160, 82, 45, 0.25);
|
||
border-color: var(--brown);
|
||
}
|
||
|
||
.stat-number {
|
||
color: var(--dark-brown);
|
||
font-size: 2rem;
|
||
font-weight: 700;
|
||
line-height: 1.2;
|
||
margin-bottom: 5px;
|
||
font-family: 'Verdana', sans-serif;
|
||
}
|
||
|
||
.stat-label {
|
||
color: var(--brown);
|
||
font-size: 0.9rem;
|
||
text-transform: uppercase;
|
||
letter-spacing: 0.5px;
|
||
font-family: 'Verdana', sans-serif;
|
||
font-weight: 600;
|
||
}
|
||
|
||
/* Таблица */
|
||
.table {
|
||
background-color: white;
|
||
border-radius: 10px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.table thead th {
|
||
background: linear-gradient(135deg, var(--brown) 0%, var(--dark-brown) 100%);
|
||
color: white;
|
||
font-weight: 600;
|
||
border: none;
|
||
padding: 12px;
|
||
font-family: 'Verdana', sans-serif;
|
||
white-space: nowrap;
|
||
text-align: center;
|
||
}
|
||
|
||
.table tbody tr:hover {
|
||
background-color: rgba(222, 184, 135, 0.2);
|
||
}
|
||
|
||
.table tbody td {
|
||
font-family: 'Verdana', sans-serif;
|
||
color: #2c3e50;
|
||
vertical-align: middle;
|
||
padding: 12px;
|
||
text-align: center;
|
||
}
|
||
|
||
.table tbody td:nth-child(3) {
|
||
text-align: left;
|
||
}
|
||
|
||
.table tbody td:nth-child(5) {
|
||
text-align: left;
|
||
}
|
||
|
||
.table a {
|
||
color: var(--brown);
|
||
text-decoration: none;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.table a:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
/* Бейджи */
|
||
.badge {
|
||
padding: 8px 12px;
|
||
font-size: 0.85rem;
|
||
border-radius: 20px;
|
||
font-family: 'Verdana', sans-serif;
|
||
font-weight: 500;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.badge.bg-success {
|
||
background: linear-gradient(135deg, #28a745 0%, #218838 100%) !important;
|
||
color: white !important;
|
||
}
|
||
|
||
.badge.bg-warning {
|
||
background: linear-gradient(135deg, var(--light-brown) 0%, var(--brown) 100%) !important;
|
||
color: white !important;
|
||
}
|
||
|
||
.badge.bg-danger {
|
||
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
|
||
color: white !important;
|
||
}
|
||
|
||
.badge.bg-secondary {
|
||
background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%) !important;
|
||
color: white !important;
|
||
}
|
||
|
||
/* Карточки статистики */
|
||
.bg-primary, .bg-success, .bg-info {
|
||
background: none !important;
|
||
}
|
||
|
||
.card {
|
||
border: none;
|
||
background: none;
|
||
}
|
||
|
||
.display-6 {
|
||
font-size: inherit;
|
||
font-weight: inherit;
|
||
line-height: inherit;
|
||
}
|
||
|
||
/* Уведомления */
|
||
.alert {
|
||
border-radius: 12px;
|
||
border: 1px solid var(--light-brown);
|
||
background: linear-gradient(135deg, var(--antique-white) 0%, #F5DEB3 100%);
|
||
border-left: 6px solid var(--brown);
|
||
font-family: 'Verdana', sans-serif;
|
||
color: #2c3e50;
|
||
}
|
||
|
||
.alert-link {
|
||
color: var(--brown);
|
||
font-weight: 600;
|
||
text-decoration: none;
|
||
}
|
||
|
||
.alert-link:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
/* Иконки */
|
||
i {
|
||
color: var(--brown);
|
||
}
|
||
|
||
.btn-primary i {
|
||
color: white;
|
||
}
|
||
|
||
/* Адаптивность для мобильных */
|
||
@media (max-width: 768px) {
|
||
.table thead {
|
||
display: none;
|
||
}
|
||
|
||
.table tbody tr {
|
||
display: block;
|
||
margin-bottom: 15px;
|
||
border: 2px solid var(--light-brown);
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.table tbody td {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
padding: 8px 12px;
|
||
border-bottom: 1px dashed var(--light-brown);
|
||
text-align: left;
|
||
}
|
||
|
||
.table tbody td:before {
|
||
content: attr(data-label);
|
||
font-weight: 600;
|
||
color: var(--brown);
|
||
margin-right: 10px;
|
||
min-width: 100px;
|
||
}
|
||
|
||
.table tbody td:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.btn-group {
|
||
flex-direction: column;
|
||
width: 100%;
|
||
}
|
||
|
||
.form-select {
|
||
width: 100% !important;
|
||
margin-right: 0 !important;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.btn-primary {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
|
||
<script>
|
||
// Добавляем data-label для адаптивности
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
const table = document.querySelector('.table tbody');
|
||
if (table) {
|
||
const headers = document.querySelectorAll('.table thead th');
|
||
const rows = table.querySelectorAll('tr');
|
||
|
||
rows.forEach(row => {
|
||
const cells = row.querySelectorAll('td');
|
||
cells.forEach((cell, index) => {
|
||
if (headers[index]) {
|
||
cell.setAttribute('data-label', headers[index].textContent.trim());
|
||
}
|
||
});
|
||
});
|
||
}
|
||
});
|
||
|
||
function addOrder() {
|
||
const supplierId = document.getElementById('supplierSelect').value;
|
||
if (!supplierId) {
|
||
alert('Пожалуйста, выберите поставщика');
|
||
return;
|
||
}
|
||
window.location.href = "{{ url_for('add_order', client_id=0) }}".replace('0', supplierId);
|
||
}
|
||
</script>
|
||
{% endblock %} |