192 lines
7.3 KiB
PHP
192 lines
7.3 KiB
PHP
<?php include('include/headscript.php'); ?>
|
|
<?php
|
|
// Ottieni l'istanza del DBHandlerSelect
|
|
$dbHandler = DBHandlerSelect::getInstance();
|
|
$pdo = $dbHandler->getConnection();
|
|
|
|
// Recupera lo school_id e user_id dalla sessione
|
|
$school_id = session('school_id');
|
|
$user_id = session('iduserlogin'); // Cambiato da 'user_id' a 'iduserlogin'
|
|
|
|
// Recupera l'order_number dai parametri GET
|
|
$order_number = $_GET['order_number'] ?? 0;
|
|
|
|
$school = null;
|
|
$school_name = 'Nessuna scuola selezionata';
|
|
$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo
|
|
if ($school_id) {
|
|
$school = \Vanguard\Models\School::find($school_id);
|
|
if ($school) {
|
|
$school_name = $school->name;
|
|
$school_logo_path = $school->logo ? url('userarea/photoschool/' . $school->logo) : $school_logo_path;
|
|
}
|
|
}
|
|
|
|
// Recupera i dettagli dell'ordine
|
|
$order_items = [];
|
|
$total_price = 0;
|
|
if ($order_number) {
|
|
$stmt = $pdo->prepare("
|
|
SELECT o.order_number, o.created_at, o.price, o.total_entries, o.available_entries, o.activation_date,
|
|
p.name AS product_name, pv.name AS variation_name, c.name AS class_name, ct.level, ct.day_of_week, c.photo AS class_photo
|
|
FROM orders o
|
|
JOIN products p ON o.product_id = p.id
|
|
JOIN product_variations pv ON o.variation_id = pv.id
|
|
LEFT JOIN class_types ct ON o.class_type_id = ct.id
|
|
LEFT JOIN classes c ON ct.class_id = c.id
|
|
WHERE o.order_number = ? AND o.user_id = ?
|
|
");
|
|
$stmt->execute([$order_number, $user_id]);
|
|
$order_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Calcola il totale
|
|
$total_price = array_sum(array_column($order_items, 'price'));
|
|
}
|
|
|
|
// Se non ci sono ordini, reindirizza (opzionale)
|
|
if (empty($order_items)) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
// Prendi la data di creazione dal primo elemento
|
|
$order_date = $order_items[0]['created_at'];
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
|
<?php include('cssinclude.php'); ?>
|
|
<?php include('siteinfo.php'); ?>
|
|
<style>
|
|
.page-content {
|
|
background-color: #f0f4f5;
|
|
}
|
|
|
|
.card-pastel {
|
|
background-color: rgb(149, 217, 248);
|
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
|
border: none;
|
|
}
|
|
|
|
.order-item-card {
|
|
background-color: #fff;
|
|
border: 1px solid #c8e6c9;
|
|
border-radius: 8px;
|
|
margin-bottom: 15px;
|
|
padding: 15px;
|
|
}
|
|
|
|
.order-item-image {
|
|
width: 60px;
|
|
height: 60px;
|
|
object-fit: cover;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.btn-pastel {
|
|
background-color: rgb(148, 186, 204);
|
|
border: none;
|
|
transition: background-color 0.3s ease;
|
|
}
|
|
|
|
.btn-pastel:hover {
|
|
background-color: rgb(155, 189, 221);
|
|
}
|
|
|
|
h5,
|
|
h6 {
|
|
font-family: 'Poppins', sans-serif;
|
|
color: #333;
|
|
}
|
|
|
|
.order-item-details p {
|
|
margin: 0;
|
|
font-size: 0.9rem;
|
|
color: #555;
|
|
}
|
|
|
|
.order-item-details .price {
|
|
font-weight: bold;
|
|
color: #28a745;
|
|
}
|
|
|
|
.total-section {
|
|
background-color: rgb(148, 186, 204);
|
|
color: #fff;
|
|
padding: 10px;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.success-icon {
|
|
font-size: 3rem;
|
|
color: #28a745;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="wrapper">
|
|
<?php include('include/navbar.php'); ?>
|
|
<?php include('include/topbar.php'); ?>
|
|
<div class="page-wrapper">
|
|
<div class="page-content">
|
|
<div class="card card-pastel radius-10 mb-4">
|
|
<div class="card-body text-center">
|
|
<?php if ($school): ?>
|
|
<h5 class="mb-3">Grazie per il tuo acquisto! - Scuola: <?php echo htmlspecialchars($school_name); ?></h5>
|
|
<img src="<?php echo $school_logo_path; ?>" alt="School Logo" style="max-height: 100px;">
|
|
<?php else: ?>
|
|
<h5 class="mb-3">Grazie per il tuo acquisto!</h5>
|
|
<img src="<?php echo $school_logo_path; ?>" alt="Default Logo" style="max-height: 100px;">
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="card card-pastel radius-10">
|
|
<div class="card-header">
|
|
<div class="d-flex align-items-center">
|
|
<div>
|
|
<h6 class="mb-0">Riepilogo Ordine #<?php echo $order_number; ?></h6>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body text-center">
|
|
<i class="bx bx-check-circle success-icon mb-3"></i>
|
|
<h5 class="mb-3">Acquisto Completato con Successo!</h5>
|
|
<p class="text-muted">Ordine effettuato il <?php echo date('d/m/Y H:i', strtotime($order_date)); ?></p>
|
|
<div class="order-items-list">
|
|
<?php foreach ($order_items as $item): ?>
|
|
<div class="order-item-card d-flex align-items-center">
|
|
<img src="<?php echo htmlspecialchars($item['class_photo'] ?: 'default_class_image.jpg'); ?>" class="order-item-image me-3" alt="product image">
|
|
<div class="order-item-details flex-grow-1">
|
|
<h6 class="mb-1"><?php echo htmlspecialchars($item['product_name']); ?></h6>
|
|
<p><strong>Variazione:</strong> <?php echo htmlspecialchars($item['variation_name']); ?></p>
|
|
<p><strong>Classe:</strong> <?php echo htmlspecialchars($item['class_name'] . ' - ' . $item['level'] . ' (' . $item['day_of_week'] . ')'); ?></p>
|
|
<p><strong>Entrate Totali:</strong> <?php echo $item['total_entries']; ?></p>
|
|
<p class="price"><strong>Prezzo:</strong> €<?php echo number_format($item['price'], 2); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="total-section mt-3 d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Totale</h5>
|
|
<h5 class="mb-0">€<?php echo number_format($total_price, 2); ?></h5>
|
|
</div>
|
|
<div class="text-center mt-4">
|
|
<a href="index.php" class="btn btn-pastel">Torna alla Home</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="overlay toggle-icon"></div>
|
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
|
<?php include('include/footer.php'); ?>
|
|
</div>
|
|
<?php include('jsinclude.php'); ?>
|
|
</body>
|
|
|
|
</html>
|