37338-vm/_get_meeting_attendance.php
2026-01-11 15:08:42 +00:00

36 lines
968 B
PHP

<?php
require_once 'WorkflowEngine.php';
session_start();
header('Content-Type: application/json');
$response = ['success' => false, 'message' => 'An error occurred.', 'attendance' => []];
if (!isset($_SESSION['user_id'])) {
$response['message'] = 'You must be logged in to perform this action.';
echo json_encode($response);
exit;
}
$groupId = $_GET['group_id'] ?? null;
$meetingDate = $_GET['meeting_date'] ?? null;
if (!$groupId || !$meetingDate) {
$response['message'] = 'Missing required parameters.';
echo json_encode($response);
exit;
}
try {
$workflowEngine = new WorkflowEngine();
$attendance = $workflowEngine->getMeetingAttendanceByGroupAndDate((int)$groupId, $meetingDate);
$response['success'] = true;
$response['attendance'] = $attendance;
} catch (Exception $e) {
error_log($e->getMessage());
$response['message'] = 'Error fetching attendance: ' . $e->getMessage();
}
echo json_encode($response);