113 lines
4.9 KiB
PHP
113 lines
4.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
$pdo = db();
|
|
|
|
// Fetch the logged-in resident's data
|
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE user_id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$resident) {
|
|
$no_profile_message = "Your profile is not yet linked. Please contact support.";
|
|
} else {
|
|
// Fetch action plans for the resident
|
|
$stmt = $pdo->prepare("SELECT * FROM action_plans WHERE resident_id = ? ORDER BY created_at DESC");
|
|
$stmt->execute([$resident['id']]);
|
|
$action_plans = $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>Resident Dashboard - Continuum of Healing</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-fluid">
|
|
<a class="navbar-brand" href="resident_dashboard.php">Continuum of Healing</a>
|
|
<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 active" href="resident_dashboard.php">Dashboard</a>
|
|
</li>
|
|
</ul>
|
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-4">
|
|
<?php if (isset($no_profile_message)): ?>
|
|
<div class="alert alert-warning"><?php echo $no_profile_message; ?></div>
|
|
<?php elseif (isset($resident)): ?>
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h2">Welcome, <?php echo htmlspecialchars($resident['first_name']); ?>!</h1>
|
|
</div>
|
|
|
|
<!-- Your Information Card -->
|
|
<div class="card mb-4">
|
|
<div class="card-header">Your Information</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<p><strong>Name:</strong> <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></p>
|
|
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<p><strong>Status:</strong> <span class="badge bg-success"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Your Action Plans Card -->
|
|
<div class="card">
|
|
<div class="card-header">Your Action Plans</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Status</th>
|
|
<th>Due Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($action_plans)): ?>
|
|
<tr>
|
|
<td colspan="3" class="text-center">You have no action plans.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($action_plans as $plan): ?>
|
|
<tr>
|
|
<td><a href="view_action_plan.php?id=<?php echo $plan['id']; ?>"><?php echo htmlspecialchars($plan['title']); ?></a></td>
|
|
<td><span class="badge bg-info"><?php echo htmlspecialchars($plan['status']); ?></span></td>
|
|
<td><?php echo htmlspecialchars($plan['due_date'] ? date("M j, Y", strtotime($plan['due_date'])) : 'N/A'); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|