api settings user e school
This commit is contained in:
@@ -1,3 +1,45 @@
|
||||
<?php
|
||||
// Recupera logo e nome scuola corrente (da sessione)
|
||||
$school_logo_path = null;
|
||||
$school_display_name = 'Nessuna scuola selezionata';
|
||||
|
||||
if (!empty($_SESSION['school_id'])) {
|
||||
$school_id = (int)$_SESSION['school_id'];
|
||||
|
||||
$stmt_school = $pdo->prepare("SELECT name, logo FROM schools WHERE id = ?");
|
||||
$stmt_school->execute([$school_id]);
|
||||
$current_school = $stmt_school->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($current_school) {
|
||||
$school_display_name = $current_school['name'];
|
||||
|
||||
$logoRaw = trim($current_school['logo'] ?? '');
|
||||
if (!empty($logoRaw)) {
|
||||
$physicalPath = __DIR__ . '/../' . $logoRaw; // adatta path se necessario
|
||||
if (file_exists($physicalPath)) {
|
||||
$school_logo_path = '/' . $logoRaw; // path web root-relative
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<style>
|
||||
.school-info {
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.school-info img {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.school-info .fw-bold {
|
||||
color: #343a40;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
<div class="sidebar-wrapper" data-simplebar="true">
|
||||
<div class="sidebar-header">
|
||||
<div>
|
||||
@@ -11,6 +53,25 @@
|
||||
</div>
|
||||
<!--navigation-->
|
||||
<ul class="metismenu" id="menu">
|
||||
<!-- Logo e nome scuola corrente -->
|
||||
<!-- Logo e nome scuola corrente (rettangolare, naturale) -->
|
||||
<div class="school-info text-center py-3 px-2 border-bottom">
|
||||
<?php if ($logoRaw): ?>
|
||||
<img src="<?= htmlspecialchars($logoRaw) ?>"
|
||||
alt="Logo <?= htmlspecialchars($school_display_name) ?>"
|
||||
class="img-fluid mb-2"
|
||||
style="max-height: 80px; width: auto; object-fit: contain; border-radius: 8px; border: 1px solid #e9ecef; box-shadow: 0 2px 6px rgba(0,0,0,0.08);">
|
||||
<?php else: ?>
|
||||
<div class="bg-light d-inline-block p-3 mb-2 rounded-3" style="width: 60px; height: 60px;">
|
||||
<i class="bx bx-building-house bx-md text-muted"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="fw-bold text-truncate" style="font-size: 1rem; max-width: 180px; margin: 0 auto;">
|
||||
<?= htmlspecialchars($school_display_name) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<li class="menu-label">Utente</li>
|
||||
<li>
|
||||
<a href="user_dashboard.php">
|
||||
@@ -18,6 +79,12 @@
|
||||
<div class="menu-title">Dashboard Utente</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="my_lessons.php">
|
||||
<div class="parent-icon"><i class="bx bx-store"></i></div>
|
||||
<div class="menu-title">Le mie prenotazioni</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="my_certificates.php">
|
||||
<div class="parent-icon"><i class="bx bx-store"></i></div>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// include/user_settings_loader.php
|
||||
|
||||
// Evita inclusioni multiple
|
||||
if (defined('USER_SETTINGS_LOADED')) return;
|
||||
define('USER_SETTINGS_LOADED', true);
|
||||
|
||||
global $userSettings; // o usa $_SESSION['user_settings'] se preferisci
|
||||
|
||||
$user_id = (int)($iduserlogin ?? $_SESSION['iduserlogin'] ?? 0);
|
||||
|
||||
if ($user_id <= 0) {
|
||||
// Utente non loggato → valori di default minimi/sicuri
|
||||
$userSettings = [
|
||||
'notify_email' => 1,
|
||||
'notify_whatsapp' => 0,
|
||||
'notify_push' => 0,
|
||||
'notify_booking_confirm' => 1,
|
||||
'notify_booking_cancel' => 1,
|
||||
'notify_session_cancel' => 1,
|
||||
'notify_payment_receipt' => 1,
|
||||
'notify_expiration_reminder' => 1,
|
||||
'newsletter_opt_in' => 0,
|
||||
'marketing_opt_in' => 0,
|
||||
'locale' => 'it',
|
||||
'timezone' => 'Europe/Rome',
|
||||
];
|
||||
} else {
|
||||
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT *
|
||||
FROM user_settings
|
||||
WHERE user_id = ?
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute([$user_id]);
|
||||
$settings = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($settings) {
|
||||
$userSettings = $settings;
|
||||
} else {
|
||||
// Utente senza impostazioni → crea record con default
|
||||
$stmt_insert = $pdo->prepare("
|
||||
INSERT INTO user_settings (user_id) VALUES (?)
|
||||
");
|
||||
$stmt_insert->execute([$user_id]);
|
||||
|
||||
// Ricarica dopo insert
|
||||
$stmt = $pdo->prepare("SELECT * FROM user_settings WHERE user_id = ? LIMIT 1");
|
||||
$stmt->execute([$user_id]);
|
||||
$userSettings = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
|
||||
}
|
||||
|
||||
// Fallback per campi che potrebbero essere NULL o mancanti
|
||||
$userSettings = array_merge([
|
||||
'notify_email' => 1,
|
||||
'notify_whatsapp' => 0,
|
||||
'notify_push' => 0,
|
||||
'notify_booking_confirm' => 1,
|
||||
'notify_booking_cancel' => 1,
|
||||
'notify_session_cancel' => 1,
|
||||
'notify_payment_receipt' => 1,
|
||||
'notify_expiration_reminder' => 1,
|
||||
'newsletter_opt_in' => 0,
|
||||
'marketing_opt_in' => 0,
|
||||
'locale' => 'it',
|
||||
'timezone' => 'Europe/Rome',
|
||||
], $userSettings);
|
||||
}
|
||||
Reference in New Issue
Block a user