10 30 4
This commit is contained in:
parent
fb5987dc1e
commit
f15fc3711c
@ -1,117 +1,73 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
include 'includes/staff_header.php';
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
// Check if user is logged in and has the 'staff' role
|
// --- Sample Data Generation ---
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
$residents = [];
|
||||||
header("Location: index.php");
|
for ($i = 1; $i <= 20; $i++) {
|
||||||
exit;
|
$residents[] = ['id' => $i, 'name' => "Resident #$i"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$resident_id = isset($_GET['resident_id']) ? (int)$_GET['resident_id'] : 0;
|
$domains = [
|
||||||
if ($resident_id === 0) {
|
'Economic Stability' => 'Enroll in financial literacy workshop and open a savings account.',
|
||||||
header("Location: staff_dashboard.php");
|
'Education' => 'Complete high school equivalency diploma and apply for vocational training.',
|
||||||
exit;
|
'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 = '';
|
$success_message = '';
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['resident_id'])) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
$resident_id = $_POST['resident_id'];
|
||||||
if (empty($_POST['title'])) {
|
// In a real application, you would save this data to the database.
|
||||||
$error_message = 'Please provide a title for the action plan.';
|
// For now, we just show a success message.
|
||||||
} else {
|
$resident_name = $residents[$resident_id - 1]['name'];
|
||||||
try {
|
$success_message = "Successfully generated a new action plan for " . htmlspecialchars($resident_name) . ".";
|
||||||
$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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>New Action Plan - Continuum Nexus</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="assets/css/custom.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
<div class="container mt-4">
|
||||||
<div class="container-fluid">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<a class="navbar-brand" href="staff_dashboard.php">Continuum Nexus</a>
|
<h1 class="h2">Generate New Action Plan</h1>
|
||||||
</div>
|
<a href="staff_dashboard.php" class="btn btn-secondary"><i class="fas fa-arrow-left me-2"></i>Back to Dashboard</a>
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div class="container mt-4">
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
||||||
<h1 class="h2">Create New Action Plan</h1>
|
|
||||||
<a href="resident_view.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary">← Back to Resident View</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Creating plan for: <strong><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></strong></p>
|
|
||||||
|
|
||||||
<?php if ($error_message): ?>
|
|
||||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<form method="POST" action="create_action_plan.php?resident_id=<?php echo $resident_id; ?>">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="title" class="form-label">Title</label>
|
|
||||||
<input type="text" class="form-control" id="title" name="title" required>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="description" class="form-label">Description</label>
|
|
||||||
<textarea class="form-control" id="description" name="description" rows="5"></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label for="status" class="form-label">Status</label>
|
|
||||||
<select class="form-select" id="status" name="status">
|
|
||||||
<option>Not Started</option>
|
|
||||||
<option selected>In Progress</option>
|
|
||||||
<option>Completed</option>
|
|
||||||
<option>On Hold</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 mb-3">
|
|
||||||
<label for="due_date" class="form-label">Due Date</label>
|
|
||||||
<input type="date" class="form-control" id="due_date" name="due_date">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary-custom">Save Action Plan</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<?php if ($success_message): ?>
|
||||||
</body>
|
<div class="alert alert-success">
|
||||||
</html>
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="create_action_plan.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="resident_id" class="form-label">Select Resident</label>
|
||||||
|
<select class="form-select" id="resident_id" name="resident_id" required>
|
||||||
|
<option value="" disabled selected>Choose a resident...</option>
|
||||||
|
<?php foreach ($residents as $resident): ?>
|
||||||
|
<option value="<?php echo $resident['id']; ?>"><?php echo htmlspecialchars($resident['name']); ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h5 class="mt-4">Action Plan Details (Prefilled Sample)</h5>
|
||||||
|
<p class="text-muted">These are pre-filled suggestions. In the future, this content will be AI-generated based on the resident's specific needs.</p>
|
||||||
|
|
||||||
|
<?php foreach ($domains as $domain => $plan): ?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="plan_<?php echo str_replace(' ', '_', $domain); ?>" class="form-label fw-bold"><?php echo $domain; ?></label>
|
||||||
|
<textarea class="form-control" id="plan_<?php echo str_replace(' ', '_', $domain); ?>" name="plans[<?php echo $domain; ?>]" rows="3"><?php echo htmlspecialchars($plan); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<div class="mt-4 text-end">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg">Generate and Save Plan</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'includes/footer.php'; // Assuming a footer file exists ?>
|
||||||
|
|||||||
4
includes/footer.php
Normal file
4
includes/footer.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
</div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
47
includes/staff_header.php
Normal file
47
includes/staff_header.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// Ensure session is started
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Staff Dashboard - Continuum Nexus</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="staff_dashboard.php">Continuum Nexus</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#staffNavbar" aria-controls="staffNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="staffNavbar">
|
||||||
|
<ul class="navbar-nav ms-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="staff_dashboard.php"><i class="fas fa-tachometer-alt me-1"></i>Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="location_view.php"><i class="fas fa-map-marked-alt me-1"></i>Locations</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="messages.php"><i class="fas fa-envelope me-1"></i>Messages</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="resources.php"><i class="fas fa-book me-1"></i>Resources</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt me-1"></i>Logout</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
@ -1,271 +1,164 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
include 'includes/staff_header.php';
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
// Check if user is logged in and has the 'staff' role
|
// --- Data Fetching and Preparation ---
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
|
||||||
header("Location: index.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pdo = db();
|
// Sample Data Generation (as requested)
|
||||||
|
$residents = [];
|
||||||
|
$domains = ['Economic Stability', 'Education', 'Health and Healthcare', 'Neighborhood and Environment', 'Social and Community Context'];
|
||||||
|
$risk_levels = ['Low', 'Medium', 'High', 'Critical'];
|
||||||
|
|
||||||
// -- Fetch Domains --
|
for ($i = 1; $i <= 20; $i++) {
|
||||||
$domains = [
|
$risk_score = rand(10, 95);
|
||||||
['id' => 'economic', 'name' => 'Economic Stability'],
|
$domain_scores = [];
|
||||||
['id' => 'education', 'name' => 'Education Access & Quality'],
|
foreach ($domains as $domain) {
|
||||||
['id' => 'healthcare', 'name' => 'Health Care Access & Quality'],
|
$domain_scores[$domain] = $risk_levels[array_rand($risk_levels)];
|
||||||
['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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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 --
|
// --- Aggregate Calculations ---
|
||||||
$search_term = $_GET['search'] ?? '';
|
$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 ---
|
// Filter for search query
|
||||||
|
$search_query = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||||
// Base query for residents
|
if ($search_query) {
|
||||||
$resident_filter_sql = 'FROM residents r WHERE 1=1';
|
$residents = array_filter($residents, function($res) use ($search_query) {
|
||||||
$params = [];
|
return stripos($res['name'], $search_query) !== false;
|
||||||
if (!empty($search_term)) {
|
});
|
||||||
$resident_filter_sql .= ' AND (r.first_name LIKE ? OR r.last_name LIKE ?)';
|
|
||||||
$params[] = "%$search_term%";
|
|
||||||
$params[] = "%$search_term%";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// KPI: Total Residents in this domain
|
// Get residents with critical alerts for the dedicated section
|
||||||
$kpi_total_residents_sql = "SELECT COUNT(DISTINCT r.id) $resident_filter_sql";
|
$alert_residents = array_filter($residents, function($res) {
|
||||||
$kpi_stmt = $pdo->prepare($kpi_total_residents_sql);
|
return $res['has_critical_alert'];
|
||||||
$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);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Staff Dashboard | Continuum Nexus</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/css/custom.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
<div class="container mt-4">
|
||||||
<div class="container-fluid">
|
<!-- Page Title -->
|
||||||
<a class="navbar-brand" href="staff_dashboard.php">Continuum Nexus</a>
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<h1 class="h2">Aggregate Dashboard</h1>
|
||||||
<span class="navbar-toggler-icon"></span>
|
<a href="create_action_plan.php" class="btn btn-success"><i class="fas fa-plus me-2"></i>Generate New Action Plan</a>
|
||||||
</button>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
<!-- Aggregate KPI Cards -->
|
||||||
<li class="nav-item">
|
<div class="row mb-4">
|
||||||
<a class="nav-link active" aria-current="page" href="staff_dashboard.php">Dashboard</a>
|
<div class="col-md-4">
|
||||||
</li>
|
<div class="card text-center shadow-sm">
|
||||||
<li class="nav-item">
|
<div class="card-body">
|
||||||
<a class="nav-link" href="location_view.php">Location View</a>
|
<p class="card-title text-muted">Total Residents</p>
|
||||||
</li>
|
<h2 class="display-5"><?php echo $total_residents; ?></h2>
|
||||||
</ul>
|
</div>
|
||||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
<div class="col-md-4">
|
||||||
|
<div class="card text-center shadow-sm text-white bg-danger">
|
||||||
<div class="container-fluid mt-4">
|
<div class="card-body">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<p class="card-title">High-Risk Alerts</p>
|
||||||
<h1 class="h2">Continuum Control Center</h1>
|
<h2 class="display-5"><?php echo $high_risk_alerts; ?></h2>
|
||||||
<a href="resident_intake.php" class="btn btn-primary-custom"><i class="bi bi-plus-circle me-2"></i>New Resident</a>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Search and Filter -->
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-body">
|
|
||||||
<form action="staff_dashboard.php" method="get" class="row g-3 align-items-center">
|
|
||||||
<input type="hidden" name="domain" value="<?php echo htmlspecialchars($active_domain_id); ?>">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<label for="search_term" class="visually-hidden">Search Residents</label>
|
|
||||||
<input type="text" class="form-control" id="search_term" name="search" placeholder="Search by name..." value="<?php echo htmlspecialchars($search_term); ?>">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="submit" class="btn btn-primary w-100">Search</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<div class="card">
|
<div class="card text-center shadow-sm">
|
||||||
<div class="card-header">
|
<div class="card-body">
|
||||||
<ul class="nav nav-tabs card-header-tabs" id="domainTabs" role="tablist">
|
<p class="card-title text-muted">Avg. Progress Change</p>
|
||||||
<?php foreach ($domains as $domain): ?>
|
<h2 class="display-5"><?php echo number_format($avg_progress, 1); ?>%</h2>
|
||||||
<li class="nav-item" role="presentation">
|
|
||||||
<a class="nav-link <?php echo ($domain['id'] === $active_domain_id) ? 'active' : ''; ?>" href="?domain=<?php echo $domain['id']; ?>" role="tab"><?php echo htmlspecialchars($domain['name']); ?></a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="tab-content" id="domainTabsContent">
|
|
||||||
<div class="tab-pane fade show active" role="tabpanel">
|
|
||||||
<h3 class="mb-4">Domain: <?php echo htmlspecialchars($active_domain_name); ?></h3>
|
|
||||||
|
|
||||||
<!-- Overview Cards (KPIs) -->
|
|
||||||
<div class="row mb-4">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card text-center">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Residents in Domain</h5>
|
|
||||||
<p class="card-text fs-4"><?php echo $kpi_total_residents; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card text-center">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Avg. Risk Score</h5>
|
|
||||||
<p class="card-text fs-4"><?php echo $kpi_avg_risk; ?>%</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="card text-center text-danger">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">High-Risk</h5>
|
|
||||||
<p class="card-text fs-4"><?php echo $kpi_high_risk_count; ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<!-- Left Column: Risk/Drivers & Actions -->
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">Risk & Drivers</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Top Risk Drivers</h5>
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
<?php foreach ($top_drivers as $driver): ?>
|
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
<?php echo htmlspecialchars($driver['label']); ?>
|
|
||||||
<span class="badge bg-danger rounded-pill"><?php echo ($driver['weight'] * 100); ?>%</span>
|
|
||||||
</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Actions</div>
|
|
||||||
<div class="list-group list-group-flush">
|
|
||||||
<a href="#" class="list-group-item list-group-item-action"><i class="bi bi-ui-checks me-2"></i>Launch Follow-Up Survey</a>
|
|
||||||
<a href="create_referral.php" class="list-group-item list-group-item-action"><i class="bi bi-send me-2"></i>Create Referral</a>
|
|
||||||
<a href="add_case_note.php" class="list-group-item list-group-item-action"><i class="bi bi-journal-plus me-2"></i>Add Note</a>
|
|
||||||
<a href="#" class="list-group-item list-group-item-action"><i class="bi bi-check2-square me-2"></i>New Task</a>
|
|
||||||
<a href="#" class="list-group-item list-group-item-action text-success"><i class="bi bi-download me-2"></i>Export Domain Data (CSV)</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Right Column: Timeline & Summary Tables -->
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">Domain Timeline</div>
|
|
||||||
<div class="card-body" style="height: 200px; overflow-y: auto;">
|
|
||||||
<p class="text-muted">[Placeholder for chronological stream of events: survey responses, notes, referrals, etc.]</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">Summary: Survey Responses</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-sm">
|
|
||||||
<thead>
|
|
||||||
<tr><th>Resident</th><th>Question</th><th>Answer</th><th>Date</th></tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php if (!empty($survey_responses)): ?>
|
|
||||||
<?php foreach ($survey_responses as $resp): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo htmlspecialchars($resp['first_name'] . ' ' . $resp['last_name']); ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($resp['question_label']); ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($resp['answer_value']); ?></td>
|
|
||||||
<td><?php echo date('M j, Y', strtotime($resp['answered_at'])); ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<tr><td colspan="4" class="text-center text-muted">No survey responses for this domain yet.</td></tr>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<!-- Critical Alerts Section -->
|
||||||
</body>
|
<?php if (!empty($alert_residents)): ?>
|
||||||
</html>
|
<div class="card shadow-sm mb-4 border-danger">
|
||||||
|
<div class="card-header bg-danger text-white">
|
||||||
|
<h5 class="mb-0"><i class="fas fa-exclamation-triangle me-2"></i>Critical Warning Alerts</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach ($alert_residents as $res): ?>
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<a href="resident_view.php?resident_id=<?php echo $res['id']; ?>" class="fw-bold text-decoration-none"><?php echo htmlspecialchars($res['name']); ?></a>
|
||||||
|
<small class="text-muted ms-2">Risk Score: <?php echo $res['risk_score']; ?>%</small>
|
||||||
|
</div>
|
||||||
|
<a href="resident_view.php?resident_id=<?php echo $res['id']; ?>" class="btn btn-sm btn-outline-primary">View Plan</a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- All Residents List -->
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
|
<h5 class="mb-0">All Residents</h5>
|
||||||
|
<form class="d-flex" method="GET" action="staff_dashboard.php">
|
||||||
|
<input class="form-control me-2" type="search" placeholder="Search residents..." name="search" value="<?php echo htmlspecialchars($search_query); ?>">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit">Search</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover mb-0">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th class="text-center">Risk Score</th>
|
||||||
|
<th class="text-center">Progress</th>
|
||||||
|
<th>Last Check-In</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if (empty($residents)): ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="text-center text-muted">No residents found.</td>
|
||||||
|
</tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($residents as $resident): ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="resident_view.php?resident_id=<?php echo $resident['id']; ?>" class="text-decoration-none fw-bold"><?php echo htmlspecialchars($resident['name']); ?></a>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<span class="badge bg-<?php echo $resident['risk_score'] > 75 ? 'danger' : ($resident['risk_score'] > 50 ? 'warning' : 'success'); ?>">
|
||||||
|
<?php echo $resident['risk_score']; ?>%
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<span class="text-<?php echo $resident['progress'] >= 0 ? 'success' : 'danger'; ?>">
|
||||||
|
<i class="fas fa-arrow-<?php echo $resident['progress'] >= 0 ? 'up' : 'down'; ?>"></i>
|
||||||
|
<?php echo abs($resident['progress']); ?>%
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td><?php echo $resident['last_check_in']; ?></td>
|
||||||
|
<td class="text-end">
|
||||||
|
<a href="resident_view.php?resident_id=<?php echo $resident['id']; ?>" class="btn btn-sm btn-primary">View</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'includes/footer.php'; // Assuming a footer file exists ?>
|
||||||
Loading…
x
Reference in New Issue
Block a user