10 30 2
This commit is contained in:
parent
9a4b6fd7bc
commit
540e3681d5
93
location_view.php
Normal file
93
location_view.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Check if user is logged in and has the 'staff' role
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Fetch resident counts by location
|
||||||
|
$location_counts = $pdo->query("
|
||||||
|
SELECT state, county, city, COUNT(id) as resident_count
|
||||||
|
FROM residents
|
||||||
|
GROUP BY state, county, city
|
||||||
|
ORDER BY state, county, city
|
||||||
|
")->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>Resident Location View | 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-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="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="staff_dashboard.php">Dashboard</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="location_view.php">Location View</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="h2 mb-4">Resident Counts by Location</h1>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>State</th>
|
||||||
|
<th>County</th>
|
||||||
|
<th>City</th>
|
||||||
|
<th class="text-end">Resident Count</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if (!empty($location_counts)): ?>
|
||||||
|
<?php foreach ($location_counts as $location): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($location['state']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($location['county']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($location['city']); ?></td>
|
||||||
|
<td class="text-end"><?php echo $location['resident_count']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="text-center text-muted">No location data available.</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -20,33 +20,41 @@ if (!$partner) {
|
|||||||
} else {
|
} else {
|
||||||
$partner_id = $partner['id'];
|
$partner_id = $partner['id'];
|
||||||
|
|
||||||
// -- Performance Summary --
|
// -- Fetch assigned residents and their domain scores --
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM residents WHERE partner_id = ?");
|
|
||||||
$stmt->execute([$partner_id]);
|
|
||||||
$total_assigned = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM residents WHERE partner_id = ? AND status = 'Active'");
|
|
||||||
$stmt->execute([$partner_id]);
|
|
||||||
$active_assigned = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM referrals WHERE partner_id = ?");
|
|
||||||
$stmt->execute([$partner_id]);
|
|
||||||
$total_referrals = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
// -- Resident Data --
|
|
||||||
$resident_sql = "
|
$resident_sql = "
|
||||||
SELECT
|
SELECT
|
||||||
r.id, r.first_name, r.last_name, r.program, r.risk_level, r.status,
|
r.id, r.first_name, r.last_name, r.program, r.status,
|
||||||
(SELECT COUNT(*) FROM action_plans ap WHERE ap.resident_id = r.id AND ap.status != 'Completed') as open_plans_count,
|
GROUP_CONCAT(rs.domain, ':', rs.score_int, ':', rs.level SEPARATOR ';') as domain_data
|
||||||
(SELECT note FROM case_notes WHERE resident_id = r.id ORDER BY created_at DESC LIMIT 1) as last_note,
|
|
||||||
(SELECT created_at FROM case_notes WHERE resident_id = r.id ORDER BY created_at DESC LIMIT 1) as last_note_date
|
|
||||||
FROM residents r
|
FROM residents r
|
||||||
|
LEFT JOIN risk_scores rs ON r.id = rs.resident_id
|
||||||
WHERE r.partner_id = ?
|
WHERE r.partner_id = ?
|
||||||
|
GROUP BY r.id
|
||||||
ORDER BY r.last_name, r.first_name
|
ORDER BY r.last_name, r.first_name
|
||||||
";
|
";
|
||||||
$resident_stmt = $pdo->prepare($resident_sql);
|
$resident_stmt = $pdo->prepare($resident_sql);
|
||||||
$resident_stmt->execute([$partner_id]);
|
$resident_stmt->execute([$partner_id]);
|
||||||
$residents = $resident_stmt->fetchAll(PDO::FETCH_ASSOC);
|
$residents_raw = $resident_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$residents = array_map(function($res) {
|
||||||
|
$res['domains'] = [];
|
||||||
|
if ($res['domain_data']) {
|
||||||
|
$domains_list = explode(';', $res['domain_data']);
|
||||||
|
foreach ($domains_list as $d) {
|
||||||
|
list($domain, $score, $level) = explode(':', $d);
|
||||||
|
$res['domains'][$domain] = ['score' => $score, 'level' => $level];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($res['domain_data']);
|
||||||
|
return $res;
|
||||||
|
}, $residents_raw);
|
||||||
|
|
||||||
|
// -- Performance Summary --
|
||||||
|
$total_assigned = count($residents);
|
||||||
|
$active_assigned = count(array_filter($residents, fn($r) => $r['status'] === 'Active'));
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT COUNT(*) FROM referrals WHERE partner_id = ?");
|
||||||
|
$stmt->execute([$partner_id]);
|
||||||
|
$total_referrals = $stmt->fetchColumn();
|
||||||
|
|
||||||
// -- Referral Data --
|
// -- Referral Data --
|
||||||
$referral_sql = "
|
$referral_sql = "
|
||||||
@ -160,8 +168,8 @@ if (!$partner) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Resident Health Cards -->
|
<!-- Resident Domain-Focused View -->
|
||||||
<h3 class="h4 mb-3">Assigned Resident Health Cards</h3>
|
<h3 class="h4 mb-3">Assigned Resident Overview</h3>
|
||||||
<div class="row gy-4">
|
<div class="row gy-4">
|
||||||
<?php if (empty($residents)): ?>
|
<?php if (empty($residents)): ?>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -169,43 +177,36 @@ if (!$partner) {
|
|||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($residents as $resident): ?>
|
<?php foreach ($residents as $resident): ?>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-12 col-lg-6">
|
||||||
<div class="card h-100 shadow-sm">
|
<div class="card h-100 shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center bg-light">
|
<div class="card-header bg-light">
|
||||||
<h5 class="mb-0 fs-6"><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h5>
|
<h5 class="mb-0"><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h5>
|
||||||
<?php
|
|
||||||
$risk_color = 'secondary';
|
|
||||||
if ($resident['risk_level'] === 'High') $risk_color = 'danger';
|
|
||||||
if ($resident['risk_level'] === 'Medium') $risk_color = 'warning';
|
|
||||||
?>
|
|
||||||
<span class="badge bg-<?php echo $risk_color; ?>"><?php echo htmlspecialchars($resident['risk_level']); ?></span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text mb-2">
|
<p class="card-text mb-2">
|
||||||
<strong><i class="bi bi-clipboard-check me-2"></i>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?>
|
<strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?><br>
|
||||||
|
<strong>Status:</strong>
|
||||||
|
<span class="badge bg-<?php echo $resident['status'] === 'Active' ? 'success' : 'secondary'; ?>"><?php echo htmlspecialchars($resident['status']); ?></span>
|
||||||
</p>
|
</p>
|
||||||
<p class="card-text mb-3">
|
<h6 class="card-subtitle mt-3 mb-2 text-muted">Domain Risk Levels:</h6>
|
||||||
<strong><i class="bi bi-activity me-2"></i>Status:</strong>
|
<div class="d-flex justify-content-around text-center">
|
||||||
<?php
|
<?php
|
||||||
$status_color = 'primary';
|
$domain_map = ['economic' => 'EC', 'education' => 'ED', 'healthcare' => 'HC', 'neighborhood' => 'NB', 'social' => 'SO'];
|
||||||
if ($resident['status'] === 'Inactive') $status_color = 'secondary';
|
foreach ($domain_map as $domain_id => $abbr):
|
||||||
if ($resident['status'] === 'Stabilized') $status_color = 'success';
|
$level = $resident['domains'][$domain_id]['level'] ?? 'N/A';
|
||||||
|
$level_class = 'bg-secondary';
|
||||||
|
if ($level === 'High') $level_class = 'bg-danger';
|
||||||
|
if ($level === 'Moderate') $level_class = 'bg-warning text-dark';
|
||||||
|
if ($level === 'Low') $level_class = 'bg-success';
|
||||||
?>
|
?>
|
||||||
<span class="badge bg-<?php echo $status_color; ?>"><?php echo htmlspecialchars($resident['status']); ?></span>
|
<div>
|
||||||
</p>
|
<span class="badge <?php echo $level_class; ?>" title="<?php echo htmlspecialchars(ucfirst($domain_id)); ?>"><?php echo $abbr; ?></span>
|
||||||
<div class="d-flex justify-content-between align-items-center border-top pt-2">
|
|
||||||
<small class="text-muted"><i class="bi bi-card-checklist me-1"></i> Open Action Plans</small>
|
|
||||||
<span class="badge rounded-pill bg-primary-custom"><?php echo $resident['open_plans_count']; ?></span>
|
|
||||||
</div>
|
</div>
|
||||||
<h6 class="card-subtitle mb-2 mt-3 text-muted border-top pt-2"><i class="bi bi-chat-left-text me-2"></i>Last Note</h6>
|
<?php endforeach; ?>
|
||||||
<p class="card-text fst-italic small">
|
</div>
|
||||||
<?php if ($resident['last_note']): ?>
|
</div>
|
||||||
"<?php echo htmlspecialchars(substr($resident['last_note'], 0, 80)); ?>..."
|
<div class="card-footer bg-white text-end">
|
||||||
<br><small class="text-muted"> on <?php echo date("M j, Y", strtotime($resident['last_note_date'])); ?></small>
|
<a href="#" class="btn btn-sm btn-outline-primary">View Details</a>
|
||||||
<?php else: ?>
|
|
||||||
<span class="text-muted">No notes recorded yet.</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,44 +2,48 @@
|
|||||||
session_start();
|
session_start();
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'resident') {
|
// Check if user is logged in and has the 'resident' role
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit();
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resident_id = $_SESSION['user_id'];
|
$resident_id = $_SESSION['user_id'];
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
// Fetch resident's name
|
// Fetch resident's first name
|
||||||
$stmt = $pdo->prepare("SELECT name FROM residents WHERE id = ?");
|
$stmt = $pdo->prepare("SELECT first_name FROM residents WHERE id = ?");
|
||||||
$stmt->execute([$resident_id]);
|
$stmt->execute([$resident_id]);
|
||||||
$resident = $stmt->fetch();
|
$resident_name = $stmt->fetchColumn();
|
||||||
|
|
||||||
// Fetch resident's domain scores
|
// Fetch resident's domain risk scores, levels, and drivers
|
||||||
$stmt = $pdo->prepare("
|
$risk_scores_stmt = $pdo->prepare("
|
||||||
SELECT d.name, rds.score
|
SELECT domain, score_int, level, drivers
|
||||||
FROM resident_domain_scores rds
|
FROM risk_scores
|
||||||
JOIN domains d ON rds.domain_id = d.id
|
WHERE resident_id = ?
|
||||||
WHERE rds.resident_id = ?
|
ORDER BY domain
|
||||||
ORDER BY d.id
|
|
||||||
");
|
");
|
||||||
$stmt->execute([$resident_id]);
|
$risk_scores_stmt->execute([$resident_id]);
|
||||||
$domain_scores = $stmt->fetchAll();
|
$risk_scores = $risk_scores_stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);
|
||||||
|
|
||||||
// Fetch resident's action plans
|
// Fetch resident's action plans
|
||||||
$stmt = $pdo->prepare("
|
$action_plans_stmt = $pdo->prepare("
|
||||||
SELECT ap.id, ap.title, ap.description, ap.status, d.name as domain_name
|
SELECT ap.id, ap.title, ap.status, ap.domain
|
||||||
FROM action_plans ap
|
FROM action_plans ap
|
||||||
JOIN domains d ON ap.domain_id = d.id
|
|
||||||
WHERE ap.resident_id = ?
|
WHERE ap.resident_id = ?
|
||||||
ORDER BY ap.created_at DESC
|
ORDER BY ap.created_at DESC
|
||||||
");
|
");
|
||||||
$stmt->execute([$resident_id]);
|
$action_plans_stmt->execute([$resident_id]);
|
||||||
$action_plans = $stmt->fetchAll();
|
$action_plans = $action_plans_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// Fetch resident's case manager for messaging
|
// Domain names mapping
|
||||||
$stmt = $pdo->prepare("SELECT u.id, u.name, u.email FROM users u JOIN residents r ON u.id = r.case_manager_id WHERE r.id = ?");
|
$domains = [
|
||||||
$stmt->execute([$resident_id]);
|
'economic' => 'Economic Stability',
|
||||||
$case_manager = $stmt->fetch();
|
'education' => 'Education Access & Quality',
|
||||||
|
'healthcare' => 'Health Care Access & Quality',
|
||||||
|
'neighborhood' => 'Neighborhood & Built Environment',
|
||||||
|
'social' => 'Social & Community Context',
|
||||||
|
];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -47,87 +51,91 @@ $case_manager = $stmt->fetch();
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Resident Dashboard - Continuum Nexus</title>
|
<title>Resident Dashboard | Continuum Nexus</title>
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
<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/5.15.4/css/all.min.css">
|
<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">
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
<style>
|
|
||||||
.progress-bar {
|
|
||||||
color: #212529;
|
|
||||||
background-color: #e9ecef;
|
|
||||||
}
|
|
||||||
.progress-bar-striped {
|
|
||||||
background-size: 1rem 1rem;
|
|
||||||
}
|
|
||||||
.domain-card {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include 'includes/resident_header.php'; ?>
|
<?php include 'includes/resident_header.php'; ?>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<h2>Welcome, <?php echo htmlspecialchars($resident['name']); ?>!</h2>
|
<h1 class="h2">Welcome, <?php echo htmlspecialchars($resident_name); ?>!</h1>
|
||||||
<div>
|
<div>
|
||||||
<?php if ($case_manager): ?>
|
<a href="messages.php" class="btn btn-primary-custom"><i class="bi bi-inbox-fill me-2"></i>My Messages</a>
|
||||||
<a href="resident_compose_message.php?recipient_id=<?php echo $case_manager['id']; ?>" class="btn btn-primary"><i class="fas fa-envelope"></i> Message Case Manager</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<a href="messages.php" class="btn btn-info"><i class="fas fa-inbox"></i> View Messages</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h3 class="mb-4">Your Domain Overview</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<?php foreach ($domains as $domain_id => $domain_name): ?>
|
||||||
<h4>Your Progress Across the 5 Domains</h4>
|
<?php
|
||||||
<div class="row">
|
$score_data = $risk_scores[$domain_id][0] ?? null;
|
||||||
<?php foreach ($domain_scores as $domain): ?>
|
$score = $score_data ? (int)$score_data['score_int'] : 0;
|
||||||
<div class="col-md-6">
|
$level = $score_data ? ucfirst($score_data['level']) : 'N/A';
|
||||||
<div class="card domain-card">
|
$drivers = $score_data && $score_data['drivers'] ? json_decode($score_data['drivers'], true) : [];
|
||||||
|
|
||||||
|
$level_class = 'text-bg-secondary';
|
||||||
|
if ($level === 'High') $level_class = 'text-bg-danger';
|
||||||
|
if ($level === 'Moderate') $level_class = 'text-bg-warning';
|
||||||
|
if ($level === 'Low') $level_class = 'text-bg-success';
|
||||||
|
?>
|
||||||
|
<div class="col-md-6 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
|
<h5 class="mb-0"><?php echo htmlspecialchars($domain_name); ?></h5>
|
||||||
|
<span class="badge <?php echo $level_class; ?>"><?php echo htmlspecialchars($level); ?></span>
|
||||||
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title"><?php echo htmlspecialchars($domain['name']); ?></h5>
|
<div class="text-center mb-3">
|
||||||
<div class="progress" style="height: 25px;">
|
<p class="display-4 fw-bold mb-0"><?php echo $score; ?><span class="fs-5">/100</span></p>
|
||||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: <?php echo htmlspecialchars($domain['score']); ?>%;" aria-valuenow="<?php echo htmlspecialchars($domain['score']); ?>" aria-valuemin="0" aria-valuemax="100">
|
<p class="text-muted mb-0">Risk Score</p>
|
||||||
<strong><?php echo htmlspecialchars($domain['score']); ?>%</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (!empty($drivers)): ?>
|
||||||
|
<h6 class="card-subtitle mb-2 text-muted">Key Factors:</h6>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach ($drivers as $driver): ?>
|
||||||
|
<li class="list-group-item">- <?php echo htmlspecialchars($driver['label']); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="text-muted text-center">No specific risk factors identified.</p>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h4><i class="fas fa-tasks"></i> Your Active Action Plans</h4>
|
<h4 class="mb-0"><i class="bi bi-list-check me-2"></i>Your Action Plans</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover align-middle">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Domain</th>
|
<th>Domain</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Action</th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if (empty($action_plans)): ?>
|
<?php if (empty($action_plans)): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4">You have no active action plans.</td>
|
<td colspan="4" class="text-center text-muted">You have no active action plans.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($action_plans as $plan): ?>
|
<?php foreach ($action_plans as $plan): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo htmlspecialchars($plan['title']); ?></td>
|
<td><?php echo htmlspecialchars($plan['title']); ?></td>
|
||||||
<td><span class="badge badge-info"><?php echo htmlspecialchars($plan['domain_name']); ?></span></td>
|
<td><span class="badge text-bg-info"><?php echo htmlspecialchars($domains[$plan['domain']] ?? 'N/A'); ?></span></td>
|
||||||
<td><span class="badge badge-primary"><?php echo htmlspecialchars(ucfirst($plan['status'])); ?></span></td>
|
<td><span class="badge text-bg-primary"><?php echo htmlspecialchars(ucfirst($plan['status'])); ?></span></td>
|
||||||
<td>
|
<td class="text-end">
|
||||||
<a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-sm btn-info">View Details</a>
|
<a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-sm btn-outline-primary">View</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@ -138,36 +146,8 @@ $case_manager = $stmt->fetch();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-6 mb-4">
|
|
||||||
<div class="card h-100">
|
|
||||||
<div class="card-header">
|
|
||||||
<h4><i class="far fa-calendar-alt"></i> Upcoming Appointments</h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<!-- Placeholder for calendar -->
|
|
||||||
<p>Your appointment calendar will be displayed here.</p>
|
|
||||||
<a href="calendar.php" class="btn btn-primary">View Calendar</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 mb-4">
|
|
||||||
<div class="card h-100">
|
|
||||||
<div class="card-header">
|
|
||||||
<h4><i class="fas fa-book"></i> Resource Library</h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>Access helpful documents, links, and guides.</p>
|
|
||||||
<a href="resources.php" class="btn btn-primary">Browse Resources</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -29,19 +29,48 @@ foreach ($domains as $domain) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- Get search term --
|
||||||
|
$search_term = $_GET['search'] ?? '';
|
||||||
|
|
||||||
// --- DATA FETCHING FOR THE ACTIVE DOMAIN ---
|
// --- DATA FETCHING FOR THE ACTIVE DOMAIN ---
|
||||||
|
|
||||||
// KPI: Total Residents in this domain (placeholder)
|
// Base query for residents
|
||||||
$kpi_total_residents = $pdo->query("SELECT COUNT(DISTINCT resident_id) FROM risk_scores WHERE domain = '{$active_domain_id}'")->fetchColumn();
|
$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%";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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: Average Risk Score
|
||||||
$kpi_avg_risk = $pdo->prepare("SELECT AVG(score_int) FROM risk_scores WHERE domain = ?");
|
$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 = ?";
|
||||||
$kpi_avg_risk->execute([$active_domain_id]);
|
$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_avg_risk = round($kpi_avg_risk->fetchColumn() ?? 0);
|
||||||
|
|
||||||
// KPI: High-Risk Residents
|
// KPI: High-Risk Residents
|
||||||
$kpi_high_risk_count = $pdo->prepare("SELECT COUNT(*) FROM risk_scores WHERE domain = ? AND level = 'high'");
|
$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'";
|
||||||
$kpi_high_risk_count->execute([$active_domain_id]);
|
$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();
|
$kpi_high_risk_count = $kpi_high_risk_count->fetchColumn();
|
||||||
|
|
||||||
// Risk & Drivers: Top Drivers (Placeholder - requires JSON processing)
|
// Risk & Drivers: Top Drivers (Placeholder - requires JSON processing)
|
||||||
@ -52,11 +81,19 @@ $top_drivers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Summary Table: Survey Responses
|
// Summary Table: Survey Responses
|
||||||
$survey_responses_stmt = $pdo->prepare("SELECT r.first_name, r.last_name, sr.question_label, sr.answer_value, sr.answered_at
|
$survey_sql = "SELECT r.first_name, r.last_name, sr.question_label, sr.answer_value, sr.answered_at
|
||||||
FROM survey_responses sr
|
FROM survey_responses sr
|
||||||
JOIN residents r ON sr.resident_id = r.id
|
JOIN residents r ON sr.resident_id = r.id
|
||||||
WHERE sr.domain = ? ORDER BY sr.answered_at DESC LIMIT 10");
|
WHERE sr.domain = ?";
|
||||||
$survey_responses_stmt->execute([$active_domain_id]);
|
$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);
|
$survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -83,6 +120,9 @@ $survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="staff_dashboard.php">Dashboard</a>
|
<a class="nav-link active" aria-current="page" href="staff_dashboard.php">Dashboard</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="location_view.php">Location View</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
</div>
|
</div>
|
||||||
@ -95,6 +135,22 @@ $survey_responses = $survey_responses_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
<a href="resident_intake.php" class="btn btn-primary-custom"><i class="bi bi-plus-circle me-2"></i>New Resident</a>
|
<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 class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<ul class="nav nav-tabs card-header-tabs" id="domainTabs" role="tablist">
|
<ul class="nav nav-tabs card-header-tabs" id="domainTabs" role="tablist">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user