future lessons

This commit is contained in:
2025-12-23 09:39:59 +01:00
parent 67cc0742ff
commit b592be5831
9 changed files with 790 additions and 28 deletions
+66 -9
View File
@@ -125,7 +125,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['school_id'])) {
|--------------------------------------------------------------------------
*/
$stmt = $pdo->prepare("
SELECT s.id, s.name, s.logo, s.address_city
SELECT
s.id,
s.name,
s.logo,
s.address_street,
s.address_postal_code,
s.address_city,
s.address_province,
s.address_country
FROM user_schools us
JOIN schools s ON us.school_id = s.id
WHERE us.user_id = ?
@@ -133,6 +141,7 @@ $stmt = $pdo->prepare("
AND s.status = 'active'
ORDER BY s.name
");
$stmt->execute([$iduserlogin]);
$userSchools = $stmt->fetchAll();
// --- VALIDAZIONE school_id: se non appartiene all'utente, la resetto ---
@@ -180,7 +189,15 @@ if (count($userSchools) > 1 && !empty($_SESSION['school_id']) && !empty($_SESSIO
*/
if (empty($userSchools)) {
$stmt = $pdo->query("
SELECT id, name, logo, address_city
SELECT
id,
name,
logo,
address_street,
address_postal_code,
address_city,
address_province,
address_country
FROM schools
WHERE status = 'active'
ORDER BY name
@@ -346,12 +363,46 @@ if (empty($userSchools)) {
<?php
$sid = (int)$school['id'];
$sname = $school['name'] ?? '';
$scity = $school['address_city'] ?? '';
$street = trim($school['address_street'] ?? '');
$zip = trim($school['address_postal_code'] ?? '');
$city = trim($school['address_city'] ?? '');
$prov = trim($school['address_province'] ?? '');
$country = trim($school['address_country'] ?? '');
// Riga 1: Via...
$addrLine1 = $street;
// Riga 2: CAP Città (PR) - Nazione
$addrLine2Parts = [];
if ($zip !== '') $addrLine2Parts[] = $zip;
if ($city !== '') $addrLine2Parts[] = $city;
$addrLine2 = implode(' ', $addrLine2Parts);
if ($prov !== '') $addrLine2 .= ' (' . $prov . ')';
if ($country !== '') $addrLine2 .= ' - ' . $country;
$logoPath = null;
if (!empty($school['logo']) && file_exists("photoschool/" . $school['logo'])) {
$logoPath = "photoschool/" . $school['logo'];
$logoRaw = trim((string)($school['logo'] ?? ''));
if ($logoRaw !== '') {
// se in DB è già tipo "photoschool/xxx.jpg" lo uso così com'è
$logoRel = ltrim($logoRaw, '/'); // evita "/photoschool/..." (leading slash)
// controllo file su disco con path reali (stessa cartella o un livello sopra)
$disk1 = __DIR__ . '/' . $logoRel;
$disk2 = __DIR__ . '/../' . $logoRel;
if (is_file($disk1)) {
$logoPath = $logoRel;
} elseif (is_file($disk2)) {
$logoPath = '../' . $logoRel;
} else {
// fallback: provo comunque a mostrarlo (magari esiste via web path)
$logoPath = $logoRel;
}
}
?>
<div class="col-md-6 col-lg-4">
<div class="card school-card h-100 shadow-sm" onclick="selectSchool(<?= $sid ?>)">
@@ -371,11 +422,17 @@ if (empty($userSchools)) {
<div class="card-body text-center pb-4">
<h5 class="card-title mb-2"><?= htmlspecialchars($sname) ?></h5>
<?php if (!empty($scity)): ?>
<p class="text-muted small mb-0">
<i class="bx bx-map me-1"></i><?= htmlspecialchars($scity) ?>
</p>
<?php if (!empty($addrLine1) || !empty($addrLine2)): ?>
<div class="text-muted small mb-0">
<div>
<i class="bx bx-map me-1"></i><?= htmlspecialchars($addrLine1) ?>
</div>
<?php if (!empty($addrLine2)): ?>
<div><?= htmlspecialchars($addrLine2) ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="card-footer bg-transparent border-0 pt-0 pb-4 px-4">