174 lines
7.2 KiB
PHP
174 lines
7.2 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'resident') {
|
|
header("Location: index.php");
|
|
exit();
|
|
}
|
|
|
|
$resident_id = $_SESSION['user_id'];
|
|
|
|
// Fetch resident's name
|
|
$stmt = $pdo->prepare("SELECT name FROM residents WHERE id = ?");
|
|
$stmt->execute([$resident_id]);
|
|
$resident = $stmt->fetch();
|
|
|
|
// Fetch resident's domain scores
|
|
$stmt = $pdo->prepare("
|
|
SELECT d.name, rds.score
|
|
FROM resident_domain_scores rds
|
|
JOIN domains d ON rds.domain_id = d.id
|
|
WHERE rds.resident_id = ?
|
|
ORDER BY d.id
|
|
");
|
|
$stmt->execute([$resident_id]);
|
|
$domain_scores = $stmt->fetchAll();
|
|
|
|
// Fetch resident's action plans
|
|
$stmt = $pdo->prepare("
|
|
SELECT ap.id, ap.title, ap.description, ap.status, d.name as domain_name
|
|
FROM action_plans ap
|
|
JOIN domains d ON ap.domain_id = d.id
|
|
WHERE ap.resident_id = ?
|
|
ORDER BY ap.created_at DESC
|
|
");
|
|
$stmt->execute([$resident_id]);
|
|
$action_plans = $stmt->fetchAll();
|
|
|
|
// Fetch resident's case manager for messaging
|
|
$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 = ?");
|
|
$stmt->execute([$resident_id]);
|
|
$case_manager = $stmt->fetch();
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Resident Dashboard - Continuum Nexus</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.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>
|
|
<body>
|
|
<?php include 'includes/resident_header.php'; ?>
|
|
|
|
<div class="container mt-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2>Welcome, <?php echo htmlspecialchars($resident['name']); ?>!</h2>
|
|
<div>
|
|
<?php if ($case_manager): ?>
|
|
<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 class="row">
|
|
<div class="col-md-12">
|
|
<h4>Your Progress Across the 5 Domains</h4>
|
|
<div class="row">
|
|
<?php foreach ($domain_scores as $domain): ?>
|
|
<div class="col-md-6">
|
|
<div class="card domain-card">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($domain['name']); ?></h5>
|
|
<div class="progress" style="height: 25px;">
|
|
<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">
|
|
<strong><?php echo htmlspecialchars($domain['score']); ?>%</strong>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h4><i class="fas fa-tasks"></i> Your Active Action Plans</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Domain</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($action_plans)): ?>
|
|
<tr>
|
|
<td colspan="4">You have no active action plans.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($action_plans as $plan): ?>
|
|
<tr>
|
|
<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 badge-primary"><?php echo htmlspecialchars(ucfirst($plan['status'])); ?></span></td>
|
|
<td>
|
|
<a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-sm btn-info">View Details</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</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>
|
|
|
|
<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>
|
|
</html>
|