Add Mago4 demo ERP with Python FastAPI
Implements a working in-memory ERP demo inspired by Mago4, covering the core modules: dashboard with KPI widgets, customers, suppliers, products, sales orders, purchase orders, and warehouse inventory. - FastAPI backend with Pydantic models and REST API (auto-docs at /docs) - Jinja2 HTML templates with Mago4-style UI (dark sidebar, blue/orange/ green/red palette, Material Design icons) - In-memory fake database seeded with sample customers, suppliers, products, and orders — ready to swap for SQLAlchemy + SQL Server - Workarounds for Python 3.14 + Starlette 1.3 / Jinja2 compatibility (cache_size=0, new TemplateResponse(request, name, ctx) signature) - launch.json for one-click preview; run.bat for manual startup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Mago4 Demo - ERP{% endblock %}</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap">
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='/css/style.css') }}">
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-container">
|
||||
<!-- Sidebar Navigation -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="logo">
|
||||
<span class="logo-text">Mago4</span>
|
||||
<span class="logo-version">Demo</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="sidebar-nav">
|
||||
<a href="/" class="nav-item {% if request.url.path == '/' %}active{% endif %}">
|
||||
<i class="material-icons">dashboard</i>
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
<a href="/customers" class="nav-item {% if 'customers' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">people</i>
|
||||
<span>Clienti</span>
|
||||
</a>
|
||||
<a href="/suppliers" class="nav-item {% if 'suppliers' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">local_shipping</i>
|
||||
<span>Fornitori</span>
|
||||
</a>
|
||||
<a href="/products" class="nav-item {% if 'products' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">inventory_2</i>
|
||||
<span>Articoli</span>
|
||||
</a>
|
||||
<a href="/sales-orders" class="nav-item {% if 'sales' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">receipt</i>
|
||||
<span>Ordini Vendita</span>
|
||||
</a>
|
||||
<a href="/purchase-orders" class="nav-item {% if 'purchase' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">shopping_cart</i>
|
||||
<span>Ordini Acquisto</span>
|
||||
</a>
|
||||
<a href="/warehouse" class="nav-item {% if 'warehouse' in request.url.path %}active{% endif %}">
|
||||
<i class="material-icons">warehouse</i>
|
||||
<span>Magazzino</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<div class="version-info">
|
||||
<span>v1.0.0</span>
|
||||
<span>In-Memory DB</span>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<header class="top-bar">
|
||||
<div class="top-bar-content">
|
||||
<h1 class="page-title">{% block page_title %}{% endblock %}</h1>
|
||||
<div class="top-bar-actions">
|
||||
<button class="btn-icon" title="Notifiche">
|
||||
<i class="material-icons">notifications</i>
|
||||
</button>
|
||||
<button class="btn-icon" title="Profilo">
|
||||
<i class="material-icons">account_circle</i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="content-area">
|
||||
{% block content %}{% endblock %}
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', path='/js/app.js') }}"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,136 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Clienti - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Clienti{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<button class="btn btn-primary" onclick="openCreateCustomerModal()">
|
||||
<i class="material-icons">add</i> Nuovo Cliente
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Elenco Clienti</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Codice</th>
|
||||
<th>Ragione Sociale</th>
|
||||
<th>Città</th>
|
||||
<th>Paese</th>
|
||||
<th>Telefono</th>
|
||||
<th>Limite Credito</th>
|
||||
<th>Saldo</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for customer in customers %}
|
||||
<tr>
|
||||
<td><strong>{{ customer.code }}</strong></td>
|
||||
<td>{{ customer.name }}</td>
|
||||
<td>{{ customer.city }}</td>
|
||||
<td>{{ customer.country }}</td>
|
||||
<td>{{ customer.phone }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(customer.credit_limit) }}</td>
|
||||
<td class="text-right {% if customer.balance > 0 %}text-danger{% endif %}">
|
||||
€ {{ "%.2f"|format(customer.balance) }}
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-info" onclick="viewCustomer({{ customer.id }})">
|
||||
<i class="material-icons">visibility</i>
|
||||
</button>
|
||||
<button class="btn-small btn-warning" onclick="editCustomer({{ customer.id }})">
|
||||
<i class="material-icons">edit</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Detail -->
|
||||
<div id="customerModal" class="modal" onclick="closeModal(event)">
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<div class="modal-header">
|
||||
<h2 id="modalTitle">Dettagli Cliente</h2>
|
||||
<button class="btn-close" onclick="closeModal()">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody">
|
||||
<!-- Content loaded via JS -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function viewCustomer(customerId) {
|
||||
fetch(`/api/customers/${customerId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
document.getElementById('modalTitle').textContent = `Cliente: ${data.name}`;
|
||||
document.getElementById('modalBody').innerHTML = `
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Codice</label>
|
||||
<span>${data.code}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Ragione Sociale</label>
|
||||
<span>${data.name}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Email</label>
|
||||
<span>${data.email}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Telefono</label>
|
||||
<span>${data.phone}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Indirizzo</label>
|
||||
<span>${data.address}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Città</label>
|
||||
<span>${data.city}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Paese</label>
|
||||
<span>${data.country}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Limite Credito</label>
|
||||
<span>€ ${data.credit_limit.toFixed(2)}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Saldo</label>
|
||||
<span class="${data.balance > 0 ? 'text-danger' : ''}">${data.balance > 0 ? '€ ' : ''}${Math.abs(data.balance).toFixed(2)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('customerModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function editCustomer(customerId) {
|
||||
alert('Modifica cliente: ' + customerId + ' (da implementare)');
|
||||
}
|
||||
|
||||
function openCreateCustomerModal() {
|
||||
alert('Creazione nuovo cliente (da implementare)');
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
if (event && event.target.id !== 'customerModal') return;
|
||||
document.getElementById('customerModal').classList.remove('show');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,106 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Dashboard - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Dashboard{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="dashboard-container">
|
||||
<!-- First Row - KPI Cards -->
|
||||
<div class="widget-row">
|
||||
{% for widget in widgets[0] %}
|
||||
<div class="widget-card stat-card" style="border-left-color: var(--color-{{ widget.color }})">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">{{ widget.title }}</h3>
|
||||
</div>
|
||||
<div class="widget-body stat-body">
|
||||
<div class="stat-icon" style="color: var(--color-{{ widget.color }})">
|
||||
<i class="material-icons">{{ widget.icon }}</i>
|
||||
</div>
|
||||
<div class="stat-value">{{ widget.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Second Row - Data Tables -->
|
||||
<div class="widget-row">
|
||||
{% for widget in widgets[1] %}
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">{{ widget.title }}</h3>
|
||||
{% if widget.subtitle %}<p class="widget-subtitle">{{ widget.subtitle }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="widget-body grid-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if "Vendita" in widget.title %}
|
||||
<th>Data</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Cliente</th>
|
||||
<th>Importo</th>
|
||||
<th>Stato</th>
|
||||
{% else %}
|
||||
<th>Data</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Fornitore</th>
|
||||
<th>Importo</th>
|
||||
<th>Stato</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if "Vendita" in widget.title %}
|
||||
{% for order in widget.data.orders %}
|
||||
<tr>
|
||||
<td>{{ order.order_date }}</td>
|
||||
<td><strong>{{ order.order_number }}</strong></td>
|
||||
<td>{{ order.customer_name }}</td>
|
||||
<td class="text-right">{{ order.total_amount }}</td>
|
||||
<td>
|
||||
<span class="badge status-{{ order.status }}">{{ order.status }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for order in widget.data.orders %}
|
||||
<tr>
|
||||
<td>{{ order.order_date }}</td>
|
||||
<td><strong>{{ order.order_number }}</strong></td>
|
||||
<td>{{ order.supplier_name }}</td>
|
||||
<td class="text-right">{{ order.total_amount }}</td>
|
||||
<td>
|
||||
<span class="badge status-{{ order.status }}">{{ order.status }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Summary Stats -->
|
||||
<div class="summary-stats">
|
||||
<div class="stat-summary">
|
||||
<div class="stat-label">Totale Clienti</div>
|
||||
<div class="stat-number">{{ stats.total_customers }}</div>
|
||||
</div>
|
||||
<div class="stat-summary">
|
||||
<div class="stat-label">Totale Fornitori</div>
|
||||
<div class="stat-number">{{ stats.total_suppliers }}</div>
|
||||
</div>
|
||||
<div class="stat-summary">
|
||||
<div class="stat-label">Articoli in Catalogo</div>
|
||||
<div class="stat-number">{{ stats.total_products }}</div>
|
||||
</div>
|
||||
<div class="stat-summary">
|
||||
<div class="stat-label">Debiti Fornitori</div>
|
||||
<div class="stat-number text-orange">€ {{ "%.2f"|format(stats.total_payable) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,144 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Articoli - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Articoli{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<button class="btn btn-primary" onclick="openCreateProductModal()">
|
||||
<i class="material-icons">add</i> Nuovo Articolo
|
||||
</button>
|
||||
{% if low_stock %}
|
||||
<div class="alert alert-warning">
|
||||
<i class="material-icons">warning</i>
|
||||
{{ low_stock|length }} articolo/i sotto la soglia di riordino
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Catalogo Articoli</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Codice</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Categoria</th>
|
||||
<th>Prezzo Unitario</th>
|
||||
<th>Giacenza</th>
|
||||
<th>Soglia Riordino</th>
|
||||
<th>Fornitore</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for product in products %}
|
||||
<tr class="{% if product.quantity_in_stock <= product.reorder_level %}low-stock{% endif %}">
|
||||
<td><strong>{{ product.code }}</strong></td>
|
||||
<td>{{ product.description }}</td>
|
||||
<td>{{ product.category }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(product.unit_price) }}</td>
|
||||
<td class="text-right {% if product.quantity_in_stock <= product.reorder_level %}text-danger{% endif %}">
|
||||
{{ product.quantity_in_stock }}
|
||||
{% if product.quantity_in_stock <= product.reorder_level %}
|
||||
<i class="material-icons small-icon">warning</i>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right">{{ product.reorder_level }}</td>
|
||||
<td>
|
||||
{% if product.supplier_id %}
|
||||
Fornitore #{{ product.supplier_id }}
|
||||
{% else %}
|
||||
—
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-info" onclick="viewProduct({{ product.id }})">
|
||||
<i class="material-icons">visibility</i>
|
||||
</button>
|
||||
<button class="btn-small btn-warning" onclick="editProduct({{ product.id }})">
|
||||
<i class="material-icons">edit</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="productModal" class="modal" onclick="closeModal(event)">
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<div class="modal-header">
|
||||
<h2 id="modalTitle">Dettagli Articolo</h2>
|
||||
<button class="btn-close" onclick="closeModal()">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function viewProduct(productId) {
|
||||
fetch(`/api/products/${productId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const isLowStock = data.quantity_in_stock <= data.reorder_level;
|
||||
document.getElementById('modalTitle').textContent = `Articolo: ${data.code}`;
|
||||
document.getElementById('modalBody').innerHTML = `
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Codice</label>
|
||||
<span>${data.code}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Descrizione</label>
|
||||
<span>${data.description}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Categoria</label>
|
||||
<span>${data.category}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Prezzo Unitario</label>
|
||||
<span>€ ${data.unit_price.toFixed(2)}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Giacenza Attuale</label>
|
||||
<span class="${isLowStock ? 'text-danger' : ''}">
|
||||
${data.quantity_in_stock} ${isLowStock ? '⚠️ SOTTOSORTA' : ''}
|
||||
</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Soglia Riordino</label>
|
||||
<span>${data.reorder_level}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Fornitore</label>
|
||||
<span>${data.supplier_id ? 'Fornitore #' + data.supplier_id : '—'}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('productModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function editProduct(productId) {
|
||||
alert('Modifica articolo: ' + productId + ' (da implementare)');
|
||||
}
|
||||
|
||||
function openCreateProductModal() {
|
||||
alert('Creazione nuovo articolo (da implementare)');
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
if (event && event.target.id !== 'productModal') return;
|
||||
document.getElementById('productModal').classList.remove('show');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,145 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Ordini Acquisto - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Ordini Acquisto{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<button class="btn btn-primary" onclick="openCreateOrderModal()">
|
||||
<i class="material-icons">add</i> Nuovo Ordine
|
||||
</button>
|
||||
{% if pending %}
|
||||
<div class="alert alert-info">
|
||||
<i class="material-icons">info</i>
|
||||
{{ pending|length }} ordine/i in sospeso
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Elenco Ordini Acquisto</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Fornitore</th>
|
||||
<th>Importo Totale</th>
|
||||
<th>Data Consegna Prevista</th>
|
||||
<th>Stato</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
<tr>
|
||||
<td>{{ order.order_date.strftime("%d/%m/%Y") }}</td>
|
||||
<td><strong>{{ order.order_number }}</strong></td>
|
||||
<td>{{ order.supplier_name }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(order.total_amount) }}</td>
|
||||
<td>
|
||||
{% if order.expected_delivery_date %}
|
||||
{{ order.expected_delivery_date.strftime("%d/%m/%Y") }}
|
||||
{% else %}
|
||||
—
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge status-{{ order.status.value }}">{{ order.status.value }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-info" onclick="viewOrder({{ order.id }})">
|
||||
<i class="material-icons">visibility</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="orderModal" class="modal" onclick="closeModal(event)">
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<div class="modal-header">
|
||||
<h2 id="modalTitle">Dettagli Ordine Acquisto</h2>
|
||||
<button class="btn-close" onclick="closeModal()">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function viewOrder(orderId) {
|
||||
fetch(`/api/purchase-orders/${orderId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const deliveryDate = data.expected_delivery_date ? new Date(data.expected_delivery_date).toLocaleDateString('it-IT') : '—';
|
||||
const orderDate = new Date(data.order_date).toLocaleDateString('it-IT');
|
||||
|
||||
let linesHtml = '<table class="data-table-nested"><thead><tr><th>Articolo</th><th>Quantità</th><th>Prezzo Unit.</th><th>Totale</th></tr></thead><tbody>';
|
||||
data.lines.forEach(line => {
|
||||
linesHtml += `<tr>
|
||||
<td>${line.product_description} (${line.product_code})</td>
|
||||
<td class="text-right">${line.quantity}</td>
|
||||
<td class="text-right">€ ${line.unit_price.toFixed(2)}</td>
|
||||
<td class="text-right">€ ${line.total_amount.toFixed(2)}</td>
|
||||
</tr>`;
|
||||
});
|
||||
linesHtml += '</tbody></table>';
|
||||
|
||||
document.getElementById('modalTitle').textContent = `Ordine: ${data.order_number}`;
|
||||
document.getElementById('modalBody').innerHTML = `
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Numero Ordine</label>
|
||||
<span>${data.order_number}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Data Ordine</label>
|
||||
<span>${orderDate}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Fornitore</label>
|
||||
<span>${data.supplier_name}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Stato</label>
|
||||
<span class="badge status-${data.status}">
|
||||
${data.status.replace('_', ' ').toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Data Consegna Prevista</label>
|
||||
<span>${deliveryDate}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Importo Totale</label>
|
||||
<span class="text-orange" style="font-size: 1.2em; font-weight: bold;">€ ${data.total_amount.toFixed(2)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 20px;">
|
||||
<h4>Righe Ordine</h4>
|
||||
${linesHtml}
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('orderModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function openCreateOrderModal() {
|
||||
alert('Creazione nuovo ordine (da implementare)');
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
if (event && event.target.id !== 'orderModal') return;
|
||||
document.getElementById('orderModal').classList.remove('show');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,145 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Ordini Vendita - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Ordini Vendita{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<button class="btn btn-primary" onclick="openCreateOrderModal()">
|
||||
<i class="material-icons">add</i> Nuovo Ordine
|
||||
</button>
|
||||
{% if pending %}
|
||||
<div class="alert alert-info">
|
||||
<i class="material-icons">info</i>
|
||||
{{ pending|length }} ordine/i in sospeso
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Elenco Ordini Vendita</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Cliente</th>
|
||||
<th>Importo Totale</th>
|
||||
<th>Data Consegna</th>
|
||||
<th>Stato</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
<tr>
|
||||
<td>{{ order.order_date.strftime("%d/%m/%Y") }}</td>
|
||||
<td><strong>{{ order.order_number }}</strong></td>
|
||||
<td>{{ order.customer_name }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(order.total_amount) }}</td>
|
||||
<td>
|
||||
{% if order.delivery_date %}
|
||||
{{ order.delivery_date.strftime("%d/%m/%Y") }}
|
||||
{% else %}
|
||||
—
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge status-{{ order.status.value }}">{{ order.status.value }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-info" onclick="viewOrder({{ order.id }})">
|
||||
<i class="material-icons">visibility</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="orderModal" class="modal" onclick="closeModal(event)">
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<div class="modal-header">
|
||||
<h2 id="modalTitle">Dettagli Ordine Vendita</h2>
|
||||
<button class="btn-close" onclick="closeModal()">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function viewOrder(orderId) {
|
||||
fetch(`/api/sales-orders/${orderId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const deliveryDate = data.delivery_date ? new Date(data.delivery_date).toLocaleDateString('it-IT') : '—';
|
||||
const orderDate = new Date(data.order_date).toLocaleDateString('it-IT');
|
||||
|
||||
let linesHtml = '<table class="data-table-nested"><thead><tr><th>Articolo</th><th>Quantità</th><th>Prezzo Unit.</th><th>Totale</th></tr></thead><tbody>';
|
||||
data.lines.forEach(line => {
|
||||
linesHtml += `<tr>
|
||||
<td>${line.product_description} (${line.product_code})</td>
|
||||
<td class="text-right">${line.quantity}</td>
|
||||
<td class="text-right">€ ${line.unit_price.toFixed(2)}</td>
|
||||
<td class="text-right">€ ${line.total_amount.toFixed(2)}</td>
|
||||
</tr>`;
|
||||
});
|
||||
linesHtml += '</tbody></table>';
|
||||
|
||||
document.getElementById('modalTitle').textContent = `Ordine: ${data.order_number}`;
|
||||
document.getElementById('modalBody').innerHTML = `
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Numero Ordine</label>
|
||||
<span>${data.order_number}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Data Ordine</label>
|
||||
<span>${orderDate}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Cliente</label>
|
||||
<span>${data.customer_name}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Stato</label>
|
||||
<span class="badge status-${data.status}">
|
||||
${data.status.replace('_', ' ').toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Data Consegna Prevista</label>
|
||||
<span>${deliveryDate}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Importo Totale</label>
|
||||
<span class="text-success" style="font-size: 1.2em; font-weight: bold;">€ ${data.total_amount.toFixed(2)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 20px;">
|
||||
<h4>Righe Ordine</h4>
|
||||
${linesHtml}
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('orderModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function openCreateOrderModal() {
|
||||
alert('Creazione nuovo ordine (da implementare)');
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
if (event && event.target.id !== 'orderModal') return;
|
||||
document.getElementById('orderModal').classList.remove('show');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,134 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Fornitori - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Fornitori{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<button class="btn btn-primary" onclick="openCreateSupplierModal()">
|
||||
<i class="material-icons">add</i> Nuovo Fornitore
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Elenco Fornitori</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Codice</th>
|
||||
<th>Ragione Sociale</th>
|
||||
<th>Città</th>
|
||||
<th>Paese</th>
|
||||
<th>Telefono</th>
|
||||
<th>Termini Pagamento</th>
|
||||
<th>Saldo</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for supplier in suppliers %}
|
||||
<tr>
|
||||
<td><strong>{{ supplier.code }}</strong></td>
|
||||
<td>{{ supplier.name }}</td>
|
||||
<td>{{ supplier.city }}</td>
|
||||
<td>{{ supplier.country }}</td>
|
||||
<td>{{ supplier.phone }}</td>
|
||||
<td class="text-center">{{ supplier.payment_terms_days }} gg</td>
|
||||
<td class="text-right {% if supplier.balance > 0 %}text-warning{% endif %}">
|
||||
€ {{ "%.2f"|format(supplier.balance) }}
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-info" onclick="viewSupplier({{ supplier.id }})">
|
||||
<i class="material-icons">visibility</i>
|
||||
</button>
|
||||
<button class="btn-small btn-warning" onclick="editSupplier({{ supplier.id }})">
|
||||
<i class="material-icons">edit</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="supplierModal" class="modal" onclick="closeModal(event)">
|
||||
<div class="modal-content" onclick="event.stopPropagation()">
|
||||
<div class="modal-header">
|
||||
<h2 id="modalTitle">Dettagli Fornitore</h2>
|
||||
<button class="btn-close" onclick="closeModal()">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function viewSupplier(supplierId) {
|
||||
fetch(`/api/suppliers/${supplierId}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
document.getElementById('modalTitle').textContent = `Fornitore: ${data.name}`;
|
||||
document.getElementById('modalBody').innerHTML = `
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Codice</label>
|
||||
<span>${data.code}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Ragione Sociale</label>
|
||||
<span>${data.name}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Email</label>
|
||||
<span>${data.email}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Telefono</label>
|
||||
<span>${data.phone}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Indirizzo</label>
|
||||
<span>${data.address}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Città</label>
|
||||
<span>${data.city}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Paese</label>
|
||||
<span>${data.country}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Termini Pagamento</label>
|
||||
<span>${data.payment_terms_days} giorni</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<label>Saldo Debito</label>
|
||||
<span class="${data.balance > 0 ? 'text-warning' : ''}">€ ${data.balance.toFixed(2)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('supplierModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function editSupplier(supplierId) {
|
||||
alert('Modifica fornitore: ' + supplierId + ' (da implementare)');
|
||||
}
|
||||
|
||||
function openCreateSupplierModal() {
|
||||
alert('Creazione nuovo fornitore (da implementare)');
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
if (event && event.target.id !== 'supplierModal') return;
|
||||
document.getElementById('supplierModal').classList.remove('show');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,143 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Magazzino - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Magazzino{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
{% if low_stock %}
|
||||
<div class="alert alert-danger" style="flex: 1;">
|
||||
<i class="material-icons">error</i>
|
||||
<strong>Attenzione!</strong> {{ low_stock|length }} articolo/i in sottosorta
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Summary Stats -->
|
||||
<div class="widget-row" style="margin-bottom: 20px;">
|
||||
<div class="widget-card stat-card" style="border-left-color: var(--color-blue)">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Articoli in Catalogo</h3>
|
||||
</div>
|
||||
<div class="widget-body stat-body">
|
||||
<div class="stat-value">{{ products|length }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="widget-card stat-card" style="border-left-color: var(--color-red)">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Articoli in Sottosorta</h3>
|
||||
</div>
|
||||
<div class="widget-body stat-body">
|
||||
<div class="stat-icon" style="color: var(--color-red)">
|
||||
<i class="material-icons">warning</i>
|
||||
</div>
|
||||
<div class="stat-value">{{ low_stock|length }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Low Stock Alert -->
|
||||
{% if low_stock %}
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">
|
||||
<i class="material-icons">warning</i> Articoli Sotto Soglia Riordino
|
||||
</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Codice</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Giacenza</th>
|
||||
<th>Soglia Riordino</th>
|
||||
<th>Scostamento</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for product in low_stock %}
|
||||
<tr class="highlight-danger">
|
||||
<td><strong>{{ product.code }}</strong></td>
|
||||
<td>{{ product.description }}</td>
|
||||
<td class="text-danger text-bold">{{ product.quantity_in_stock }}</td>
|
||||
<td class="text-right">{{ product.reorder_level }}</td>
|
||||
<td class="text-right text-danger">
|
||||
-{{ product.reorder_level - product.quantity_in_stock }} unità
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-small btn-primary" onclick="createPOForProduct({{ product.id }})">
|
||||
<i class="material-icons">add_shopping_cart</i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- All Products -->
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Inventario Completo</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Codice</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Categoria</th>
|
||||
<th>Giacenza</th>
|
||||
<th>Soglia Riordino</th>
|
||||
<th>Prezzo Unit.</th>
|
||||
<th>Valore Magazzino</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for product in products %}
|
||||
<tr class="{% if product.quantity_in_stock <= product.reorder_level %}low-stock{% endif %}">
|
||||
<td><strong>{{ product.code }}</strong></td>
|
||||
<td>{{ product.description }}</td>
|
||||
<td>{{ product.category }}</td>
|
||||
<td class="text-right {% if product.quantity_in_stock <= product.reorder_level %}text-danger text-bold{% endif %}">
|
||||
{{ product.quantity_in_stock }}
|
||||
</td>
|
||||
<td class="text-right">{{ product.reorder_level }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(product.unit_price) }}</td>
|
||||
<td class="text-right text-bold">
|
||||
€ {{ "%.2f"|format(product.quantity_in_stock * product.unit_price) }}
|
||||
</td>
|
||||
<td>
|
||||
{% if product.quantity_in_stock <= product.reorder_level %}
|
||||
<span class="badge badge-danger">
|
||||
<i class="material-icons">warning</i> SOTTOSORTA
|
||||
</span>
|
||||
{% elif product.quantity_in_stock <= product.reorder_level + 20 %}
|
||||
<span class="badge badge-warning">
|
||||
<i class="material-icons">info</i> PROSSIMA SOGLIA
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge badge-success">
|
||||
<i class="material-icons">check</i> OK
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function createPOForProduct(productId) {
|
||||
alert('Creazione ordine di acquisto per articolo #' + productId + ' (da implementare)');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user