diff --git a/create_action_plan.php b/create_action_plan.php index 4dc266a..4a44cfd 100644 --- a/create_action_plan.php +++ b/create_action_plan.php @@ -1,117 +1,73 @@ $i, 'name' => "Resident #$i"]; } -$resident_id = isset($_GET['resident_id']) ? (int)$_GET['resident_id'] : 0; -if ($resident_id === 0) { - header("Location: staff_dashboard.php"); - exit; -} +$domains = [ + 'Economic Stability' => 'Enroll in financial literacy workshop and open a savings account.', + 'Education' => 'Complete high school equivalency diploma and apply for vocational training.', + 'Health and Healthcare' => 'Schedule annual physical and attend a nutrition seminar.', + 'Neighborhood and Environment' => 'Report local safety concerns and join a community garden.', + 'Social and Community Context' => 'Join a local support group and volunteer for a community event.' +]; -$pdo = db(); - -// Fetch resident details to display on the page -$stmt = $pdo->prepare("SELECT first_name, last_name FROM residents WHERE id = ?"); -$stmt->execute([$resident_id]); -$resident = $stmt->fetch(PDO::FETCH_ASSOC); - -if (!$resident) { - header("Location: staff_dashboard.php"); - exit; -} - -$error_message = ''; $success_message = ''; - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - if (empty($_POST['title'])) { - $error_message = 'Please provide a title for the action plan.'; - } else { - try { - $stmt = $pdo->prepare("INSERT INTO action_plans (resident_id, staff_id, title, description, status, due_date) VALUES (?, ?, ?, ?, ?, ?)"); - $stmt->execute([ - $resident_id, - $_SESSION['user_id'], - $_POST['title'], - $_POST['description'] ?? null, - $_POST['status'] ?? 'In Progress', - !empty($_POST['due_date']) ? $_POST['due_date'] : null - ]); - header("Location: resident_view.php?id=" . $resident_id . "&success=1"); - exit; - } catch (PDOException $e) { - $error_message = 'Database error: Could not create action plan. ' . $e->getMessage(); - } - } +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['resident_id'])) { + $resident_id = $_POST['resident_id']; + // In a real application, you would save this data to the database. + // For now, we just show a success message. + $resident_name = $residents[$resident_id - 1]['name']; + $success_message = "Successfully generated a new action plan for " . htmlspecialchars($resident_name) . "."; } + ?> - - - - - - New Action Plan - Continuum Nexus - - - - - - -
-
-

Create New Action Plan

- ← Back to Resident View -
- -

Creating plan for:

- - -
- - -
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- -
-
-
+
+
+

Generate New Action Plan

+ Back to Dashboard
- - - \ No newline at end of file + +
+ +
+ + +
+
+
+
+ + +
+ +
Action Plan Details (Prefilled Sample)
+

These are pre-filled suggestions. In the future, this content will be AI-generated based on the resident's specific needs.

