diff --git a/src/admin/index.php b/src/admin/index.php index 0eaa1c9..332c703 100644 --- a/src/admin/index.php +++ b/src/admin/index.php @@ -23,12 +23,30 @@ if ($role !== 'admin') { die("Accesso negato. Solo gli amministratori possono accedere a questa sezione."); } -// Query per ottenere tutti i prodotti -$sql = "SELECT p.ProductID, p.ProductName, c.Name AS 'CategoryName', p.Description, p.Price, p.StockQuantity, p.ImagePath FROM Products p JOIN Categories c ON p.CategoryID=c.CategoryID"; -$result = $conn->query($sql); +// Lettura dei contatori per la dashboard +$totalOrders = 0; +$pendingOrders = 0; +$totalProducts = 0; -if ($result === false) { - die("Errore nella query: " . $conn->error); +$sql_total_orders = "SELECT COUNT(*) FROM Orders"; +$result_total_orders = $conn->query($sql_total_orders); +if ($result_total_orders) { + $totalOrders = $result_total_orders->fetch_row()[0]; + $result_total_orders->close(); +} + +$sql_pending_orders = "SELECT COUNT(*) FROM Orders WHERE Status = 'pending'"; +$result_pending_orders = $conn->query($sql_pending_orders); +if ($result_pending_orders) { + $pendingOrders = $result_pending_orders->fetch_row()[0]; + $result_pending_orders->close(); +} + +$sql_total_products = "SELECT COUNT(*) FROM Products"; +$result_total_products = $conn->query($sql_total_products); +if ($result_total_products) { + $totalProducts = $result_total_products->fetch_row()[0]; + $result_total_products->close(); } ?> @@ -68,7 +86,21 @@ if ($result === false) {
-

Hello World!

+

Dashboard

+
+
+

+

Ordini totali

+
+
+

+

Ordini in corso

+
+
+

+

Prodotti totali

+
+
diff --git a/src/assets/style.css b/src/assets/style.css index 1121585..31af370 100644 --- a/src/assets/style.css +++ b/src/assets/style.css @@ -256,6 +256,44 @@ form button:hover { padding: 20px; } +.admin-stats-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + gap: 16px; + margin-top: 20px; +} + +.admin-stat-card { + padding: 20px; + border: 1px solid #ddd; + border-radius: 12px; + background-color: #fff; + box-shadow: 0 1px 4px rgba(0,0,0,0.06); + text-align: center; +} + +.admin-stat-card h2 { + margin: 0 0 10px; + font-size: 36px; + color: #333; +} + +.admin-stat-card p { + margin: 0; + color: #666; + font-weight: 600; +} + +.admin-stat-pending { + border-color: #ffc107; + background-color: #fff8e1; +} + +.admin-stat-products { + border-color: #17a2b8; + background-color: #e9f7fb; +} + @media (max-width: 768px) { .account-layout { flex-direction: column;