mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 12:42: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.");
|
die("Accesso negato. Solo gli amministratori possono accedere a questa sezione.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query per ottenere tutti i prodotti
|
// Lettura dei contatori per la dashboard
|
||||||
$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";
|
$totalOrders = 0;
|
||||||
$result = $conn->query($sql);
|
$pendingOrders = 0;
|
||||||
|
$totalProducts = 0;
|
||||||
|
|
||||||
if ($result === false) {
|
$sql_total_orders = "SELECT COUNT(*) FROM Orders";
|
||||||
die("Errore nella query: " . $conn->error);
|
$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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="my-container">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|||||||
@@ -256,6 +256,44 @@ form button:hover {
|
|||||||
padding: 20px;
|
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) {
|
@media (max-width: 768px) {
|
||||||
.account-layout {
|
.account-layout {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
Reference in New Issue
Block a user