mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 14:52:04 +00:00
feat: implementazione dashboard
This commit is contained in:
+38
-6
@@ -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) {
|
||||
</ul>
|
||||
</div>
|
||||
<div class="my-container">
|
||||
<h1>Hello World!<h1>
|
||||
<h1>Dashboard</h1>
|
||||
<div class="admin-stats-grid">
|
||||
<div class="admin-stat-card">
|
||||
<h2><?php echo htmlspecialchars($totalOrders); ?></h2>
|
||||
<p>Ordini totali</p>
|
||||
</div>
|
||||
<div class="admin-stat-card admin-stat-pending">
|
||||
<h2><?php echo htmlspecialchars($pendingOrders); ?></h2>
|
||||
<p>Ordini in corso</p>
|
||||
</div>
|
||||
<div class="admin-stat-card admin-stat-products">
|
||||
<h2><?php echo htmlspecialchars($totalProducts); ?></h2>
|
||||
<p>Prodotti totali</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
Reference in New Issue
Block a user