";
try {
$db = getDatabase();
$pdo = $db->getConnection();
// Get recent appointments with their cancellation tokens
$stmt = $pdo->prepare("
SELECT
a.booking_id,
a.service_id,
a.start_datetime,
a.end_datetime,
a.status,
a.cancellation_token,
c.first_name,
c.last_name,
c.email
FROM appointments a
LEFT JOIN customers c ON a.customer_id = c.id
WHERE a.start_datetime >= NOW()
AND a.status IN ('CONFIRMED', 'PENDING')
ORDER BY a.start_datetime ASC
LIMIT 10
");
$stmt->execute();
$appointments = $stmt->fetchAll();
if (empty($appointments)) {
echo "
No active appointments found!
Create some test appointments first using the appointment creator.