diff --git a/index.php b/index.php index 7205f3d..8150b19 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,140 @@ query("SELECT COUNT(*) FROM participants")->fetchColumn(); +$worker_count = db()->query("SELECT COUNT(*) FROM support_workers")->fetchColumn(); +$service_log_count = db()->query("SELECT COUNT(*) FROM service_logs")->fetchColumn(); + +// Fetch upcoming compliance alerts (e.g., expiring in 90 days) +$ninety_days_from_now = date('Y-m-d', strtotime('+90 days')); +$compliance_alerts = db()->query("SELECT COUNT(*) FROM participants WHERE ndis_plan_end_date <= '$ninety_days_from_now'")->fetchColumn(); +$worker_alerts = db()->query("SELECT COUNT(*) FROM support_workers WHERE ndis_worker_screening_expiry <= '$ninety_days_from_now' OR first_aid_expiry <= '$ninety_days_from_now'")->fetchColumn(); +$total_alerts = $compliance_alerts + $worker_alerts; + +// Chart Data +// Participants per month +$participants_per_month_q = db()->query("SELECT DATE_FORMAT(created_at, '%Y-%m') as month, COUNT(*) as count FROM participants GROUP BY month ORDER BY month"); +$participants_per_month = $participants_per_month_q->fetchAll(PDO::FETCH_ASSOC); +$participant_months = json_encode(array_column($participants_per_month, 'month')); +$participant_counts = json_encode(array_column($participants_per_month, 'count')); + +// Services per month +$services_per_month_q = db()->query("SELECT DATE_FORMAT(service_date, '%Y-%m') as month, COUNT(*) as count FROM service_logs GROUP BY month ORDER BY month"); +$services_per_month = $services_per_month_q->fetchAll(PDO::FETCH_ASSOC); +$service_months = json_encode(array_column($services_per_month, 'month')); +$service_counts = json_encode(array_column($services_per_month, 'count')); + +// Billing status +$billing_status_q = db()->query("SELECT billing_status, COUNT(*) as count FROM service_logs GROUP BY billing_status"); +$billing_status = $billing_status_q->fetchAll(PDO::FETCH_ASSOC); +$billing_status_labels = json_encode(array_column($billing_status, 'billing_status')); +$billing_status_counts = json_encode(array_column($billing_status, 'count')); -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
+ +
+

Dashboard

+ Log a New Service +
+ +
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

+

Total Participants

+

+ Manage Participants →
-
-
- Page updated: (UTC) -
- - +
+

Total Support Workers

+

+ Manage Workers → +
+
+

Services Logged

+

+ View Service Logs → +
+
+

Compliance Alerts

+

+ View Alerts → +
+