Auto commit: 2025-10-30T00:25:31.871Z
This commit is contained in:
parent
0f55e9d0b9
commit
515d5888d3
123
calendar.php
Normal file
123
calendar.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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 id
|
||||
$stmt = $pdo->prepare("SELECT id FROM residents WHERE user_id = ?");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$resident) {
|
||||
// Handle case where resident profile is not found
|
||||
die("Resident profile not found.");
|
||||
}
|
||||
$resident_id = $resident['id'];
|
||||
|
||||
// Basic Calendar Logic
|
||||
$month = isset($_GET['month']) ? (int)$_GET['month'] : date('m');
|
||||
$year = isset($_GET['year']) ? (int)$_GET['year'] : date('Y');
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$first_day_of_month = mktime(0, 0, 0, $month, 1, $year);
|
||||
$days_in_month = date('t', $first_day_of_month);
|
||||
$day_of_week = date('w', $first_day_of_month);
|
||||
|
||||
// Fetch appointments for the month
|
||||
$stmt = $pdo->prepare("SELECT * FROM appointments WHERE resident_id = ? AND MONTH(start_time) = ? AND YEAR(start_time) = ? ORDER BY start_time");
|
||||
$stmt->execute([$resident_id, $month, $year]);
|
||||
$appointments = [];
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$day = date('j', strtotime($row['start_time']));
|
||||
$appointments[$day][] = $row;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Appointment Calendar - 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">
|
||||
<style>
|
||||
.calendar-day { min-height: 120px; }
|
||||
.calendar-day-np { background-color: #f5f5f5; }
|
||||
.appointment { font-size: 0.8em; padding: 2px 5px; margin-bottom: 3px; border-radius: 3px; background-color: #e3f2fd; border-left: 3px solid #2196F3; }
|
||||
</style>
|
||||
</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" href="resident_dashboard.php">Dashboard</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="messages.php">Messages</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="resources.php">Resource Library</a></li>
|
||||
<li class="nav-item"><a class="nav-link active" href="calendar.php">Calendar</a></li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Appointment Calendar</h1>
|
||||
<div>
|
||||
<a href="?month=<?php echo date('m', strtotime('-1 month', $first_day_of_month)); ?>&year=<?php echo date('Y', strtotime('-1 month', $first_day_of_month)); ?>" class="btn btn-sm btn-outline-secondary">‹ Prev</a>
|
||||
<span class="mx-2 h4"><?php echo date('F Y', $first_day_of_month); ?></span>
|
||||
<a href="?month=<?php echo date('m', strtotime('+1 month', $first_day_of_month)); ?>&year=<?php echo date('Y', strtotime('+1 month', $first_day_of_month)); ?>" class="btn btn-sm btn-outline-secondary">Next ›</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<?php for ($i = 0; $i < $day_of_week; $i++): ?>
|
||||
<td class="calendar-day-np"></td>
|
||||
<?php endfor; ?>
|
||||
<?php for ($day = 1; $day <= $days_in_month; $day++): ?>
|
||||
<?php if ($day_of_week == 7): ?>
|
||||
</tr><tr>
|
||||
<?php $day_of_week = 0; ?>
|
||||
<?php endif; ?>
|
||||
<td class="calendar-day <?php echo date('Y-m-d', mktime(0,0,0,$month,$day,$year)) == $today ? 'table-primary' : ''; ?>">
|
||||
<strong><?php echo $day; ?></strong>
|
||||
<?php if (isset($appointments[$day])): ?>
|
||||
<?php foreach ($appointments[$day] as $appointment): ?>
|
||||
<div class="appointment" title="<?php echo htmlspecialchars($appointment['description']); ?>">
|
||||
<?php echo date('g:ia', strtotime($appointment['start_time'])); ?> - <?php echo htmlspecialchars($appointment['title']); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php $day_of_week++; ?>
|
||||
<?php endfor; ?>
|
||||
<?php for ($i = $day_of_week; $i < 7; $i++): ?>
|
||||
<td class="calendar-day-np"></td>
|
||||
<?php endfor; ?>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
95
messages.php
Normal file
95
messages.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Fetch messages for the resident
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT m.id, m.subject, m.created_at, m.read_at, u.email as other_party_email
|
||||
FROM messages m
|
||||
JOIN users u ON (m.sender_user_id = u.id AND m.recipient_user_id = ?) OR (m.recipient_user_id = u.id AND m.sender_user_id = ?)
|
||||
WHERE m.sender_user_id = ? OR m.recipient_user_id = ?
|
||||
ORDER BY m.created_at DESC
|
||||
");
|
||||
$stmt->execute([$user_id, $user_id, $user_id, $user_id]);
|
||||
$messages = $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>My Messages - 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" href="resident_dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="messages.php">Messages</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">My Messages</h1>
|
||||
<a href="resident_compose_message.php" class="btn btn-primary-custom">New Message</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Subject</th>
|
||||
<th>From/To</th>
|
||||
<th>Date</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($messages)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">You have no messages.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($messages as $message): ?>
|
||||
<tr class="<?php echo !$message['read_at'] ? 'fw-bold' : ''; ?>">
|
||||
<td><?php echo htmlspecialchars($message['subject']); ?></td>
|
||||
<td><?php echo htmlspecialchars($message['other_party_email']); ?></td>
|
||||
<td><?php echo date("M j, Y, g:i a", strtotime($message['created_at'])); ?></td>
|
||||
<td><a href="view_message.php?id=<?php echo $message['id']; ?>" class="btn btn-sm btn-primary">View</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?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>
|
||||
84
resident_compose_message.php
Normal file
84
resident_compose_message.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Get resident's case manager
|
||||
$stmt = $pdo->prepare("SELECT u.id, u.email FROM users u JOIN residents r ON u.id = r.case_manager_id WHERE r.user_id = ?");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$case_manager = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$case_manager) {
|
||||
// Handle case where resident has no case manager assigned
|
||||
$error_message = "You do not have a case manager assigned. Please contact support.";
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Compose Message - 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" href="resident_dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="messages.php">Messages</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Compose New Message</h1>
|
||||
<a href="messages.php" class="btn btn-secondary">← Back to Messages</a>
|
||||
</div>
|
||||
|
||||
<?php if (isset($error_message)): ?>
|
||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||
<?php else: ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="send_message.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="recipient" class="form-label">To</label>
|
||||
<input type="text" id="recipient" class="form-control" value="<?php echo htmlspecialchars($case_manager['email']); ?>" readonly>
|
||||
<input type="hidden" name="recipient_user_id" value="<?php echo $case_manager['id']; ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="subject" class="form-label">Subject</label>
|
||||
<input type="text" name="subject" id="subject" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="body" class="form-label">Message</label>
|
||||
<textarea name="body" id="body" class="form-control" rows="8" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom">Send Message</button>
|
||||
</form>
|
||||
</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>
|
||||
@ -31,6 +31,7 @@ if (!$resident) {
|
||||
<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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
@ -43,6 +44,15 @@ if (!$resident) {
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="resident_dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="messages.php">Messages</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="resources.php">Resource Library</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="calendar.php">Appointment Calendar</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
@ -50,6 +60,13 @@ if (!$resident) {
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<?php if (isset($_GET['success']) && $_GET['success'] == 'checkin_saved'): ?>
|
||||
<div class="alert alert-success">Your check-in has been saved.</div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_GET['error'])): ?>
|
||||
<div class="alert alert-danger">There was an error saving your check-in. Please try again.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($no_profile_message)): ?>
|
||||
<div class="alert alert-warning"><?php echo $no_profile_message; ?></div>
|
||||
<?php elseif (isset($resident)): ?>
|
||||
@ -57,51 +74,109 @@ if (!$resident) {
|
||||
<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 class="row">
|
||||
<div class="col-md-8">
|
||||
<!-- Daily Check-in -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Daily Check-In</h5>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Status:</strong> <span class="badge bg-success"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
||||
<div class="card-body">
|
||||
<form action="save_check_in.php" method="POST">
|
||||
<input type="hidden" name="resident_id" value="<?php echo $resident['id']; ?>">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">How are you feeling today?</label>
|
||||
<div class="d-flex justify-content-around mood-selector">
|
||||
<label class="mood-option"><input type="radio" name="mood_rating" value="1" required><i class="far fa-sad-tear fa-2x"></i></label>
|
||||
<label class="mood-option"><input type="radio" name="mood_rating" value="2"><i class="far fa-frown fa-2x"></i></label>
|
||||
<label class="mood-option"><input type="radio" name="mood_rating" value="3"><i class="far fa-meh fa-2x"></i></label>
|
||||
<label class="mood-option"><input type="radio" name="mood_rating" value="4"><i class="far fa-smile fa-2x"></i></label>
|
||||
<label class="mood-option"><input type="radio" name="mood_rating" value="5"><i class="far fa-grin-beam fa-2x"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="journal_entry" class="form-label">Journal Entry (optional)</label>
|
||||
<textarea name="journal_entry" id="journal_entry" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom">Save Check-In</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Your Action Plans Card -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Active Action Plans</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Status</th>
|
||||
<th>Due Date</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($action_plans)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">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 bg-info text-dark"><?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>
|
||||
<td><a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-sm btn-primary">View</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</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 class="col-.md-4">
|
||||
<!-- Your Information Card -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Your Information</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><strong>Name:</strong> <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></p>
|
||||
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
||||
<p><strong>Status:</strong> <span class="badge bg-success"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Personalized Progress Tracker -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Your Progress</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div>
|
||||
<label class="form-label">Health</label>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" style="width: <?php echo $resident['health_progress'] ?? 0; ?>%;" aria-valuenow="<?php echo $resident['health_progress'] ?? 0; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $resident['health_progress'] ?? 0; ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label class="form-label">Housing</label>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" style="width: <?php echo $resident['housing_progress'] ?? 0; ?>%;" aria-valuenow="<?php echo $resident['housing_progress'] ?? 0; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $resident['housing_progress'] ?? 0; ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label class="form-label">Employment</label>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" style="width: <?php echo $resident['employment_progress'] ?? 0; ?>%;" aria-valuenow="<?php echo $resident['employment_progress'] ?? 0; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $resident['employment_progress'] ?? 0; ?>%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
74
resources.php
Normal file
74
resources.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?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 resources, grouped by category
|
||||
$stmt = $pdo->query("SELECT * FROM resources ORDER BY category, title");
|
||||
$resources_by_category = [];
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$resources_by_category[$row['category']][] = $row;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Resource Library - 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" href="resident_dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="messages.php">Messages</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="resources.php">Resource Library</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Resource Library</h1>
|
||||
</div>
|
||||
|
||||
<?php foreach ($resources_by_category as $category => $resources): ?>
|
||||
<h3 class="h4 mt-4"><?php echo htmlspecialchars($category); ?></h3>
|
||||
<div class="list-group">
|
||||
<?php foreach ($resources as $resource): ?>
|
||||
<a href="<?php echo htmlspecialchars($resource['url']); ?>" class="list-group-item list-group-item-action" target="_blank">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1"><?php echo htmlspecialchars($resource['title']); ?></h5>
|
||||
</div>
|
||||
<p class="mb-1"><?php echo htmlspecialchars($resource['description']); ?></p>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
34
save_check_in.php
Normal file
34
save_check_in.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: resident_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$resident_id = isset($_POST['resident_id']) ? (int)$_POST['resident_id'] : 0;
|
||||
$mood_rating = isset($_POST['mood_rating']) ? (int)$_POST['mood_rating'] : 0;
|
||||
$journal_entry = isset($_POST['journal_entry']) ? trim($_POST['journal_entry']) : '';
|
||||
|
||||
if ($resident_id === 0 || $mood_rating === 0) {
|
||||
header("Location: resident_dashboard.php?error=checkin_failed");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO check_ins (resident_id, mood_rating, journal_entry) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$resident_id, $mood_rating, $journal_entry]);
|
||||
|
||||
header("Location: resident_dashboard.php?success=checkin_saved");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
header("Location: resident_dashboard.php?error=checkin_failed");
|
||||
exit;
|
||||
}
|
||||
@ -17,9 +17,16 @@ $recipient_user_id = isset($_POST['recipient_user_id']) ? (int)$_POST['recipient
|
||||
$subject = isset($_POST['subject']) ? trim($_POST['subject']) : '';
|
||||
$body = isset($_POST['body']) ? trim($_POST['body']) : '';
|
||||
|
||||
$redirect_url = 'messages.php';
|
||||
if ($_SESSION['user_role'] === 'staff') {
|
||||
$redirect_url = 'staff_dashboard.php';
|
||||
} elseif ($_SESSION['user_role'] === 'partner') {
|
||||
$redirect_url = 'partner_dashboard.php';
|
||||
}
|
||||
|
||||
|
||||
if ($recipient_user_id === 0 || empty($subject) || empty($body)) {
|
||||
// Basic validation failed
|
||||
$redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php';
|
||||
header("Location: " . $redirect_url . "?error=empty_message");
|
||||
exit;
|
||||
}
|
||||
@ -29,12 +36,10 @@ try {
|
||||
$stmt = $pdo->prepare("INSERT INTO messages (sender_user_id, recipient_user_id, subject, body) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$sender_user_id, $recipient_user_id, $subject, $body]);
|
||||
|
||||
$redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php';
|
||||
header("Location: " . $redirect_url . "?success=message_sent");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, log this error.
|
||||
$redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php';
|
||||
header("Location: " . $redirect_url . "?error=db_error");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -7,9 +7,16 @@ if (!isset($_SESSION['user_id'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_role = $_SESSION['user_role'];
|
||||
|
||||
$message_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
if ($message_id === 0) {
|
||||
$redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php';
|
||||
$redirect_url = 'resident_dashboard.php';
|
||||
if ($user_role === 'staff') {
|
||||
$redirect_url = 'staff_dashboard.php';
|
||||
} elseif ($user_role === 'partner') {
|
||||
$redirect_url = 'partner_dashboard.php';
|
||||
}
|
||||
header("Location: " . $redirect_url);
|
||||
exit;
|
||||
}
|
||||
@ -28,7 +35,12 @@ $message = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$message || ($message['recipient_user_id'] != $_SESSION['user_id'] && $message['sender_user_id'] != $_SESSION['user_id'])) {
|
||||
// Message not found or user is not part of the conversation
|
||||
$redirect_url = ($_SESSION['user_role'] === 'staff') ? 'staff_dashboard.php' : 'partner_dashboard.php';
|
||||
$redirect_url = 'resident_dashboard.php';
|
||||
if ($user_role === 'staff') {
|
||||
$redirect_url = 'staff_dashboard.php';
|
||||
} elseif ($user_role === 'partner') {
|
||||
$redirect_url = 'partner_dashboard.php';
|
||||
}
|
||||
header("Location: " . $redirect_url . "?error=not_found");
|
||||
exit;
|
||||
}
|
||||
@ -38,6 +50,14 @@ if ($message['recipient_user_id'] == $_SESSION['user_id'] && !$message['read_at'
|
||||
$pdo->prepare("UPDATE messages SET read_at = NOW() WHERE id = ?")->execute([$message_id]);
|
||||
}
|
||||
|
||||
$back_link = 'messages.php';
|
||||
if ($user_role === 'staff') {
|
||||
$back_link = 'staff_dashboard.php';
|
||||
} elseif ($user_role === 'partner') {
|
||||
$back_link = 'partner_dashboard.php';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -51,15 +71,25 @@ if ($message['recipient_user_id'] == $_SESSION['user_id'] && !$message['read_at'
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Continuum of Healing</a>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
<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" href="resident_dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="messages.php">Messages</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">View Message</h1>
|
||||
<a href="partner_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||
<a href="<?php echo $back_link; ?>" class="btn btn-secondary">← Back to Messages</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
@ -92,4 +122,4 @@ if ($message['recipient_user_id'] == $_SESSION['user_id'] && !$message['read_at'
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user