Sindbad~EG File Manager
<?php
require_once '../config/config.php';
header('Content-Type: application/json');
$db = Database::getInstance()->getConnection();
try {
$eventId = $_GET['event_id'] ?? null;
$lastId = $_GET['last_id'] ?? 0;
if (!$eventId) {
throw new Exception('Event ID is required');
}
// Get attendance records newer than lastId
$stmt = $db->prepare("
SELECT
ea.*,
m.membershipcard_id,
m.phone as member_phone,
m.email as member_email
FROM event_attendance ea
LEFT JOIN members m ON ea.member_id = m.id
WHERE ea.event_id = :event_id
AND ea.id > :last_id
ORDER BY ea.check_in_time DESC
LIMIT 50
");
$stmt->execute([
'event_id' => $eventId,
'last_id' => $lastId
]);
$newAttendance = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get total count
$countStmt = $db->prepare("SELECT COUNT(*) as total FROM event_attendance WHERE event_id = :event_id");
$countStmt->execute(['event_id' => $eventId]);
$count = $countStmt->fetch();
// Get latest 20 for display
$recentStmt = $db->prepare("
SELECT
ea.*,
m.membershipcard_id,
m.phone as member_phone,
m.email as member_email
FROM event_attendance ea
LEFT JOIN members m ON ea.member_id = m.id
WHERE ea.event_id = :event_id
ORDER BY ea.check_in_time DESC
LIMIT 20
");
$recentStmt->execute(['event_id' => $eventId]);
$recentAttendance = $recentStmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
'success' => true,
'new_attendance' => $newAttendance,
'recent_attendance' => $recentAttendance,
'total_count' => $count['total'],
'last_id' => !empty($recentAttendance) ? $recentAttendance[0]['id'] : $lastId
]);
} catch (Exception $e) {
echo json_encode([
'success' => false,
'message' => $e->getMessage()
]);
}
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists