getConnection(); function e($v): string { return htmlspecialchars((string) $v, ENT_QUOTES, 'UTF-8'); } $id = (int) ($_GET['idbookingclass'] ?? 0); $token = preg_replace('/[^a-zA-Z0-9\-]/', '', (string) ($_GET['token'] ?? '')); $bk = null; if ($id > 0 && $token !== '') { $st = $pdo->prepare( "SELECT bc.idbookingclass, bc.idschool, bc.iduser, bc.status, ss.dateschedule, s.servicename, ob.expireon, au.email, au.first_name FROM bookingclass bc JOIN serviceschedule ss ON ss.idserviceschedule = bc.idserviceschedule LEFT JOIN service s ON s.idservice = bc.idservice LEFT JOIN orderbook ob ON ob.idorderbook = bc.idorder LEFT JOIN auth_users au ON au.id = bc.iduser WHERE bc.idbookingclass = ? AND bc.cancellation_token = ?" ); $st->execute([$id, $token]); $bk = $st->fetch() ?: null; } $school = null; if ($bk) { $st = $pdo->prepare("SELECT * FROM schools WHERE idschool = ?"); $st->execute([(int) $bk['idschool']]); $school = $st->fetch() ?: null; } $state = 'ask'; // ask | done | invalid | toolate $message = ''; if (!$bk || !$school || $bk['status'] !== 'booked') { $state = 'invalid'; } elseif (!BookingRules::canCancel($bk['dateschedule'])) { $state = 'toolate'; } elseif (($_GET['action'] ?? '') === 'cancel') { $upd = $pdo->prepare( "UPDATE bookingclass SET status = 'cancelled' WHERE idbookingclass = ? AND cancellation_token = ? AND status = 'booked'" ); $upd->execute([$id, $token]); if ($upd->rowCount() > 0) { $lines = [ 'La tua lezione ' . e($bk['servicename'] ?: 'Lezione') . ' del ' . date('d-m-Y H:i', strtotime($bk['dateschedule'])) . ' è stata cancellata.', ]; if (!empty($bk['expireon'])) { $lines[] = 'Ricordati di riprenotarla entro la scadenza del tuo pacchetto: ' . date('d-m-Y', strtotime($bk['expireon'])) . '.'; } SchoolMail::toStudent((string) $bk['email'], (string) $bk['first_name'], 'Lezione cancellata', $lines, '', $school, true); } $state = 'done'; } $when = $bk ? date('d-m-Y H:i', strtotime($bk['dateschedule'])) : ''; $expiry = ($bk && !empty($bk['expireon'])) ? date('d-m-Y', strtotime($bk['expireon'])) : null; $schName = $school['name'] ?? 'YogiBook'; $baseQs = 'idbookingclass=' . $id . '&token=' . urlencode($token); ?> <?php echo e($schName); ?> - Gestione lezione

Link non valido

Il link non è valido oppure la lezione è già stata cancellata o spostata.

Cancellazione non più possibile

Il termine per cancellare o spostare questa lezione è scaduto.

Lezione cancellata

Ricordati di riprenotarla entro il .

Cosa vuoi fare con questa lezione?

Pacchetto valido fino al

Sposta la lezione
Vai alle tue lezioni