From 515d5888d3f20852ee152370aacbc548cd5a5f0f Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 30 Oct 2025 00:25:31 +0000 Subject: [PATCH] Auto commit: 2025-10-30T00:25:31.871Z --- calendar.php | 123 +++++++++++++++++++++++++++ messages.php | 95 +++++++++++++++++++++ resident_compose_message.php | 84 +++++++++++++++++++ resident_dashboard.php | 157 ++++++++++++++++++++++++++--------- resources.php | 74 +++++++++++++++++ save_check_in.php | 34 ++++++++ send_message.php | 13 ++- view_message.php | 42 ++++++++-- 8 files changed, 571 insertions(+), 51 deletions(-) create mode 100644 calendar.php create mode 100644 messages.php create mode 100644 resident_compose_message.php create mode 100644 resources.php create mode 100644 save_check_in.php diff --git a/calendar.php b/calendar.php new file mode 100644 index 0000000..3059584 --- /dev/null +++ b/calendar.php @@ -0,0 +1,123 @@ +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; +} + +?> + + + + + + Appointment Calendar - Continuum of Healing + + + + + + + + +
+
+

Appointment Calendar

+
+ ‹ Prev + + Next › +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
SunMonTueWedThuFriSat
+ + + +
+ - +
+ + +
+
+
+ + + + \ No newline at end of file diff --git a/messages.php b/messages.php new file mode 100644 index 0000000..c63f420 --- /dev/null +++ b/messages.php @@ -0,0 +1,95 @@ +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); + +?> + + + + + + My Messages - Continuum of Healing + + + + + + + +
+
+

My Messages

+ New Message +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
SubjectFrom/ToDate
You have no messages.
View
+
+
+
+
+ + + + diff --git a/resident_compose_message.php b/resident_compose_message.php new file mode 100644 index 0000000..d6cef17 --- /dev/null +++ b/resident_compose_message.php @@ -0,0 +1,84 @@ +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."; +} + +?> + + + + + + Compose Message - Continuum of Healing + + + + + + +
+
+

Compose New Message

+ ← Back to Messages +
+ + +
+ +
+
+
+
+ + + +
+
+ + +
+
+ + +
+ +
+
+
+ +
+ + + + diff --git a/resident_dashboard.php b/resident_dashboard.php index d2ea055..977c4a9 100644 --- a/resident_dashboard.php +++ b/resident_dashboard.php @@ -31,6 +31,7 @@ if (!$resident) { Resident Dashboard - Continuum of Healing + @@ -43,6 +44,15 @@ if (!$resident) { + + + Logout @@ -50,6 +60,13 @@ if (!$resident) {
+ +
Your check-in has been saved.
+ + +
There was an error saving your check-in. Please try again.
+ +
@@ -57,51 +74,109 @@ if (!$resident) {

Welcome, !

- -
-
Your Information
-
-
-
-

Name:

-

Program:

+
+
+ +
+
+
Daily Check-In
-
-

Status:

+
+
+ +
+ +
+ + + + + +
+
+
+ + +
+ +
+
+
+ + +
+
+
Active Action Plans
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
TitleStatusDue Date
You have no active action plans.
View
+
-
- - -
-
Your Action Plans
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
TitleStatusDue Date
You have no action plans.
+
+ +
+
+
Your Information
+
+
+

Name:

+

Program:

+

Status:

+
+
+ +
+
+
Your Progress
+
+
+
+ +
+
%
+
+
+
+ +
+
%
+
+
+
+ +
+
%
+
+
+
diff --git a/resources.php b/resources.php new file mode 100644 index 0000000..e18d214 --- /dev/null +++ b/resources.php @@ -0,0 +1,74 @@ +query("SELECT * FROM resources ORDER BY category, title"); +$resources_by_category = []; +while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $resources_by_category[$row['category']][] = $row; +} + +?> + + + + + + Resource Library - Continuum of Healing + + + + + + + +
+
+

Resource Library

+
+ + $resources): ?> +

+
+ + +
+
+
+

+
+ +
+ + +
+ + + + diff --git a/save_check_in.php b/save_check_in.php new file mode 100644 index 0000000..1e778e5 --- /dev/null +++ b/save_check_in.php @@ -0,0 +1,34 @@ +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; +} diff --git a/send_message.php b/send_message.php index cd0ba0c..d033290 100644 --- a/send_message.php +++ b/send_message.php @@ -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; -} +} \ No newline at end of file diff --git a/view_message.php b/view_message.php index 0711c56..f25b73f 100644 --- a/view_message.php +++ b/view_message.php @@ -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'; +} + + ?> @@ -51,15 +71,25 @@ if ($message['recipient_user_id'] == $_SESSION['user_id'] && !$message['read_at'
@@ -92,4 +122,4 @@ if ($message['recipient_user_id'] == $_SESSION['user_id'] && !$message['read_at' - + \ No newline at end of file