Restyle UI to match Mago4 and add invoicing, warehouse, scadenzario
Rework the demo into a faithful Mago4 look-and-feel and expand it with core ERP modules modelled on the real Mago4 database schema. UI (ispirata a Mago4): - Blue header with logo/search/operation date, desktop-style window tabs - White sidebar with coloured module icons (Anagrafiche, Vendite, Acquisti, Amministrazione, Logistica) - Card-based module landing pages with breadcrumb + tab strip - Document detail forms with left tabs, line grid and totals box Fatturazione (InvoiceMng / MA_SaleDoc): - Document types (Fattura Immediata, DDT, Nota di Credito, ProForma) - Lines with discount/IVA, automatic taxable/tax/total computation - Document states (draft -> printed -> issued / posted_to_inventory) Magazzino (Inventory / MA_InventoryEntries + MA_InventoryReasons): - Inventory movements with load/unload reasons (DebitCreditSign) - Posting a movement actually updates item balances - Causali and stock valuation pages Amministrazione / Scadenzario (AP_AR / MA_PyblsRcvbls): - Open items (receivables/payables) with due date, method, state - Settle action closes the item and recomputes the cash forecast Dashboard riprogettata (focus su scadenze e to-do): - Overdue alert banner, KPI for overdue payables/receivables - Upcoming deadlines table, prioritised "Cose da fare" action list - 30-day cash-flow forecast and customer credit-limit check Adds REST endpoints for invoices, movements, schedules and dashboard data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+49
-123
@@ -1,60 +1,40 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Ordini Acquisto - Mago4 Demo{% endblock %}
|
||||
{% block page_title %}Ordini Acquisto{% endblock %}
|
||||
{% block title %}Ordini Fornitore - Mago4 Demo{% endblock %}
|
||||
{% block window_tabs %}<a href="/purchase-orders" class="window-tab active"><i class="material-icons">shopping_cart</i> Ordini Fornitore</a>{% 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 class="module-bar">
|
||||
<div class="module-title">Ordini Fornitore</div>
|
||||
<div class="breadcrumb"><a href="/">Mago4</a><span class="sep">»</span><a href="/acquisti">Acquisti</a><span class="sep">»</span><span class="current">Ordini Fornitore</span></div>
|
||||
</div>
|
||||
<div class="tab-strip">
|
||||
<a href="/purchase-orders" class="active">Ordini Fornitore</a>
|
||||
<a href="/acquisti">Documenti Acquisto</a>
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<div class="widget-header">
|
||||
<h3 class="widget-title">Elenco Ordini Acquisto</h3>
|
||||
</div>
|
||||
<div class="widget-body">
|
||||
<div class="doc-toolbar">
|
||||
<button class="tb-btn" title="Nuovo" onclick="alert('Nuovo ordine (demo)')"><i class="material-icons">add_box</i></button>
|
||||
<button class="tb-btn" title="Cerca"><i class="material-icons">search</i></button>
|
||||
<div class="tb-sep"></div>
|
||||
<button class="tb-btn" title="Stampa"><i class="material-icons">print</i></button>
|
||||
</div>
|
||||
|
||||
<div class="content-pad">
|
||||
{% if pending %}<div class="alert alert-info"><i class="material-icons">info</i> {{ pending|length }} ordine/i in sospeso</div>{% endif %}
|
||||
<div class="panel">
|
||||
<div class="panel-header"><h3><i class="material-icons">shopping_cart</i> Elenco Ordini Fornitore</h3></div>
|
||||
<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>
|
||||
<thead><tr><th>Data</th><th>Numero</th><th>Fornitore</th><th class="text-right">Importo</th><th>Consegna Prevista</th><th>Stato</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
{% for o 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>
|
||||
<td>{{ o.order_date.strftime("%d/%m/%Y") }}</td>
|
||||
<td class="text-bold mono">{{ o.order_number }}</td>
|
||||
<td>{{ o.supplier_name }}</td>
|
||||
<td class="text-right">€ {{ "%.2f"|format(o.total_amount) }}</td>
|
||||
<td>{{ o.expected_delivery_date.strftime("%d/%m/%Y") if o.expected_delivery_date else '—' }}</td>
|
||||
<td><span class="badge status-{{ o.status.value }}">{{ o.status.value }}</span></td>
|
||||
<td class="text-center"><button class="btn-icon-sm act-view" onclick="viewOrder({{ o.id }})"><i class="material-icons">visibility</i></button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -62,84 +42,30 @@
|
||||
</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 id="genericModal" class="modal" onclick="if(event.target.id==='genericModal')closeGenericModal()">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header"><h2 id="gmTitle">Ordine</h2><button class="modal-close" onclick="closeGenericModal()"><i class="material-icons">close</i></button></div>
|
||||
<div class="modal-body" id="gmBody"></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');
|
||||
function viewOrder(id) {
|
||||
fetch(`/api/purchase-orders/${id}`).then(r=>r.json()).then(d=>{
|
||||
let rows = d.lines.map(l=>`<tr><td>${l.product_description} <span class="text-mute">(${l.product_code})</span></td>
|
||||
<td class="text-right">${l.quantity}</td><td class="text-right">€ ${l.unit_price.toFixed(2)}</td>
|
||||
<td class="text-right">€ ${l.total_amount.toFixed(2)}</td></tr>`).join('');
|
||||
openGenericModal('Ordine: ' + d.order_number, `
|
||||
<div style="padding:16px">
|
||||
<div class="form-grid-2">
|
||||
${field('Numero Ordine', d.order_number)}${field('Data', fmtDate(d.order_date))}
|
||||
${field('Fornitore', d.supplier_name)}${field('Stato', d.status)}
|
||||
${field('Consegna Prevista', fmtDate(d.expected_delivery_date))}${field('Totale', '€ ' + d.total_amount.toFixed(2))}
|
||||
</div>
|
||||
<div class="form-section-title">Righe Ordine</div>
|
||||
<table class="data-table-nested"><thead><tr><th>Articolo</th><th class="text-right">Q.tà</th><th class="text-right">Prezzo</th><th class="text-right">Totale</th></tr></thead><tbody>${rows}</tbody></table>
|
||||
</div>`);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user