yogiboook_new/public/userarea/shop-school.php

200 lines
7.6 KiB
PHP

<?php include('include/headscript.php'); ?>
<?php
// Ottieni l'istanza del DBHandlerSelect
$dbHandler = DBHandlerSelect::getInstance();
$pdo = $dbHandler->getConnection();
// Recupera lo school_id dalla sessione
$school_id = session('school_id');
$school = null;
$school_name = 'Nessuna scuola selezionata';
$school_logo_path = url('userarea/photoschool/yogibook_logo.png'); // Default logo
if ($school_id) {
// Usa il modello School per recuperare i dati della scuola
$school = \Vanguard\Models\School::find($school_id);
if ($school) {
$school_name = $school->name;
$school_logo_path = $school->logo ? url('userarea/' . $school->logo) : $school_logo_path;
}
}
// Recupera i prodotti con le variazioni e le classi associate, filtrati per scuola
$products = [];
if ($school_id) {
$stmt = $pdo->prepare("
SELECT p.id, p.name AS product_name,
MIN(pv.price) AS min_price,
MAX(pv.price) AS max_price,
c.name AS class_name,
c.photo AS class_photo
FROM products p
LEFT JOIN product_variations pv ON p.id = pv.product_id
LEFT JOIN product_class_types pct ON p.id = pct.product_id AND pct.variation_id IS NULL
LEFT JOIN class_types ct ON pct.class_type_id = ct.id
LEFT JOIN classes c ON ct.class_id = c.id
WHERE p.school_id = ? AND p.status = 'active'
GROUP BY p.id
");
$stmt->execute([$school_id]);
$products = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--favicon-->
<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;
/* Sfondo pastello chiaro (grigio-azzurro) */
}
.card-pastel {
background-color: rgb(149, 217, 248);
/* Celeste pastello */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
/* Ombra leggera */
border: none;
}
.product-card {
background-color: #ffffff;
border-left: 4px solid #c8e6c9;
/* Verde pastello per il bordo */
transition: transform 0.2s ease;
}
.product-card:hover {
transform: translateY(-3px);
}
.product-card img {
width: 100%;
height: 200px;
object-fit: cover;
}
.btn-pastel {
background-color: rgb(148, 186, 204);
/* Celeste pastello */
border: none;
transition: background-color 0.3s ease;
}
.btn-pastel:hover {
background-color: rgb(155, 189, 221);
/* Celeste più scuro */
}
h5,
h6 {
font-family: 'Poppins', sans-serif;
color: #333;
}
.price-range {
font-size: 1.1rem;
color: #28a745;
margin-bottom: 10px;
}
</style>
</head>
<body>
<!--wrapper-->
<div class="wrapper">
<!--sidebar wrapper -->
<?php include('include/navbar.php'); ?>
<!--end sidebar wrapper -->
<!--start header -->
<?php include('include/topbar.php'); ?>
<!--end header -->
<!--start page wrapper -->
<div class="page-wrapper">
<div class="page-content">
<!-- Sezione Scuola -->
<div class="card card-pastel radius-10 mb-4">
<div class="card-body text-center">
<?php if ($school): ?>
<h5 class="mb-3">Shop della 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">Nessuna scuola selezionata</h5>
<img src="<?php echo $school_logo_path; ?>" alt="Default Logo" style="max-height: 100px;">
<?php endif; ?>
</div>
</div>
<!-- Sezione Prodotti -->
<div class="card card-pastel radius-10">
<div class="card-header">
<div class="d-flex align-items-center">
<div>
<h6 class="mb-0">Acquista un Prodotto</h6>
</div>
</div>
</div>
<div class="card-body">
<?php if (empty($products)): ?>
<p class="text-center text-muted">Nessun prodotto disponibile per questa scuola.</p>
<?php else: ?>
<div class="row">
<?php foreach ($products as $product): ?>
<div class="col-12 col-md-6 col-lg-4 mb-3">
<div class="card product-card radius-10">
<img src="<?php echo htmlspecialchars($product['class_photo'] ?: 'default_class_image.jpg'); ?>" alt="<?php echo htmlspecialchars($product['class_name']); ?>">
<div class="card-body text-center">
<h6 class="card-title"><?php echo htmlspecialchars($product['product_name']); ?></h6>
<p class="price-range">
<?php
if ($product['min_price'] == $product['max_price']) {
echo htmlspecialchars($product['min_price']) . '€';
} else {
echo htmlspecialchars($product['min_price']) . '€ - ' . htmlspecialchars($product['max_price']) . '€';
}
?>
</p>
<p class="text-muted"><?php echo htmlspecialchars($product['class_name'] ?: 'Classe non specificata'); ?></p>
<a href="product_detail.php?product_id=<?php echo $product['id']; ?>" class="btn btn-pastel btn-sm">Dettagli</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!--end page wrapper -->
<!--start overlay-->
<div class="overlay toggle-icon"></div>
<!--end overlay-->
<!--Start Back To Top Button-->
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
<!--End Back To Top Button-->
<?php include('include/footer.php'); ?>
</div>
<!--end wrapper-->
<!-- search modal -->
<?php //include('include/searchmodal.php');
?>
<!-- end search modal -->
<!--start switcher-->
<?php //include('include/themeswitcher.php');
?>
<!--end switcher-->
<?php include('jsinclude.php'); ?>
</body>
</html>