getConnection();
function e($value): string
{
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
}
function initials(string $first, string $last): string
{
$ini = strtoupper(mb_substr(trim($first), 0, 1) . mb_substr(trim($last), 0, 1));
return $ini !== '' ? $ini : '?';
}
function avatarColor(string $seed): string
{
$palette = ['#1ebf73', '#2980b9', '#8e44ad', '#e67e22', '#16a085', '#c0392b', '#2c3e50', '#d35400'];
return $palette[abs(crc32($seed)) % count($palette)];
}
$eventId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
if ($eventId <= 0) {
header('Location: events.php');
exit();
}
// Annullamento singola iscrizione (deve avvenire prima di ogni output)
if (isset($_GET['cancel_booking'])) {
$bookingId = (int) $_GET['cancel_booking'];
$upd = $pdo->prepare("UPDATE event_bookings SET status = 'cancelled', updated_at = NOW() WHERE id = ? AND event_id = ?");
$upd->execute([$bookingId, $eventId]);
header('Location: event_participants.php?id=' . $eventId . '&message=booking_cancelled');
exit();
}
$stmt = $pdo->prepare("SELECT * FROM events WHERE id = ?");
$stmt->execute([$eventId]);
$event = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$event) {
header('Location: events.php?message=error');
exit();
}
$bStmt = $pdo->prepare("SELECT * FROM event_bookings WHERE event_id = ? ORDER BY created_at DESC, id DESC");
$bStmt->execute([$eventId]);
$bookings = $bStmt->fetchAll(PDO::FETCH_ASSOC);
// Riepilogo (solo prenotazioni non annullate)
$bookedSeats = 0;
$activeCount = 0;
$revenue = 0.0;
foreach ($bookings as $b) {
if ($b['status'] !== 'cancelled') {
$bookedSeats += (int) $b['seats'];
$activeCount++;
$revenue += (float) $b['amount'];
}
}
$maxSeats = (int) $event['max_seats'];
$message = $_GET['message'] ?? '';
function bookingBadge(string $status): array
{
switch ($status) {
case 'confirmed':
return ['Confermata', '#e7f7ee', '#1a7f52'];
case 'cancelled':
return ['Annullata', '#fdecea', '#c0392b'];
default:
return ['In attesa', '#fff4e5', '#b26a00'];
}
}
?>
YogiBook - Partecipanti
Iscrizione annullata.
| Partecipante |
Email |
Telefono |
Posti |
Marketing |
Iscritto il |
Stato |
Azioni |
|
Ancora nessun iscritto a questo evento.
|
|
|
|
|
|
Sì
No
|
|
|
—
|