event_participants.php
* - Modifica -> event_form.php?id=
* - Annulla -> modale (SweetAlert2) che chiede se inviare la mail di
* annullamento a tutti i partecipanti, poi event_delete.php
*/
$pdo = DBHandlerSelect::getInstance()->getConnection();
function e($value): string
{
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
}
$message = $_GET['message'] ?? '';
// Posti prenotati = SOMMA dei posti delle prenotazioni non annullate.
$sql = "SELECT e.*,
COALESCE(b.booked, 0) AS booked,
COALESCE(b.bookings_count, 0) AS bookings_count,
COALESCE(w.waiting, 0) AS waiting,
u.first_name AS creator_first,
u.last_name AS creator_last
FROM events e
LEFT JOIN (
SELECT event_id,
SUM(seats) AS booked,
COUNT(*) AS bookings_count
FROM event_bookings
WHERE status IN ('confirmed','pending','offered')
GROUP BY event_id
) b ON b.event_id = e.id
LEFT JOIN (
SELECT event_id, SUM(seats) AS waiting
FROM event_bookings
WHERE status = 'waiting'
GROUP BY event_id
) w ON w.event_id = e.id
LEFT JOIN auth_users u ON u.id = e.user_id
ORDER BY e.starts_at ASC";
$events = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
$mesi = [
1 => 'gennaio',
2 => 'febbraio',
3 => 'marzo',
4 => 'aprile',
5 => 'maggio',
6 => 'giugno',
7 => 'luglio',
8 => 'agosto',
9 => 'settembre',
10 => 'ottobre',
11 => 'novembre',
12 => 'dicembre'
];
function dataItaliana(string $dt, array $mesi): string
{
$t = strtotime($dt);
return date('j', $t) . ' ' . $mesi[(int) date('n', $t)] . ' ' . date('Y', $t);
}
/** @return array [label, bgColor, textColor] */
function statusBadge(string $status): array
{
switch ($status) {
case 'published':
return ['Aperto', '#e7f7ee', '#1a7f52'];
case 'scheduled':
return ['Programmato', '#eef2fb', '#3a5bb8'];
case 'cancelled':
return ['Annullato', '#fdecea', '#c0392b'];
default:
return ['Bozza', '#eef0f3', '#6b7280'];
}
}
?>
YogiBook - Eventi
Eventi
Evento salvato con successo.
Evento annullato.
Si è verificato un errore. Controlla i dati e riprova.
Eventi
Ciao , gestisci qui i tuoi eventi: crea, modifica, vedi i partecipanti o annulla.