diff --git a/public/api/api_teacher_mark_lost.php b/public/api/api_teacher_mark_lost.php new file mode 100644 index 00000000..3e636d6b --- /dev/null +++ b/public/api/api_teacher_mark_lost.php @@ -0,0 +1,51 @@ +&lost= + * -------------------------------------------------------------------------- + */ + +require_once __DIR__ . '/_bootstrap.php'; + +// Gate staff +$roleId = (int) $user->role_id; +if (!in_array($roleId, [1, 3], true)) { + http_response_code(403); + echo json_encode(['success' => false, 'message' => 'Forbidden']); + exit; +} + +$bookingId = isset($_POST['booking_id']) ? (int) $_POST['booking_id'] : 0; +$lostRaw = isset($_POST['lost']) ? strtoupper(trim((string) $_POST['lost'])) : ''; +$lost = ($lostRaw === 'Y') ? 'Y' : 'N'; + +if ($bookingId <= 0) { + http_response_code(400); + echo json_encode(['success' => false, 'message' => 'ID prenotazione non valido']); + exit; +} + +try { + $stmt = $db->prepare( + "UPDATE bookingclass SET lostlesson = :lost WHERE idbookingclass = :id" + ); + $stmt->execute([':lost' => $lost, ':id' => $bookingId]); + + echo json_encode([ + 'success' => true, + 'booking_id' => $bookingId, + 'lost' => $lost, + ], JSON_UNESCAPED_UNICODE); +} catch (Throwable $ex) { + error_log('api_teacher_mark_lost error: ' . $ex->getMessage()); + http_response_code(500); + echo json_encode(['success' => false, 'message' => 'Errore aggiornamento']); +}