Selettore scuola in tutte le pagine

This commit is contained in:
2026-10-03 19:02:07 +02:00
parent 28222ee7f1
commit 8441cc702c
34 changed files with 587 additions and 334 deletions
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddSuperadminAndSchoolRoles extends AbstractMigration
{
public function up(): void
{
// 1) Flag superadmin di piattaforma (gestore del portale)
$this->table('auth_users')
->addColumn('is_superadmin', 'char', [
'limit' => 1,
'default' => 'N',
'null' => false,
'comment' => 'Y = gestore piattaforma, vede tutte le scuole',
])
->update();
// 2) Ruoli nella scuola 1 ricavati dai ruoli Vanguard attuali
$this->execute("
UPDATE school_user su
JOIN auth_users u ON u.id = su.user_id
JOIN auth_roles r ON r.id = u.role_id
SET su.school_role = CASE
WHEN LOWER(r.name) = 'admin' THEN 'admin'
WHEN LOWER(r.name) = 'teacher' THEN 'teacher'
ELSE 'student'
END
WHERE su.idschool = 1
");
}
public function down(): void
{
$this->execute("UPDATE school_user SET school_role = 'student' WHERE idschool = 1");
$this->table('auth_users')
->removeColumn('is_superadmin')
->update();
}
}
+1 -1
View File
@@ -328,7 +328,7 @@ function teacherOptions(array $teachers, int $selectedId): string
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -535,7 +535,7 @@ $italianMonths = [
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -221,7 +221,7 @@ $associatedClasses = $stmtAssoc->fetchAll();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -400,7 +400,7 @@ $conn->close();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -450,7 +450,7 @@ $conn->close();
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon"
+1 -1
View File
@@ -195,7 +195,7 @@ $today = date('Y-m-d');
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+171 -42
View File
@@ -1,13 +1,17 @@
<?php
/**
* SchoolContext
* Determina la scuola corrente dell'utente loggato e la rende disponibile
* a tutte le pagine (via headscript).
* SchoolContext v2
* Determina la scuola corrente dell'utente loggato, il suo ruolo nella scuola
* e le scuole tra cui può passare (owner multi-scuola, superadmin).
*
* Uso:
* $school = SchoolContext::resolve((int)$iduserlogin);
* $idschool = SchoolContext::id();
* Uso (nella headscript):
* $schoolData = SchoolContext::resolve((int)$iduserlogin);
* $idschool = SchoolContext::id();
*
* Ruoli scuola: owner | admin | teacher | student
* Il superadmin di piattaforma (auth_users.is_superadmin = 'Y') può entrare
* in qualsiasi scuola: se non ne è membro, il suo ruolo risulta 'superadmin'.
*/
if (!class_exists('DBHandlerSelect')) {
@@ -19,49 +23,53 @@ class SchoolContext
/** Scuola di fallback durante la fase monoscuola (Seregno) */
const DEFAULT_SCHOOL = 1;
/** @var array|null dati della scuola corrente (riga schools + school_role) */
/** @var array|null scuola corrente (riga schools + school_role) */
private static $school = null;
/**
* Risolve la scuola corrente per l'utente indicato.
* Chiamare una sola volta per richiesta (nella headscript).
*/
/** @var int */
private static $userId = 0;
/** @var bool */
private static $superadmin = false;
/** @var array scuole di cui l'utente è membro */
private static $memberships = [];
/* ------------------------------------------------------------------ */
public static function resolve(int $userId): array
{
if (self::$school !== null) {
return self::$school;
}
$pdo = DBHandlerSelect::getInstance()->getConnection();
$pdo = self::pdo();
self::$userId = $userId;
$schools = self::userSchools($pdo, $userId);
$st = $pdo->prepare("SELECT is_superadmin FROM auth_users WHERE id = ?");
$st->execute([$userId]);
self::$superadmin = ($st->fetchColumn() === 'Y');
self::$memberships = self::loadMemberships($userId);
// TEMPORANEO (fase monoscuola): utente senza scuola -> agganciato a Seregno
if (empty($schools)) {
$stmt = $pdo->prepare(
if (empty(self::$memberships) && !self::$superadmin) {
$ins = $pdo->prepare(
"INSERT IGNORE INTO school_user (user_id, idschool, school_role)
VALUES (?, ?, 'student')"
);
$stmt->execute([$userId, self::DEFAULT_SCHOOL]);
$schools = self::userSchools($pdo, $userId);
$ins->execute([$userId, self::DEFAULT_SCHOOL]);
self::$memberships = self::loadMemberships($userId);
}
if (empty($schools)) {
$requested = isset($_SESSION['idschool']) ? (int) $_SESSION['idschool'] : 0;
$selected = self::pick($requested);
if ($selected === null) {
http_response_code(403);
die('Nessuna scuola attiva associata a questo account.');
}
// Scuola richiesta in sessione: accettata solo se l'utente ne fa parte
$requested = isset($_SESSION['idschool']) ? (int) $_SESSION['idschool'] : 0;
$selected = $schools[0];
foreach ($schools as $row) {
if ((int) $row['idschool'] === $requested) {
$selected = $row;
break;
}
}
$selected['idschool'] = (int) $selected['idschool'];
$_SESSION['idschool'] = $selected['idschool'];
@@ -69,16 +77,55 @@ class SchoolContext
return self::$school;
}
/** ID della scuola corrente */
public static function id(): int
/**
* Cambia scuola corrente. Ritorna false se l'utente non può accedervi.
*/
public static function switchTo(int $idschool): bool
{
if (self::$school === null) {
throw new RuntimeException('SchoolContext::resolve() non ancora chiamato');
if ($idschool <= 0) {
return false;
}
return self::$school['idschool'];
foreach (self::available() as $s) {
if ((int) $s['idschool'] === $idschool) {
$_SESSION['idschool'] = $idschool;
self::$school = null;
self::resolve(self::$userId);
return true;
}
}
return false;
}
/**
* Scuole tra cui l'utente può scegliere (per il selettore in topbar).
* Superadmin: tutte le scuole. Altri: solo quelle di cui è membro.
*/
public static function available(): array
{
if (!self::$superadmin) {
return self::$memberships;
}
$roles = [];
foreach (self::$memberships as $m) {
$roles[(int) $m['idschool']] = $m['school_role'];
}
$all = self::pdo()->query("SELECT * FROM schools ORDER BY name")->fetchAll();
foreach ($all as &$s) {
$s['school_role'] = $roles[(int) $s['idschool']] ?? 'superadmin';
}
unset($s);
return $all;
}
/* --------------------------- getter -------------------------------- */
public static function id(): int
{
return self::get()['idschool'];
}
/** Dati completi della scuola corrente */
public static function get(): array
{
if (self::$school === null) {
@@ -87,25 +134,107 @@ class SchoolContext
return self::$school;
}
/** Ruolo dell'utente nella scuola corrente: student|teacher|admin|owner */
/** owner | admin | teacher | student | superadmin */
public static function role(): string
{
return self::get()['school_role'];
}
/** Scuole attive a cui l'utente è iscritto */
private static function userSchools(PDO $pdo, int $userId): array
public static function isSuperadmin(): bool
{
$stmt = $pdo->prepare(
return self::$superadmin;
}
public static function isOwner(): bool
{
return self::role() === 'owner';
}
/** Può gestire la scuola: owner, admin o superadmin */
public static function isSchoolAdmin(): bool
{
return self::$superadmin || in_array(self::role(), ['owner', 'admin'], true);
}
/** Staff della scuola: amministratori + insegnanti */
public static function isStaff(): bool
{
return self::isSchoolAdmin() || self::role() === 'teacher';
}
/** Blocca la pagina se l'utente non è amministratore della scuola */
public static function requireSchoolAdmin(): void
{
if (!self::isSchoolAdmin()) {
http_response_code(403);
die('Accesso non autorizzato.');
}
}
/** Blocca la pagina se l'utente non è superadmin */
public static function requireSuperadmin(): void
{
if (!self::$superadmin) {
http_response_code(403);
die('Accesso non autorizzato.');
}
}
/* --------------------------- interni ------------------------------- */
private static function pick(int $requested): ?array
{
// 1) scuola richiesta e l'utente ne è membro
foreach (self::$memberships as $m) {
if ((int) $m['idschool'] === $requested) {
return $m;
}
}
// 2) superadmin: può entrare in qualunque scuola esistente
if (self::$superadmin) {
$pdo = self::pdo();
if ($requested > 0) {
$st = $pdo->prepare("SELECT * FROM schools WHERE idschool = ?");
$st->execute([$requested]);
$row = $st->fetch();
if ($row) {
$row['school_role'] = 'superadmin';
return $row;
}
}
if (!empty(self::$memberships)) {
return self::$memberships[0];
}
$row = $pdo->query("SELECT * FROM schools ORDER BY idschool LIMIT 1")->fetch();
if ($row) {
$row['school_role'] = 'superadmin';
return $row;
}
return null;
}
// 3) prima scuola di cui è membro
return self::$memberships[0] ?? null;
}
private static function loadMemberships(int $userId): array
{
$st = self::pdo()->prepare(
"SELECT s.*, su.school_role
FROM school_user su
JOIN schools s ON s.idschool = su.idschool
WHERE su.user_id = ?
AND su.active = 'Y'
AND s.status <> 'suspended'
ORDER BY su.idschool"
ORDER BY s.name"
);
$stmt->execute([$userId]);
return $stmt->fetchAll();
$st->execute([$userId]);
return $st->fetchAll();
}
private static function pdo(): PDO
{
return DBHandlerSelect::getInstance()->getConnection();
}
}
+2 -3
View File
@@ -461,7 +461,7 @@ $insertedCount = isset($_GET['n']) ? (int) $_GET['n'] : null;
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
@@ -692,8 +692,7 @@ $insertedCount = isset($_GET['n']) ? (int) $_GET['n'] : null;
Swal.fire({
title: sameDay ? 'Aggiungere questo giorno?' : 'Aggiungere questo periodo?',
html: sameDay ?
'Vuoi impostare come pausa il giorno <strong>' + labelFor(a) + '</strong>?' :
'Vuoi impostare come pausa tutti i giorni da <strong>' + labelFor(a) + '</strong> a <strong>' + labelFor(b) + '</strong>?',
'Vuoi impostare come pausa il giorno <strong>' + labelFor(a) + '</strong>?' : 'Vuoi impostare come pausa tutti i giorni da <strong>' + labelFor(a) + '</strong> a <strong>' + labelFor(b) + '</strong>?',
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#1ebf73',
+1 -1
View File
@@ -340,7 +340,7 @@ $pageTitle = $isEdit ? 'Modifica evento' : 'Nuovo evento';
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -235,7 +235,7 @@ $isEdit = $editId > 0 && $edit;
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -138,7 +138,7 @@ $types = [
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -297,7 +297,7 @@ function bookingBadge(string $status): array
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -124,7 +124,7 @@ $message = $_GET['message'] ?? '';
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -306,7 +306,7 @@ function statusBadge(string $status): array
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+3
View File
@@ -58,6 +58,9 @@ require_once('class/SchoolContext.php');
$schoolData = SchoolContext::resolve((int) $iduserlogin);
$idschool = SchoolContext::id();
$schoolname = $schoolData['name'];
$schoolrole = SchoolContext::role(); // owner|admin|teacher|student|superadmin
$isschooladmin = SchoolContext::isSchoolAdmin();
$issuperadmin = SchoolContext::isSuperadmin();
// ------------------------------
if (!isset($_SESSION["tempcode"])) {
$timestampnow = time();
+1 -1
View File
@@ -147,7 +147,7 @@ $conn->close();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="bx bx-search icon-sm align-middle"></i>
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* Selettore scuola in topbar.
* Visibile solo se l'utente ha accesso a più di una scuola.
* Include: <?php include('include/schoolswitcher.php'); ?>
*/
$__schools = SchoolContext::available();
if (count($__schools) > 1) :
if (empty($_SESSION['csrf_switch'])) {
$_SESSION['csrf_switch'] = bin2hex(random_bytes(16));
}
$__current = SchoolContext::get();
$__roleLabels = [
'owner' => 'Titolare',
'admin' => 'Admin',
'teacher' => 'Insegnante',
'student' => 'Allievo',
'superadmin' => 'Superadmin',
];
?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Cambia scuola">
<i class="bx bx-buildings font-size-20 align-middle"></i>
<span class="d-none d-xl-inline-block ms-1 fw-semibold"><?php echo htmlspecialchars($__current['name'], ENT_QUOTES, 'UTF-8'); ?></span>
<i class="bx bx-chevron-down d-none d-xl-inline-block"></i>
</button>
<div class="dropdown-menu dropdown-menu-end" style="min-width: 260px;">
<h6 class="dropdown-header">Le tue scuole</h6>
<?php foreach ($__schools as $__s) :
$__isCurrent = ((int) $__s['idschool'] === (int) $__current['idschool']);
$__role = $__roleLabels[$__s['school_role']] ?? $__s['school_role'];
?>
<form method="post" action="switchschool.php" class="m-0">
<input type="hidden" name="idschool" value="<?php echo (int) $__s['idschool']; ?>">
<input type="hidden" name="token" value="<?php echo $_SESSION['csrf_switch']; ?>">
<button type="submit" class="dropdown-item d-flex justify-content-between align-items-center <?php echo $__isCurrent ? 'active' : ''; ?>" <?php echo $__isCurrent ? 'disabled' : ''; ?>>
<span><?php echo htmlspecialchars($__s['name'], ENT_QUOTES, 'UTF-8'); ?></span>
<span class="badge rounded-pill bg-light text-dark ms-2"><?php echo htmlspecialchars($__role, ENT_QUOTES, 'UTF-8'); ?></span>
</button>
</form>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
+1 -1
View File
@@ -487,7 +487,7 @@ $teachers = $pdo->query("SELECT e.*,
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+264 -262
View File
@@ -1,12 +1,12 @@
<?php require_once('include/headscript.php'); ?>
<?php // optionquery
$optionquery = new WA_MySQLi_RS("optionquery",$bkngstm,0);
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
$optionquery->setQuery("SELECT * FROM option");
$optionquery->execute();
?>
<?php
// Crea la connessione al database
// Crea la connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
// Verifica se il modulo è stato inviato
if ($_SERVER["REQUEST_METHOD"] == "POST") {
@@ -19,7 +19,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Aggiorna i dati nella tabella auth_users
$sqlUpdate = "UPDATE auth_users SET classnotification = '$emailNotifications', ordernotification = '$orderNotifications' WHERE id = '$iduserlogin'";
if ($conn->query($sqlUpdate) === TRUE) {
// L'aggiornamento è stato completato con successo
// Puoi aggiungere un messaggio di successo qui se lo desideri
@@ -27,7 +27,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Gestisci l'errore in caso di errore nell'aggiornamento
echo "Errore nell'aggiornamento dei dati: " . $conn->error;
}
// Chiudi la connessione al database (assicurati di chiuderla correttamente)
$conn->close();
}
@@ -37,8 +37,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<?php
$iduser=$iduserlogin;
// Crea la connessione al database
$iduser = $iduserlogin;
// Crea la connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
// Verifica la connessione
@@ -49,309 +49,311 @@ if ($conn->connect_error) {
// Ottieni i dati dal database in base all'id dell'utente
// Ottieni i dati dal database in base all'id dell'utente
$sqldata = "SELECT * FROM auth_users WHERE id = '$iduserlogin'";
$resultdata = $conn->query($sqldata);
if ($resultdata->num_rows > 0) {
$rowdata = $resultdata->fetch_assoc();
$notificationmail=$rowdata['classnotification'];
$notificationmail = $rowdata['classnotification'];
$notificationorder = $rowdata['ordernotification'];
}
?>
<!doctype html>
<html lang="en">
<head>
<head>
<meta charset="utf-8" />
<title>YogiBook - Prenotazioni YogaSoul</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
<meta content="Advanced Creative Solutions" name="author" />
<!-- App favicon -->
<link rel="shortcut icon" href="assets/images/favicon.ico">
<meta charset="utf-8" />
<title>YogiBook - Prenotazioni YogaSoul</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
<meta content="Advanced Creative Solutions" name="author" />
<!-- App favicon -->
<link rel="shortcut icon" href="assets/images/favicon.ico">
<!-- Bootstrap Css -->
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<!-- App Css-->
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Bootstrap Css -->
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<!-- App Css-->
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function() {
$("#expiryDate").datepicker({ dateFormat: "yy-mm-dd" });
$("#expiryDate").datepicker({
dateFormat: "yy-mm-dd"
});
});
</script>
<style>
.custom-card {
margin: 10px auto;
display: flex;
width: 90%;
max-width: 700px;
background-color: white;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden;
cursor: pointer;
transition: transform 0.2s;
}
<style>
.custom-card {
margin: 10px auto;
display: flex;
width: 90%;
max-width: 700px;
background-color: white;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden;
cursor: pointer;
transition: transform 0.2s;
}
.custom-card:hover {
transform: translateY(-5px);
}
.custom-card:hover {
transform: translateY(-5px);
}
.custom-date-box {
flex: 1;
background-color: red;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0;
font-size: 60px;
font-weight: bold;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
}
.custom-date-box {
flex: 1;
background-color: red;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0;
font-size: 60px;
font-weight: bold;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
}
.custom-day {
line-height: 1;
}
.custom-day {
line-height: 1;
}
.custom-month {
font-size: 28px;
}
.custom-month {
font-size: 28px;
}
.custom-event-details {
flex: 2;
display: flex;
flex-direction: column;
padding: 10px 20px;
background-color: lightblue;
}
.custom-event-details {
flex: 2;
display: flex;
flex-direction: column;
padding: 10px 20px;
background-color: lightblue;
}
.custom-heading {
margin-top: 0;
font-size: 24px;
}
.custom-heading {
margin-top: 0;
font-size: 24px;
}
.custom-paragraph {
margin-bottom: 5px;
}
.custom-paragraph {
margin-bottom: 5px;
}
.custom-actions {
display: none;
flex-direction: row;
justify-content: space-between;
margin-top: 10px;
}
.custom-actions {
display: none;
flex-direction: row;
justify-content: space-between;
margin-top: 10px;
}
.custom-card.expanded .custom-actions {
display: flex;
}
.custom-card.expanded .custom-actions {
display: flex;
}
.custom-action-button {
background-color: #f0f0f0;
border: none;
padding: 8px 12px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
}
.custom-action-button {
background-color: #f0f0f0;
border: none;
padding: 8px 12px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
}
.custom-action-button:hover {
background-color: #e0e0e0;
}
.custom-action-button:hover {
background-color: #e0e0e0;
}
@media (max-width: 768px) {
.custom-card {
flex-direction: column;
}
@media (max-width: 768px) {
.custom-card {
flex-direction: column;
}
.custom-date-box, .custom-event-details {
width: 100%;
border-radius: 0;
}
.custom-date-box,
.custom-event-details {
width: 100%;
border-radius: 0;
}
.custom-event-time {
font-size: 24px;
}
}
</style>
<script>
function confirmDelete(id, deletePageUrl) {
Swal.fire({
title: "Sei sicuro?",
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#d33",
cancelButtonColor: "#3085d6",
confirmButtonText: "Sì, cancella!",
cancelButtonText: "Annulla"
}).then((result) => {
if (result.isConfirmed) {
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
window.location.href = `deleteclass.php?id=${id}`;
}
});
}
</script>
<body>
.custom-event-time {
font-size: 24px;
}
}
</style>
<script>
function confirmDelete(id, deletePageUrl) {
Swal.fire({
title: "Sei sicuro?",
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#d33",
cancelButtonColor: "#3085d6",
confirmButtonText: "Sì, cancella!",
cancelButtonText: "Annulla"
}).then((result) => {
if (result.isConfirmed) {
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
window.location.href = `deleteclass.php?id=${id}`;
}
});
}
</script>
<body>
<!-- <body data-layout="horizontal"> -->
<!-- Begin page -->
<div id="layout-wrapper">
<!-- Begin page -->
<div id="layout-wrapper">
<!-- Top Bar -->
<header id="page-topbar" class="isvertical-topbar">
<div class="navbar-header">
<div class="d-flex">
<!-- LOGO -->
<?php include('include/logoarea.php'); ?>
<!-- Top Bar -->
<header id="page-topbar" class="isvertical-topbar">
<div class="navbar-header">
<div class="d-flex">
<!-- LOGO -->
<?php include('include/logoarea.php'); ?>
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
<i class="bx bx-menu align-middle"></i>
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
<i class="bx bx-menu align-middle"></i>
</button>
<!-- start page title -->
<div class="page-title-box align-self-center d-none d-md-block">
<h4 class="page-title mb-0">Notifiche</h4>
</div>
<!-- end page title -->
</div>
<div class="d-flex">
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="bx bx-search icon-sm align-middle"></i>
</button>
<!-- start page title -->
<div class="page-title-box align-self-center d-none d-md-block">
<h4 class="page-title mb-0">Notifiche</h4>
</div>
<!-- end page title -->
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="bx bx-search icon-sm align-middle"></i>
</button>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
<form class="p-2">
<div class="search-box">
<div class="position-relative">
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
<i class="bx bx-search search-icon"></i>
</div>
</div>
</form>
</div>
</div>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
</header>
<?php include('include/sidebar.php'); ?>
<header class="ishorizontal-topbar">
<div class="navbar-header">
<div class="d-flex">
</div>
</div>
<div class="topnav">
<div class="container-fluid">
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
</nav>
</div>
</div>
</header>
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="main-content">
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<?php if (isset($message)) { ?>
<div class="alert alert-success" role="alert">
Preferenze aggiornate con successo
</div><?php } ?>
<p>Di seguito puoi modificare le preferenze di notifiche del sistema prenotazione YogiBook</p>
<div class="table-responsive">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form-check form-switch mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="emailNotifications" name="emailNotifications" value="Y" <?php echo $notificationmail === 'Y' ? 'checked' : ''; ?>>
<label class="form-check-label" for="emailNotifications">Notifiche prossime lezioni</label>
<p>Notifiche di reminder delle lezioni che hai prenotato</p>
</div>
<div class="form-check form-switch mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="orderNotifications" name="orderNotifications" value="Y" <?php echo $notificationorder === 'Y' ? 'checked' : ''; ?>>
<label class="form-check-label" for="orderNotifications">Notifiche ordini inseriti</label>
<p>Notifiche di reminder degli ordini che hai effettuato</p>
</div>
<input type="hidden" class="form-control" name="iduser" value="<?php echo $iduserlogin; ?>">
<input type="hidden" class="form-control" name="kind" value="insert">
<input type="hidden" class="form-control" name="message" value="Y">
<input type="submit" class="btn btn-primary w-md" name="submit" value="Aggiorna">
</form>
</div>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
<form class="p-2">
<div class="search-box">
<div class="position-relative">
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
<i class="bx bx-search search-icon"></i>
</div>
</div>
</form>
</div>
</div>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
</header>
<?php include('include/sidebar.php'); ?>
<header class="ishorizontal-topbar">
<div class="navbar-header">
<div class="d-flex">
</div>
</div>
<div class="topnav">
<div class="container-fluid">
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
</nav>
</div>
</div>
</header>
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="main-content">
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<?php if (isset($message)) { ?>
<div class="alert alert-success" role="alert">
Preferenze aggiornate con successo
</div><?php } ?>
<p>Di seguito puoi modificare le preferenze di notifiche del sistema prenotazione YogiBook</p>
<div class="table-responsive">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="form-check form-switch mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="emailNotifications" name="emailNotifications" value="Y" <?php echo $notificationmail === 'Y' ? 'checked' : ''; ?>>
<label class="form-check-label" for="emailNotifications">Notifiche prossime lezioni</label>
<p>Notifiche di reminder delle lezioni che hai prenotato</p>
</div>
<div class="form-check form-switch mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="orderNotifications" name="orderNotifications" value="Y" <?php echo $notificationorder === 'Y' ? 'checked' : ''; ?>>
<label class="form-check-label" for="orderNotifications">Notifiche ordini inseriti</label>
<p>Notifiche di reminder degli ordini che hai effettuato</p>
</div>
<input type="hidden" class="form-control" name="iduser" value="<?php echo $iduserlogin; ?>">
<input type="hidden" class="form-control" name="kind" value="insert">
<input type="hidden" class="form-control" name="message" value="Y">
<input type="submit" class="btn btn-primary w-md" name="submit" value="Aggiorna">
</form>
</div>
</div>
</div>
</div>
</div>
<!-- container-fluid -->
</div>
<?php include('include/footer.php'); ?>
</div>
@@ -360,11 +362,11 @@ if ($resultdata->num_rows > 0) {
</div>
<!-- END layout-wrapper -->
<!-- JAVASCRIPT -->
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
@@ -374,6 +376,6 @@ if ($resultdata->num_rows > 0) {
<script src="assets/js/app.js"></script>
</body>
</body>
</html>
+1 -1
View File
@@ -147,7 +147,7 @@ $conn->close();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="bx bx-search icon-sm align-middle"></i>
+1 -1
View File
@@ -112,7 +112,7 @@ $showTeacher = ($opt['show_teacher'] ?? 'N') === 'Y';
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -235,7 +235,7 @@ $services = $pdo->query("SELECT idservice, servicename, day, time FROM service O
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -386,7 +386,7 @@ unset($order);
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -184,7 +184,7 @@ $qParam = $q !== '' ? '&q=' . urlencode($q) : '';
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -201,7 +201,7 @@ $fmt = function ($dt) {
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -231,7 +231,7 @@ $conn->close();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -244,7 +244,7 @@ $users = $pdo->query($sql)->fetchAll();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -642,7 +642,7 @@ $periodLabel = date('d/m/Y', strtotime($from)) . ' – ' . date('d/m/Y', strtoti
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* Cambio scuola corrente (owner multi-scuola / superadmin).
* Riceve POST: idschool, token. Reindirizza alla pagina principale
* della nuova scuola (non alla pagina precedente, i cui ID
* appartenevano alla scuola di prima).
*/
require_once('include/headscript.php');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: adminpanel.php');
exit;
}
$token = $_POST['token'] ?? '';
if (empty($_SESSION['csrf_switch']) || !hash_equals($_SESSION['csrf_switch'], $token)) {
http_response_code(400);
die('Richiesta non valida.');
}
$target = (int) ($_POST['idschool'] ?? 0);
if (!SchoolContext::switchTo($target)) {
http_response_code(403);
die('Non hai accesso a questa scuola.');
}
$landing = SchoolContext::isStaff() ? 'adminpanel.php' : 'userpanel.php';
header('Location: ' . $landing);
exit;
+1 -1
View File
@@ -163,7 +163,7 @@ $result = $conn->query($query);
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<div class="dropdown d-inline-block">
<button type="button" class="btn header-item noti-icon"
+1 -1
View File
@@ -537,7 +537,7 @@ $italianMonths = [
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -286,7 +286,7 @@ $currentYear = date('Y');
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>
+1 -1
View File
@@ -307,7 +307,7 @@ $documents = $stmtDocs->fetchAll();
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?php include('include/schoolswitcher.php'); ?><?php include('include/languageselection.php'); ?>
<?php include('include/profiletopbar.php'); ?>
</div>
</div>