mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 12:42:04 +00:00
Aggiunta pagina "I miei ordini"
This commit is contained in:
@@ -264,4 +264,59 @@ form button:hover {
|
||||
.my-container {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Stili per la pagina ordini */
|
||||
.orders-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.order-card {
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.order-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.order-header h3 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.order-status {
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background-color: #ffc107;
|
||||
color: #212529;
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.status-cancelled {
|
||||
background-color: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.order-details p {
|
||||
margin: 5px 0;
|
||||
color: #666;
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
session_start();
|
||||
include 'db_conf.php';
|
||||
|
||||
// Controlla se l'utente è loggato
|
||||
if (!isset($_SESSION['id'])) {
|
||||
header('Location: login.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Query per ottenere gli ordini dell'utente con i prodotti
|
||||
$sql = "SELECT o.OrderID, o.OrderDate, o.Total, o.Status,
|
||||
GROUP_CONCAT(p.ProductName SEPARATOR ', ') AS Products
|
||||
FROM Orders o
|
||||
LEFT JOIN OrderItems oi ON o.OrderID = oi.OrderID
|
||||
LEFT JOIN Products p ON oi.ProductID = p.ProductID
|
||||
WHERE o.UserID = ?
|
||||
GROUP BY o.OrderID
|
||||
ORDER BY o.OrderDate DESC";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $_SESSION['id']);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if (!$result) {
|
||||
die("Errore nella query: " . $conn->error);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Il mio account - TechStore</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
<script src="assets/js/cart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header style="display: flex; justify-content: space-between; align-items: center; padding: 10px; background-color: #f2f2f2; border-bottom: 1px solid #ddd;">
|
||||
<div id="logo" style="font-size: 24px; font-weight: bold;"><a href="index.php"><img src="img/logo.png" alt="Logo TechStore" height="32px"></a></div>
|
||||
<div>
|
||||
<a href="cart.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer;">Carrello</button></a>
|
||||
<?php if (isset($_SESSION['name'])): ?>
|
||||
<a href="logout.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">Logout</button></a>
|
||||
<span style="margin-left: 10px;">Benvenuto, <?php echo htmlspecialchars($_SESSION['name']); ?></span>
|
||||
<?php else: ?>
|
||||
<a href="login.php"><button style="margin-left: 10px; padding: 8px 16px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Accesso</button></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if (isset($_SESSION['name'])): ?>
|
||||
<div class="account-layout">
|
||||
<div class="my-sidebar">
|
||||
<ul>
|
||||
<li><a href="account.php">Il mio account</a></li>
|
||||
<li><a href="orders.php">I miei ordini</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="my-container">
|
||||
<h1>I miei ordini</h1>
|
||||
<?php if ($result->num_rows > 0): ?>
|
||||
<div class="orders-list">
|
||||
<?php while ($order = $result->fetch_assoc()): ?>
|
||||
<div class="order-card">
|
||||
<div class="order-header">
|
||||
<h3>Ordine #<?php echo htmlspecialchars($order['OrderID']); ?></h3>
|
||||
<span class="order-status status-<?php echo htmlspecialchars($order['Status']); ?>">
|
||||
<?php echo htmlspecialchars(ucfirst($order['Status'])); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="order-details">
|
||||
<p><strong>Data:</strong> <?php echo date('d/m/Y H:i', strtotime($order['OrderDate'])); ?></p>
|
||||
<p><strong>Prodotti:</strong> <?php echo htmlspecialchars($order['Products']); ?></p>
|
||||
<p><strong>Totale:</strong> €<?php echo number_format($order['Total'], 2, ',', '.'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<p>Non hai ancora effettuato ordini.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php header('Location: login.php'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $conn->close(); ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user