booked. * Solo staff (Admin=1 / teacher=3). * * Posizione: public/api/api_teacher_confirm_pending.php * Metodo: POST * Auth: Bearer token (Sanctum) via _bootstrap.php * Body: booking_id= * -------------------------------------------------------------------------- */ 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; if ($bookingId <= 0) { http_response_code(400); echo json_encode(['success' => false, 'message' => 'ID prenotazione non valido']); exit; } try { // Conferma solo se davvero in pending $stmt = $db->prepare( "UPDATE bookingclass SET status = 'booked' WHERE idbookingclass = :id AND status = 'pending'" ); $stmt->execute([':id' => $bookingId]); echo json_encode([ 'success' => true, 'booking_id' => $bookingId, 'confirmed' => $stmt->rowCount(), ], JSON_UNESCAPED_UNICODE); } catch (Throwable $ex) { error_log('api_teacher_confirm_pending error: ' . $ex->getMessage()); http_response_code(500); echo json_encode(['success' => false, 'message' => 'Errore conferma']); }