963 lines
48 KiB
PHP
963 lines
48 KiB
PHP
<?php require_once('include/headscript.php'); ?>
|
|
<?php
|
|
/**
|
|
* Connessione unica PDO riusata per tutta la pagina.
|
|
* DBHandlerSelect è un singleton: una sola connessione per richiesta.
|
|
* $iduserlogin arriva dalla sessione autenticata (headscript.php).
|
|
*/
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
|
|
// Forziamo l'id utente a intero: viene dalla sessione, ma è comunque
|
|
// buona norma non fidarsi mai e trattarlo come integer.
|
|
$iduserlogin = (int) $iduserlogin;
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* 1) Calcolo del mese da visualizzare
|
|
* ---------------------------------------------------------------------- */
|
|
if (isset($_GET['prev_month'])) {
|
|
$currentMonthStart = preg_replace('/[^0-9\-]/', '', $_GET['prev_month']) . '-01';
|
|
} elseif (isset($_GET['next_month'])) {
|
|
$currentMonthStart = preg_replace('/[^0-9\-]/', '', $_GET['next_month']) . '-01';
|
|
} else {
|
|
$currentMonthStart = date("Y-m-01");
|
|
}
|
|
|
|
// Validazione: se la stringa non è una data valida, torna al mese corrente
|
|
$ts = strtotime($currentMonthStart);
|
|
if ($ts === false) {
|
|
$currentMonthStart = date("Y-m-01");
|
|
}
|
|
|
|
$currentDate = date("Y-m-d");
|
|
|
|
// Se oggi è dopo l'inizio del mese scelto, parti da oggi
|
|
if ($currentDate > $currentMonthStart) {
|
|
$currentMonthStart = $currentDate;
|
|
}
|
|
|
|
$currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart));
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* 2) Lezioni prenotate nel range del mese
|
|
* ---------------------------------------------------------------------- */
|
|
$sqlBooked = "SELECT bookingclass.*, service.*, serviceschedule.*, orderbook.expireon
|
|
FROM bookingclass
|
|
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
|
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
|
LEFT JOIN orderbook ON bookingclass.idorder = orderbook.idorderbook
|
|
WHERE bookingclass.iduser = :iduser
|
|
AND bookingclass.status = 'booked'
|
|
AND serviceschedule.dateschedule BETWEEN :monthStart AND DATE_ADD(:monthEnd, INTERVAL 1 DAY)
|
|
ORDER BY serviceschedule.dateschedule";
|
|
|
|
$stmtBooked = $pdo->prepare($sqlBooked);
|
|
$stmtBooked->execute([
|
|
':iduser' => $iduserlogin,
|
|
':monthStart' => $currentMonthStart,
|
|
':monthEnd' => $currentMonthEnd,
|
|
]);
|
|
$bookedRows = $stmtBooked->fetchAll();
|
|
|
|
// Lezioni in attesa di conferma (pending) dell'utente, nel mese visualizzato
|
|
$sqlPending = "SELECT bookingclass.*, service.servicename, service.colorclass, service.idteacher, serviceschedule.dateschedule
|
|
FROM bookingclass
|
|
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
|
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
|
WHERE bookingclass.iduser = :iduser
|
|
AND bookingclass.status = 'pending'
|
|
AND serviceschedule.dateschedule BETWEEN :monthStart AND DATE_ADD(:monthEnd, INTERVAL 1 DAY)
|
|
ORDER BY serviceschedule.dateschedule";
|
|
$stmtPending = $pdo->prepare($sqlPending);
|
|
$stmtPending->execute([
|
|
':iduser' => $iduserlogin,
|
|
':monthStart' => $currentMonthStart,
|
|
':monthEnd' => $currentMonthEnd,
|
|
]);
|
|
$pendingRows = $stmtPending->fetchAll();
|
|
|
|
// Lezioni in lista d'attesa (waiting) dell'utente, nel mese visualizzato
|
|
$sqlWaiting = "SELECT bookingclass.*, service.servicename, service.colorclass, service.maxcapacity, service.idteacher, serviceschedule.dateschedule
|
|
FROM bookingclass
|
|
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
|
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
|
WHERE bookingclass.iduser = :iduser
|
|
AND bookingclass.status = 'waiting'
|
|
AND serviceschedule.dateschedule BETWEEN :monthStart AND DATE_ADD(:monthEnd, INTERVAL 1 DAY)
|
|
ORDER BY serviceschedule.dateschedule";
|
|
$stmtWaiting = $pdo->prepare($sqlWaiting);
|
|
$stmtWaiting->execute([
|
|
':iduser' => $iduserlogin,
|
|
':monthStart' => $currentMonthStart,
|
|
':monthEnd' => $currentMonthEnd,
|
|
]);
|
|
$waitingRows = $stmtWaiting->fetchAll();
|
|
|
|
// Posizione in coda per ciascuna lezione waiting (1-based, ordine per created_at)
|
|
$waitingPositions = [];
|
|
foreach ($waitingRows as $wrow) {
|
|
$sqlPos = "SELECT COUNT(*) AS pos
|
|
FROM bookingclass
|
|
WHERE idserviceschedule = :sched
|
|
AND status = 'waiting'
|
|
AND created_at <= :mycreated";
|
|
$stmtPos = $pdo->prepare($sqlPos);
|
|
$stmtPos->execute([
|
|
':sched' => (int) $wrow['idserviceschedule'],
|
|
':mycreated' => $wrow['created_at'],
|
|
]);
|
|
$rowPos = $stmtPos->fetch();
|
|
$waitingPositions[(int) $wrow['idbookingclass']] = (int) ($rowPos['pos'] ?? 0);
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* 3) Somma dei ticket acquistati dall'utente
|
|
* ---------------------------------------------------------------------- */
|
|
$sqlTickets = "SELECT SUM(nticket) AS total_tickets
|
|
FROM orderbook
|
|
WHERE iduser = :iduser";
|
|
$stmtTickets = $pdo->prepare($sqlTickets);
|
|
$stmtTickets->execute([':iduser' => $iduserlogin]);
|
|
$rowTickets = $stmtTickets->fetch();
|
|
$totalTickets = (int) ($rowTickets['total_tickets'] ?? 0);
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* 4) Conteggio stati lezioni (praticate / future / perse / da confermare)
|
|
* ---------------------------------------------------------------------- */
|
|
$currentDateTime = date("Y-m-d H:i:s");
|
|
|
|
$sqlCounts = "SELECT
|
|
COUNT(*) AS total,
|
|
SUM(CASE WHEN serviceschedule.dateschedule <= :now1
|
|
AND bookingclass.status = 'booked'
|
|
AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS passed,
|
|
SUM(CASE WHEN serviceschedule.dateschedule > :now2
|
|
AND bookingclass.status = 'booked'
|
|
AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS future,
|
|
SUM(CASE WHEN bookingclass.lostlesson = 'Y'
|
|
AND bookingclass.status != 'cancelled' THEN 1 ELSE 0 END) AS lost,
|
|
SUM(CASE WHEN bookingclass.status = 'pending' THEN 1 ELSE 0 END) AS pending
|
|
FROM bookingclass
|
|
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
|
WHERE bookingclass.iduser = :iduser
|
|
AND bookingclass.status != 'cancelled'";
|
|
|
|
$stmtCounts = $pdo->prepare($sqlCounts);
|
|
$stmtCounts->execute([
|
|
':now1' => $currentDateTime,
|
|
':now2' => $currentDateTime,
|
|
':iduser' => $iduserlogin,
|
|
]);
|
|
$rowCounts = $stmtCounts->fetch();
|
|
|
|
$totalRecords = (int) ($rowCounts['total'] ?? 0);
|
|
$passedRecords = (int) ($rowCounts['passed'] ?? 0);
|
|
$futureRecords = (int) ($rowCounts['future'] ?? 0);
|
|
$lost = (int) ($rowCounts['lost'] ?? 0);
|
|
$pending = (int) ($rowCounts['pending'] ?? 0);
|
|
|
|
$toprogram = $totalTickets - $passedRecords - $futureRecords - $pending - $lost;
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* 4b) Insegnanti nelle card (solo se attivo nelle Opzioni)
|
|
* ---------------------------------------------------------------------- */
|
|
$optShow = $pdo->query("SELECT show_teacher FROM `option` LIMIT 1")->fetch();
|
|
$showTeacher = ($optShow['show_teacher'] ?? 'N') === 'Y';
|
|
|
|
$teachersById = [];
|
|
if ($showTeacher) {
|
|
foreach ($pdo->query("SELECT idemployee, nameemployee, surnameemployee, photo FROM employee")->fetchAll() as $t) {
|
|
$teachersById[(int) $t['idemployee']] = $t;
|
|
}
|
|
}
|
|
/* -------------------------------------------------------------------------
|
|
* 5) Pre-caricamento limiti di riprogrammazione per gli ordini coinvolti
|
|
* (una sola query invece di una per ogni card, dentro il loop)
|
|
* ---------------------------------------------------------------------- */
|
|
$reprogramInfo = [];
|
|
$orderIds = array_filter(array_unique(array_map(
|
|
fn($r) => (int) ($r['idorder'] ?? 0),
|
|
$bookedRows
|
|
)));
|
|
|
|
if (!empty($orderIds)) {
|
|
// Costruiamo i placeholder ?,?,? in numero pari agli id
|
|
$placeholders = implode(',', array_fill(0, count($orderIds), '?'));
|
|
$sqlReprog = "SELECT idorderbook, maxreschedule, reprogrammed
|
|
FROM orderbook
|
|
WHERE idorderbook IN ($placeholders)";
|
|
$stmtReprog = $pdo->prepare($sqlReprog);
|
|
$stmtReprog->execute(array_values($orderIds));
|
|
foreach ($stmtReprog->fetchAll() as $r) {
|
|
$reprogramInfo[(int) $r['idorderbook']] = [
|
|
'max' => (int) ($r['maxreschedule'] ?? 0),
|
|
'done' => (int) ($r['reprogrammed'] ?? 0),
|
|
];
|
|
}
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------
|
|
* Helper output sicuro (evita XSS quando stampiamo dati DB nell'HTML)
|
|
* ---------------------------------------------------------------------- */
|
|
function e($value): string
|
|
{
|
|
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
|
}
|
|
|
|
function teacherLine(array $row, bool $show, array $teachersById): string
|
|
{
|
|
if (!$show) return '';
|
|
$t = $teachersById[(int) ($row['idteacher'] ?? 0)] ?? null;
|
|
if (!$t) return '';
|
|
|
|
$name = trim($t['nameemployee'] . ' ' . $t['surnameemployee']);
|
|
if (!empty($t['photo'])) {
|
|
$avatar = '<img class="teacher-avatar-sm" src="assets/images/teachers/' . e($t['photo']) . '" alt="">';
|
|
} else {
|
|
$ini = mb_strtoupper(mb_substr($t['nameemployee'], 0, 1) . mb_substr($t['surnameemployee'], 0, 1));
|
|
$avatar = '<span class="teacher-avatar-sm">' . e($ini) . '</span>';
|
|
}
|
|
return '<p class="custom-paragraph teacher-line">' . $avatar . 'Insegnante: <strong>' . e($name) . '</strong></p>';
|
|
}
|
|
|
|
$italianMonths = [
|
|
"January" => "Gennaio",
|
|
"February" => "Febbraio",
|
|
"March" => "Marzo",
|
|
"April" => "Aprile",
|
|
"May" => "Maggio",
|
|
"June" => "Giugno",
|
|
"July" => "Luglio",
|
|
"August" => "Agosto",
|
|
"September" => "Settembre",
|
|
"October" => "Ottobre",
|
|
"November" => "Novembre",
|
|
"December" => "Dicembre"
|
|
];
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<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" />
|
|
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
|
|
|
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
|
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/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>
|
|
|
|
<style>
|
|
.custom-card {
|
|
background: #fff;
|
|
border-radius: 14px;
|
|
box-shadow: 0 3px 16px rgba(0, 0, 0, 0.06);
|
|
overflow: hidden;
|
|
margin-bottom: 18px;
|
|
display: flex;
|
|
cursor: pointer;
|
|
transition: box-shadow 0.2s;
|
|
}
|
|
|
|
.custom-card:hover {
|
|
box-shadow: 0 6px 22px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.pending-card {
|
|
cursor: default;
|
|
}
|
|
|
|
.pending-card .custom-date-box {
|
|
flex: 0 0 90px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.pending-card .custom-day {
|
|
font-size: 30px;
|
|
}
|
|
|
|
.pending-card .custom-month {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.pending-card .custom-event-details {
|
|
padding: 12px 20px;
|
|
}
|
|
|
|
.pending-card .custom-heading {
|
|
font-size: 17px;
|
|
}
|
|
|
|
.custom-date-box {
|
|
flex: 0 0 110px;
|
|
background: #E1D0B8;
|
|
color: #ffffff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 16px;
|
|
}
|
|
|
|
.custom-day {
|
|
font-size: 44px;
|
|
font-weight: 800;
|
|
line-height: 1;
|
|
}
|
|
|
|
.custom-month {
|
|
font-size: 18px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.custom-event-details {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 18px 22px;
|
|
background: #fff;
|
|
border-left: 20px solid #ccc;
|
|
/* colore impostato inline per ogni card */
|
|
}
|
|
|
|
.custom-heading {
|
|
font-size: 19px;
|
|
font-weight: 700;
|
|
color: #1f2937;
|
|
margin: 0 0 4px;
|
|
}
|
|
|
|
.teacher-line {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin: 4px 0 6px;
|
|
}
|
|
|
|
.teacher-line strong {
|
|
color: #374151;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.teacher-avatar-sm {
|
|
flex: 0 0 26px;
|
|
width: 26px;
|
|
height: 26px;
|
|
border-radius: 50%;
|
|
object-fit: cover;
|
|
background: #E1D0B8;
|
|
color: #5a4630;
|
|
font-size: 11px;
|
|
font-weight: 800;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.custom-paragraph {
|
|
color: #6b7280;
|
|
font-size: 14px;
|
|
margin-bottom: 3px;
|
|
}
|
|
|
|
.custom-actions {
|
|
display: none;
|
|
flex-direction: row;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
margin-top: 12px;
|
|
}
|
|
|
|
.custom-card.expanded .custom-actions {
|
|
display: flex;
|
|
}
|
|
|
|
.custom-action-button {
|
|
border: none;
|
|
border-radius: 8px;
|
|
padding: 7px 14px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
background: #eef2f7;
|
|
color: #374151;
|
|
cursor: pointer;
|
|
transition: filter 0.15s;
|
|
}
|
|
|
|
.custom-action-button:hover {
|
|
filter: brightness(0.94);
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.custom-card {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.custom-date-box {
|
|
flex: 0 0 auto;
|
|
width: 100%;
|
|
flex-direction: row;
|
|
gap: 10px;
|
|
padding: 12px;
|
|
}
|
|
|
|
.custom-day {
|
|
font-size: 30px;
|
|
}
|
|
|
|
.custom-month {
|
|
font-size: 18px;
|
|
}
|
|
}
|
|
|
|
.month-navigation {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.month-nav-button {
|
|
background: none;
|
|
border: none;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.current-month {
|
|
font-size: 24px;
|
|
margin: 0 20px;
|
|
}
|
|
|
|
.card {
|
|
width: 100%;
|
|
}
|
|
|
|
.pastel-color {
|
|
border: 1px solid #D1C4CC;
|
|
padding: 0px;
|
|
text-align: center;
|
|
border-radius: 10px;
|
|
margin-right: 20px;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.pastel-color.acquistate {
|
|
background-color: #E2C4FB;
|
|
}
|
|
|
|
.pastel-color.praticate {
|
|
background-color: #C4E1FB;
|
|
}
|
|
|
|
.pastel-color.prenotate {
|
|
background-color: #CDFBC4;
|
|
}
|
|
|
|
.pastel-color.conferma {
|
|
background-color: #FBFAC4;
|
|
}
|
|
|
|
.pastel-color.programmare {
|
|
background-color: #FBE4C4;
|
|
}
|
|
|
|
.pastel-color.perse {
|
|
background-color: #FBC7C4;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.pastel-color {
|
|
margin-right: 0;
|
|
margin-bottom: 20px;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
function confirmDelete(id, idservice, deletePageUrl) {
|
|
Swal.fire({
|
|
title: "Sei sicuro?",
|
|
text: "Questa prenotazione verrà cancellata e ti verrà richiesto di programmare la lezione!",
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#d33",
|
|
cancelButtonColor: "#3085d6",
|
|
confirmButtonText: "Sì, riprogramma!",
|
|
cancelButtonText: "Annulla"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = `${deletePageUrl}?id=${id}&idserviceordered=${idservice}`;
|
|
}
|
|
});
|
|
}
|
|
|
|
function confirmDeleteOnly(idbookingclass, expirydate, ticketLost) {
|
|
var html = ticketLost ?
|
|
`<strong>Confermi di voler cancellare questa lezione?</strong><br><br>
|
|
Hai già usato <strong>tutte le riprogrammazioni</strong> del tuo pacchetto.<br>
|
|
Cancellando liberi il posto in sala, ma
|
|
<strong style="color:#d33;">la lezione non potrà essere recuperata.</strong> ` :
|
|
`<strong>Confermi di voler cancellare questa lezione?</strong><br><br>
|
|
<strong>RICORDA:</strong> dovrai riprogrammarla entro la scadenza del tuo abbonamento per non perderla!<br><br>
|
|
La cancellazione conta come <strong>una delle riprogrammazioni</strong> disponibili per il tuo pacchetto.<br><br>
|
|
<span style="font-size:20px;color:#d33;font-weight:bold;">Scadenza: ${expirydate}</span>`;
|
|
|
|
Swal.fire({
|
|
title: "Attenzione",
|
|
html: html,
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonText: ticketLost ? "Cancella comunque" : "Procedi",
|
|
cancelButtonText: "Annulla",
|
|
confirmButtonColor: "#d33",
|
|
cancelButtonColor: "#3085d6"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = "delete_lesson.php?id=" + idbookingclass;
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="layout-wrapper">
|
|
<header id="page-topbar" class="isvertical-topbar">
|
|
<div class="navbar-header">
|
|
<div class="d-flex">
|
|
<?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>
|
|
<div class="page-title-box align-self-center d-none d-md-block">
|
|
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex">
|
|
<?php include('include/languageselection.php'); ?>
|
|
<?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 class="topnav">
|
|
<div class="container-fluid">
|
|
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<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">
|
|
<h5>Benvenuta/o </h5>
|
|
<p>Di seguito puoi vedere lo stato delle tue prenotazioni</p>
|
|
<div class="row">
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color acquistate">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Lezioni acquistate</h5>
|
|
<p><?php echo e($totalTickets); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color praticate">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Praticate</h5>
|
|
<p><?php echo e($passedRecords); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color prenotate">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Prenotate</h5>
|
|
<p><?php echo e($futureRecords); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color conferma">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Da confermare</h5>
|
|
<p><?php echo e($pending); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color programmare">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Da programmare</h5>
|
|
<p><?php echo e($toprogram); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<div class="card pastel-color perse">
|
|
<div class="card-body">
|
|
<h5 style="font-size: 0.9em;">Perse</h5>
|
|
<p><?php echo e($lost); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert" style="text-align: center;">
|
|
<i class="mdi mdi-alert-outline me-2"></i>
|
|
Car* Yogi, ti ricordiamo che il pacchetto 4 lezioni ha validità entro <strong>5 settimane</strong> e il pacchetto da 12 lezioni entro <strong>15 settimane</strong> dalla prima lezione 🙏
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (isset($_GET['reprogram'])) { ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="mdi mdi-check-all me-2"></i>
|
|
Richiesta di riprogrammazione inviata con successo!
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (isset($_GET['waiting'])) { ?>
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-hourglass-half me-2"></i>
|
|
La classe era piena: sei stata/o inserita/o in <strong>lista d'attesa</strong>. Se si libera un posto verrai avvisata/o.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (isset($_GET['leftwaiting'])) { ?>
|
|
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-check me-2"></i>
|
|
Sei uscita/o dalla lista d'attesa.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (isset($_GET['full'])) { ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-ban me-2"></i>
|
|
La classe è al completo e la lista d'attesa non è attiva. Prova con un altro orario.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (($_GET['deleted'] ?? '') === '0') {
|
|
$cancelErrors = [
|
|
'window' => 'Non è più possibile cancellare questa lezione: il tempo per la cancellazione è scaduto.',
|
|
'limit' => 'Hai raggiunto il numero massimo di riprogrammazioni per questo pacchetto.',
|
|
'status' => 'Questa prenotazione non può essere cancellata da qui.',
|
|
'notfound' => 'Prenotazione non trovata.',
|
|
];
|
|
$cancelMsg = $cancelErrors[$_GET['err'] ?? ''] ?? 'Si è verificato un errore: la lezione non è stata cancellata. Riprova o contattaci.';
|
|
?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-ban me-2"></i>
|
|
<?php echo e($cancelMsg); ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (($_GET['deleted'] ?? '') === 'lost') { ?>
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
Lezione cancellata.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if (($_GET['deleted'] ?? '') === '1') { ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="mdi mdi-check-all me-2"></i>
|
|
Lezione cancellata con successo! Grazie per aver liberato il posto!
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="">
|
|
<div class="row mb-2">
|
|
<div class="col-xl-3 col-md-12">
|
|
<div class="pb-3 pb-xl-0">
|
|
<form class="email-search">
|
|
<div class="position-relative">
|
|
<h3>Lezioni Programmate</h3>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="col-xl-9 col-md-12">
|
|
<div class="text-sm-end">
|
|
<?php if ($toprogram > 0) { ?>
|
|
<a href="selectorder.php">
|
|
<button type="button" class="btn btn-primary btn-rounded waves-effect waves-light mb-2 me-2" data-bs-toggle="modal" data-bs-target=".create-task">
|
|
<i class="mdi mdi-plus me-1"></i> Programma lezioni rimanenti
|
|
</button>
|
|
</a>
|
|
<?php } ?>
|
|
<a href="https://yogasoul.it/shop-completo/">
|
|
<button type="button" class="btn btn-success btn-rounded waves-effect waves-light mb-2 me-2" data-bs-toggle="modal" data-bs-target=".create-task">
|
|
<i class="mdi mdi-plus me-1"></i> Acquista Pacchetto Lezioni
|
|
</button>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container-fluid">
|
|
<div class="month-navigation">
|
|
<a href="?prev_month=<?php echo e(date('Y-m', strtotime('-1 month', strtotime($currentMonthStart)))); ?>" class="arrow-link">
|
|
<i class="fas fa-chevron-left fa-2x"></i>
|
|
</a>
|
|
<h2><?php echo e($italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart))); ?></h2>
|
|
<a href="?next_month=<?php echo e(date('Y-m', strtotime('+1 month', strtotime($currentMonthStart)))); ?>" class="arrow-link">
|
|
<i class="fas fa-chevron-right fa-2x"></i>
|
|
</a>
|
|
</div>
|
|
|
|
<?php if (!empty($pendingRows)) : ?>
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 style="color:#8a6d00;margin-bottom:14px;">
|
|
<i class="fas fa-hourglass-half me-1"></i> In attesa di conferma
|
|
</h5>
|
|
<?php foreach ($pendingRows as $prow) :
|
|
$pDateObj = new DateTime($prow['dateschedule']);
|
|
$pDay = $pDateObj->format("d");
|
|
$pMonth = $italianMonths[$pDateObj->format("F")];
|
|
$pWhen = $pDateObj->format("d-m-Y H:i");
|
|
$pColor = $prow['colorclass'] ?? '#1ebf73';
|
|
$pName = $prow['servicename'] ?? '';
|
|
?>
|
|
<div class="custom-card pending-card">
|
|
<div class="custom-date-box" style="background:#e0a800;">
|
|
<div class="custom-day"><?php echo e($pDay); ?></div>
|
|
<div class="custom-month"><?php echo e($pMonth); ?></div>
|
|
</div>
|
|
<div class="custom-event-details" style="border-left-color:<?php echo e($pColor); ?>">
|
|
<h2 class="custom-heading">
|
|
<?php echo e($pName); ?>
|
|
<span style="display:inline-block;background:#fff4d6;color:#8a6d00;font-size:11px;font-weight:700;padding:2px 9px;border-radius:20px;margin-left:6px;vertical-align:middle;">In attesa</span>
|
|
</h2>
|
|
<p class="custom-paragraph">Quando: <?php echo e($pWhen); ?></p>
|
|
<?php echo teacherLine($prow, $showTeacher, $teachersById); ?>
|
|
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($waitingRows)) : ?>
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 style="color:#8a6d00;margin-bottom:14px;">
|
|
<i class="fas fa-hourglass-half me-1"></i> In lista d'attesa
|
|
</h5>
|
|
<?php foreach ($waitingRows as $wrow) :
|
|
$wDateObj = new DateTime($wrow['dateschedule']);
|
|
$wDay = $wDateObj->format("d");
|
|
$wMonth = $italianMonths[$wDateObj->format("F")];
|
|
$wWhen = $wDateObj->format("d-m-Y H:i");
|
|
$wColor = $wrow['colorclass'] ?? '#1ebf73';
|
|
$wName = $wrow['servicename'] ?? '';
|
|
$wPos = $waitingPositions[(int) $wrow['idbookingclass']] ?? 0;
|
|
?>
|
|
<div class="custom-card pending-card">
|
|
<div class="custom-date-box" style="background:#9C9C9C;">
|
|
<div class="custom-day"><?php echo e($wDay); ?></div>
|
|
<div class="custom-month"><?php echo e($wMonth); ?></div>
|
|
</div>
|
|
<div class="custom-event-details" style="border-left-color:<?php echo e($wColor); ?>">
|
|
<h2 class="custom-heading">
|
|
<?php echo e($wName); ?>
|
|
<span style="display:inline-block;background:#eee;color:#555;font-size:11px;font-weight:700;padding:2px 9px;border-radius:20px;margin-left:6px;vertical-align:middle;">In coda</span>
|
|
</h2>
|
|
<p class="custom-paragraph">Quando: <?php echo e($wWhen); ?></p>
|
|
<?php echo teacherLine($wrow, $showTeacher, $teachersById); ?>
|
|
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
|
<?php if ($wPos > 0) : ?>
|
|
<p class="custom-paragraph" style="font-weight:700;color:#8a6d00;">
|
|
<i class="fas fa-list-ol me-1"></i> La tua posizione in coda: <?php echo e($wPos); ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
<p class="custom-paragraph" style="font-size:13px;color:#9ca3af;">
|
|
Se si libera un posto verrai avvisata/o. Non serve fare nulla.
|
|
</p>
|
|
<div style="margin-top:8px;">
|
|
<button class="custom-action-button" style="background:#fbeef3;color:#d1698a;"
|
|
onclick="confirmLeaveWaiting(<?php echo (int) $wrow['idbookingclass']; ?>)">
|
|
<i class="fas fa-times-circle"></i> Esci dalla lista d'attesa
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 style="color:#1a7f52;margin-bottom:14px;">
|
|
<i class="fas fa-check-circle me-1"></i> Prenotate
|
|
</h5>
|
|
<?php if (empty($bookedRows)) { ?>
|
|
<p>Prenotazioni non presenti per questo mese</p>
|
|
<?php
|
|
} else {
|
|
foreach ($bookedRows as $row) {
|
|
$dateschedule = $row['dateschedule'];
|
|
$dateObj = new DateTime($dateschedule);
|
|
$dayInItalian = $dateObj->format("d");
|
|
$monthInItalian = $italianMonths[$dateObj->format("F")];
|
|
$newDateFormat = $dateObj->format("d-m-Y H:i");
|
|
|
|
// Calcolo finestra di cancellazione
|
|
$currentTime = new DateTime();
|
|
$classTime = new DateTime($dateschedule);
|
|
$isSameDay = $classTime->format('Y-m-d') === $currentTime->format('Y-m-d');
|
|
$classHour = (int) $classTime->format('H');
|
|
$classMinute = (int) $classTime->format('i');
|
|
$isBefore1700 = ($classHour < 17) || ($classHour === 17 && $classMinute === 0);
|
|
|
|
if ($isSameDay) {
|
|
if ($isBefore1700) {
|
|
$deadline = new DateTime($classTime->format('Y-m-d 00:01:00'));
|
|
} else {
|
|
$deadline = new DateTime($classTime->format('Y-m-d 12:00:00'));
|
|
}
|
|
$canBeDeleted = $currentTime <= $deadline;
|
|
} else {
|
|
$canBeDeleted = true;
|
|
}
|
|
|
|
// Limite riprogrammazioni (dai dati pre-caricati, niente query nel loop)
|
|
$idorder = (int) ($row['idorder'] ?? 0);
|
|
$canReprogram = true;
|
|
if (isset($reprogramInfo[$idorder])) {
|
|
$canReprogram = $reprogramInfo[$idorder]['done'] < $reprogramInfo[$idorder]['max'];
|
|
}
|
|
|
|
$idbookingclass = (int) $row['idbookingclass'];
|
|
$idservice = (int) $row['idservice'];
|
|
$expirydate = date("d/m/Y", strtotime($row['expireon']));
|
|
$colorclass = $row['colorclass'] ?? '#1ebf73';
|
|
$servicename = $row['servicename'] ?? '';
|
|
?>
|
|
<div class="custom-card" onclick="toggleCard(this)">
|
|
<div class="custom-date-box">
|
|
<div class="custom-day"><?php echo e($dayInItalian); ?></div>
|
|
<div class="custom-month"><?php echo e($monthInItalian); ?></div>
|
|
</div>
|
|
<div class="custom-event-details" style="border-left-color:<?php echo e($colorclass); ?>">
|
|
<h2 class="custom-heading"><?php echo e($servicename); ?></h2>
|
|
<p class="custom-paragraph">Quando: <?php echo e($newDateFormat); ?></p>
|
|
<?php echo teacherLine($row, $showTeacher, $teachersById); ?>
|
|
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
|
<div class="custom-actions">
|
|
<button class="custom-action-button" onclick="addToCalendar(this)" data-eventname="<?php echo e($servicename); ?>" data-eventdate="<?php echo e($newDateFormat); ?>">
|
|
<i class="far fa-calendar-plus"></i> Cal
|
|
</button>
|
|
<?php if ($canBeDeleted) : ?>
|
|
<?php if ($canReprogram) : ?>
|
|
<button class="custom-action-button" onclick="confirmDelete(<?php echo $idbookingclass; ?>, <?php echo $idservice; ?>, 'bookingpanel.php')">
|
|
<i class="fas fa-calendar-alt"></i> Riprogramma
|
|
</button>
|
|
<?php endif; ?>
|
|
<button class="custom-action-button"
|
|
onclick="confirmDeleteOnly(<?php echo $idbookingclass; ?>, '<?php echo e($expirydate); ?>', <?php echo $canReprogram ? 'false' : 'true'; ?>)">
|
|
<i class="fas fa-trash"></i> Cancella
|
|
</button>
|
|
<?php else : ?>
|
|
<button class="custom-action-button"><i class="fas fa-exclamation-circle"></i> Non più cancellabile</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><br><br>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include('include/footer.php'); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function toggleCard(card) {
|
|
card.classList.toggle("expanded");
|
|
}
|
|
|
|
function addToCalendar(button) {
|
|
const eventName = button.getAttribute('data-eventname');
|
|
const eventDate = button.getAttribute('data-eventdate');
|
|
const googleCalendarLink = `https://www.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(eventName)}&dates=${encodeURIComponent(eventDate)}`;
|
|
window.open(googleCalendarLink, '_blank');
|
|
const outlookCalendarLink = `webcal://outlook.live.com/calendar/0/deeplink/compose?path=/calendar/action/compose&subject=${encodeURIComponent(eventName)}&startdt=${encodeURIComponent(eventDate)}`;
|
|
window.open(outlookCalendarLink, '_blank');
|
|
}
|
|
|
|
function confirmLeaveWaiting(id) {
|
|
Swal.fire({
|
|
title: "Uscire dalla lista d'attesa?",
|
|
text: "Verrai rimossa/o dalla coda per questa lezione.",
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#d1698a",
|
|
cancelButtonColor: "#3085d6",
|
|
confirmButtonText: "Sì, esci",
|
|
cancelButtonText: "Annulla"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = "leavewaiting.php?id=" + id;
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
|
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
|
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
|
<script src="assets/js/app.js"></script>
|
|
</body>
|
|
|
|
</html>
|