prepare("SELECT id, full_legal_name, ndis_plan_end_date FROM participants WHERE ndis_plan_end_date <= :end_date AND ndis_plan_end_date >= CURDATE() ORDER BY ndis_plan_end_date ASC");
$plan_stmt->bindParam(':end_date', $ninety_days_from_now);
$plan_stmt->execute();
$plan_alerts = $plan_stmt->fetchAll(PDO::FETCH_ASSOC);
// Worker Screening Expiries
$screening_stmt = $db->prepare("SELECT id, full_name, ndis_worker_screening_expiry FROM support_workers WHERE ndis_worker_screening_expiry <= :end_date AND ndis_worker_screening_expiry >= CURDATE() ORDER BY ndis_worker_screening_expiry ASC");
$screening_stmt->bindParam(':end_date', $ninety_days_from_now);
$screening_stmt->execute();
$screening_alerts = $screening_stmt->fetchAll(PDO::FETCH_ASSOC);
// First Aid Expiries
$fa_stmt = $db->prepare("SELECT id, full_name, first_aid_expiry FROM support_workers WHERE first_aid_expiry <= :end_date AND first_aid_expiry >= CURDATE() ORDER BY first_aid_expiry ASC");
$fa_stmt->bindParam(':end_date', $ninety_days_from_now);
$fa_stmt->execute();
$first_aid_alerts = $fa_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$error = "Database Error: " . $e->getMessage();
}
function get_days_until_badge($date) {
$now = time();
$your_date = strtotime($date);
$datediff = $your_date - $now;
$days = round($datediff / (60 * 60 * 24));
$class = ' ';
if ($days < 0) $class = 'expired';
elseif ($days <= 30) $class = 'urgent';
elseif ($days <= 60) $class = 'soon';
else $class = 'safe';
$text = ($days < 0) ? "Expired" : "{$days} days";
return "{$text}";
}
?>
Compliance Dashboard