branch waiting list with update
This commit is contained in:
+17
-4
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once('include/headscript.php');
|
||||
require_once __DIR__ . '/class/mailer.php';
|
||||
require_once('include/waitinglist.php');
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
@@ -55,11 +56,20 @@ if ($rowUser = $resUser->fetch_assoc()) {
|
||||
}
|
||||
$stmtUser->close();
|
||||
|
||||
// Decide lo stato: pending se c'è posto, waiting se la classe è piena
|
||||
$bookingStatus = decideBookingStatus($conn, $idnewbooking);
|
||||
|
||||
if ($bookingStatus === 'full') {
|
||||
// Classe piena e lista d'attesa disattivata: non inseriamo nulla
|
||||
header("Location: userpanel.php?full=Y");
|
||||
exit();
|
||||
}
|
||||
|
||||
// Inserisce la nuova prenotazione in bookingclass
|
||||
$insertQuery = "INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
|
||||
VALUES (?, ?, NULL, '0', ?, ?, ?, 'pending')";
|
||||
VALUES (?, ?, NULL, '0', ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($insertQuery);
|
||||
$stmt->bind_param("iiiis", $idnewbooking, $iduser, $idservicenew, $idorder, $newtime);
|
||||
$stmt->bind_param("iiiiss", $idnewbooking, $iduser, $idservicenew, $idorder, $newtime, $bookingStatus);
|
||||
if (!$stmt->execute()) {
|
||||
$stmt->close();
|
||||
die("Errore durante l'inserimento della nuova prenotazione: " . $conn->error);
|
||||
@@ -78,9 +88,12 @@ $stmt->close();
|
||||
|
||||
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
|
||||
|
||||
// Parametro di ritorno diverso se finito in lista d'attesa
|
||||
$redirectFlag = ($bookingStatus === 'waiting') ? 'waiting=Y' : 'reprogram=Y';
|
||||
|
||||
// Se non abbiamo un'email valida, salta l'invio ma completa comunque il flusso
|
||||
if ($emailuser === '') {
|
||||
header("Location: userpanel.php?reprogram=Y");
|
||||
header("Location: userpanel.php?$redirectFlag");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -168,5 +181,5 @@ try {
|
||||
}
|
||||
|
||||
// Esegui il reindirizzamento
|
||||
header("Location: userpanel.php?reprogram=Y");
|
||||
header("Location: userpanel.php?$redirectFlag");
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user