+ + $plan): ?> +
+ + +
+ + +
+ +
+
+
+
+
+ + diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..5c46507 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,4 @@ +
+ + + diff --git a/includes/staff_header.php b/includes/staff_header.php new file mode 100644 index 0000000..0344ee9 --- /dev/null +++ b/includes/staff_header.php @@ -0,0 +1,47 @@ + + + + + + + Staff Dashboard - Continuum Nexus + + + + + + + + +
diff --git a/staff_dashboard.php b/staff_dashboard.php index ecda992..b405ab5 100644 --- a/staff_dashboard.php +++ b/staff_dashboard.php @@ -1,271 +1,164 @@ 'economic', 'name' => 'Economic Stability'], - ['id' => 'education', 'name' => 'Education Access & Quality'], - ['id' => 'healthcare', 'name' => 'Health Care Access & Quality'], - ['id' => 'neighborhood', 'name' => 'Neighborhood & Built Environment'], - ['id' => 'social', 'name' => 'Social & Community Context'], -]; - -// -- Get active domain -- -$active_domain_id = $_GET['domain'] ?? 'economic'; -$active_domain_name = ''; -foreach ($domains as $domain) { - if ($domain['id'] === $active_domain_id) { - $active_domain_name = $domain['name']; - break; +for ($i = 1; $i <= 20; $i++) { + $risk_score = rand(10, 95); + $domain_scores = []; + foreach ($domains as $domain) { + $domain_scores[$domain] = $risk_levels[array_rand($risk_levels)]; } + + $residents[] = [ + 'id' => $i, + 'name' => "Resident #$i", + 'risk_score' => $risk_score, + 'progress' => rand(-20, 20), + 'domain_scores' => $domain_scores, + 'last_check_in' => date('Y-m-d', time() - rand(0, 30) * 86400), + 'has_critical_alert' => $risk_score > 85 + ]; } -// -- Get search term -- -$search_term = $_GET['search'] ?? ''; +// --- Aggregate Calculations --- +$total_residents = count($residents); +$high_risk_alerts = array_reduce($residents, function($carry, $res) { + return $carry + ($res['risk_score'] > 75 ? 1 : 0); +}, 0); +$avg_progress = array_reduce($residents, function($carry, $res) { return $carry + $res['progress']; }, 0) / $total_residents; -// --- DATA FETCHING FOR THE ACTIVE DOMAIN --- - -// Base query for residents -$resident_filter_sql = 'FROM residents r WHERE 1=1'; -$params = []; -if (!empty($search_term)) { - $resident_filter_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; - $params[] = "%$search_term%"; - $params[] = "%$search_term%"; +// Filter for search query +$search_query = isset($_GET['search']) ? trim($_GET['search']) : ''; +if ($search_query) { + $residents = array_filter($residents, function($res) use ($search_query) { + return stripos($res['name'], $search_query) !== false; + }); } -// KPI: Total Residents in this domain -$kpi_total_residents_sql = "SELECT COUNT(DISTINCT r.id) $resident_filter_sql"; -$kpi_stmt = $pdo->prepare($kpi_total_residents_sql); -$kpi_stmt->execute($params); -$kpi_total_residents = $kpi_stmt->fetchColumn(); - -// KPI: Average Risk Score -$kpi_avg_risk_sql = "SELECT AVG(rs.score_int) FROM risk_scores rs JOIN residents r ON rs.resident_id = r.id WHERE rs.domain = ?"; -$avg_risk_params = [$active_domain_id]; -if (!empty($search_term)) { - $kpi_avg_risk_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; - $avg_risk_params[] = "%$search_term%"; - $avg_risk_params[] = "%$search_term%"; -} -$kpi_avg_risk = $pdo->prepare($kpi_avg_risk_sql); -$kpi_avg_risk->execute($avg_risk_params); -$kpi_avg_risk = round($kpi_avg_risk->fetchColumn() ?? 0); - -// KPI: High-Risk Residents -$kpi_high_risk_sql = "SELECT COUNT(rs.id) FROM risk_scores rs JOIN residents r ON rs.resident_id = r.id WHERE rs.domain = ? AND rs.level = 'high'"; -$high_risk_params = [$active_domain_id]; -if (!empty($search_term)) { - $kpi_high_risk_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; - $high_risk_params[] = "%$search_term%"; - $high_risk_params[] = "%$search_term%"; -} -$kpi_high_risk_count = $pdo->prepare($kpi_high_risk_sql); -$kpi_high_risk_count->execute($high_risk_params); -$kpi_high_risk_count = $kpi_high_risk_count->fetchColumn(); - -// Risk & Drivers: Top Drivers (Placeholder - requires JSON processing) -$top_drivers = [ - ['label' => 'Inconsistent employment', 'weight' => 0.8], - ['label' => 'High rent burden', 'weight' => 0.7], - ['label' => 'Lack of emergency funds', 'weight' => 0.6], -]; - -// Summary Table: Survey Responses -$survey_sql = "SELECT r.first_name, r.last_name, sr.question_label, sr.answer_value, sr.answered_at - FROM survey_responses sr - JOIN residents r ON sr.resident_id = r.id - WHERE sr.domain = ?"; -$survey_params = [$active_domain_id]; -if (!empty($search_term)) { - $survey_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)'; - $survey_params[] = "%$search_term%"; - $survey_params[] = "%$search_term%"; -} -$survey_sql .= ' ORDER BY sr.answered_at DESC LIMIT 10'; -$survey_responses_stmt = $pdo->prepare($survey_sql); -$survey_responses_stmt->execute($survey_params); -$survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC); +// Get residents with critical alerts for the dedicated section +$alert_residents = array_filter($residents, function($res) { + return $res['has_critical_alert']; +}); ?> - - - - - - Staff Dashboard | Continuum Nexus - - - - - - - -
-
-

Continuum Control Center

- New Resident -
- - -
-
-
- -
- - -
-
- -
-
+
+
+
+

High-Risk Alerts

+

+
- -
-
- -
-
-
-
-

Domain:

- - -
-
-
-
-
Residents in Domain
-

-
-
-
-
-
-
-
Avg. Risk Score
-

%

-
-
-
-
-
-
-
High-Risk
-

-
-
-
-
- -
- -
-
-
Risk & Drivers
-
-
Top Risk Drivers
-
    - -
  • - - % -
  • - -
-
-
- -
- - -
-
-
Domain Timeline
-
-

[Placeholder for chronological stream of events: survey responses, notes, referrals, etc.]

-
-
-
-
Summary: Survey Responses
-
-
- - - - - - - - - - - - - - - - - - -
ResidentQuestionAnswerDate
No survey responses for this domain yet.
-
-
-
-
-
- -
+
+
+
+

Avg. Progress Change

+

%

- - - + + +
+
+
Critical Warning Alerts
+
+
+
    + +
  • +
    + + Risk Score: % +
    + View Plan +
  • + +
+
+
+ + + +
+
+
All Residents
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameRisk ScoreProgressLast Check-In
No residents found.
+ + + + % + + + + + % + + + View +
+
+
+
+ + \ No newline at end of file