prima prova
This commit is contained in:
parent
4009b1a0be
commit
1a59bcf2b0
9 changed files with 1387 additions and 0 deletions
83
public/statistiche.html
Normal file
83
public/statistiche.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Statistiche Ordini</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Statistiche degli Ordini</h1>
|
||||
|
||||
<h2>Totale vendite</h2>
|
||||
<p id="totale-vendite">Caricamento in corso...</p>
|
||||
|
||||
<h2>Metodi di Pagamento</h2>
|
||||
<h3>Totale in contante</h3>
|
||||
<p id="cash-total">Caricamento in corso...</p>
|
||||
<h3>Totale PayPal</h3>
|
||||
<p id="paypal-total">Caricamento in corso...</p>
|
||||
|
||||
<h2>Statistiche per Utente</h2>
|
||||
<div id="user-stats">Caricamento in corso...</div>
|
||||
|
||||
<h2>Prodotti Venduti</h2>
|
||||
<table id="product-stats">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome Prodotto</th>
|
||||
<th>Quantità Vendute</th>
|
||||
<th>Totale</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Le righe saranno riempite tramite JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
// Carica le statistiche dal server
|
||||
fetch('/statistiche')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const { utenti, metodi_pagamento, prodotti_venduti, totale_vendite } = data;
|
||||
|
||||
// Mostra il totale delle vendite
|
||||
document.getElementById('totale-vendite').textContent = `€ ${totale_vendite.toFixed(2)}`;
|
||||
|
||||
// Mostra il totale per ogni metodo di pagamento
|
||||
document.getElementById('cash-total').textContent = `€ ${metodi_pagamento.Cash.toFixed(2)}`;
|
||||
document.getElementById('paypal-total').textContent = `€ ${metodi_pagamento.PayPal.toFixed(2)}`;
|
||||
|
||||
// Mostra le statistiche per utente
|
||||
let userStatsHTML = '';
|
||||
for (const [userId, stats] of Object.entries(utenti)) {
|
||||
userStatsHTML += `
|
||||
<div>
|
||||
<h3>Utente ${userId}</h3>
|
||||
<p>Totale in contante: € ${stats.totale_cash.toFixed(2)}</p>
|
||||
<p>Totale PayPal: € ${stats.totale_paypal.toFixed(2)}</p>
|
||||
<p>Totale ordine: € ${stats.totale.toFixed(2)}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
document.getElementById('user-stats').innerHTML = userStatsHTML;
|
||||
|
||||
// Mostra le statistiche dei prodotti venduti
|
||||
const productStatsTable = document.getElementById('product-stats').getElementsByTagName('tbody')[0];
|
||||
for (const [productName, stats] of Object.entries(prodotti_venduti)) {
|
||||
const row = productStatsTable.insertRow();
|
||||
row.insertCell(0).textContent = productName;
|
||||
row.insertCell(1).textContent = stats.quantita;
|
||||
row.insertCell(2).textContent = `€ ${stats.totale.toFixed(2)}`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Errore nel caricamento delle statistiche:', error);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue