added mail to events
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/bootstrap.php';
|
||||
require_once dirname(__DIR__) . '/include/event_mailer.php';
|
||||
|
||||
/**
|
||||
* Endpoint pubblico PRENOTAZIONE (POST).
|
||||
@@ -98,7 +99,7 @@ try {
|
||||
|
||||
// Posti occupati (solo confermate/pending): protetto dal lock evento
|
||||
$os = $pdo->prepare("SELECT COALESCE(SUM(seats),0) FROM event_bookings
|
||||
WHERE event_id = ? AND status IN ('confirmed','pending')");
|
||||
WHERE event_id = ? AND status IN ('confirmed','pending','offered')");
|
||||
$os->execute([$eventId]);
|
||||
$occupied = (int) $os->fetchColumn();
|
||||
$remaining = max(0, $maxSeats - $occupied);
|
||||
@@ -159,7 +160,13 @@ try {
|
||||
|
||||
$pdo->commit();
|
||||
|
||||
// TODO Step 4: email di conferma / lista d'attesa all'iscritto (usando $token).
|
||||
// Email di conferma / lista d'attesa (best-effort: non blocca la prenotazione)
|
||||
try {
|
||||
$bookingRow = ['email' => $email, 'name' => $fullName, 'seats' => $seats, 'status' => $status, 'token' => $token];
|
||||
yse_mail_booking($bookingRow, $event);
|
||||
} catch (Throwable $mailEx) {
|
||||
error_log('[book mail] ' . $mailEx->getMessage());
|
||||
}
|
||||
|
||||
$msg = $status === 'confirmed'
|
||||
? 'Prenotazione confermata! Ti abbiamo inviato una email di riepilogo.'
|
||||
|
||||
Reference in New Issue
Block a user