draft 2
This commit is contained in:
parent
5152f90703
commit
c5ae495f9e
@ -4,24 +4,20 @@
|
|||||||
:root {
|
:root {
|
||||||
--primary-color: #3B82F6;
|
--primary-color: #3B82F6;
|
||||||
--secondary-color: #10B981;
|
--secondary-color: #10B981;
|
||||||
|
--info-color: #0EA5E9;
|
||||||
--bg-color: #F9FAFB;
|
--bg-color: #F9FAFB;
|
||||||
--surface-color: #FFFFFF;
|
--surface-color: #FFFFFF;
|
||||||
--text-color: #1F2937;
|
--text-color: #1F2937;
|
||||||
--light-gray: #6B7280;
|
--light-gray: #6B7280;
|
||||||
|
|
||||||
--primary-color-staff: #3B82F6;
|
|
||||||
--secondary-color-resident: #10B981;
|
|
||||||
--text-color-dark: #1F2937;
|
|
||||||
--text-color-light: #6B7280;
|
|
||||||
--background-light: #F9FAFB;
|
|
||||||
--surface-white: #FFFFFF;
|
|
||||||
--border-color: #E5E7EB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body.login-page {
|
body {
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
background-color: var(--bg-color);
|
background-color: var(--bg-color);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-page {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -44,8 +40,9 @@ body.login-page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-card h1 {
|
.login-card h1 {
|
||||||
font-weight: 600;
|
font-family: 'Nunito', sans-serif;
|
||||||
font-size: 1.5rem;
|
font-weight: 700;
|
||||||
|
font-size: 1.75rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,33 +51,6 @@ body.login-page {
|
|||||||
margin-bottom: 2.5rem;
|
margin-bottom: 2.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-block {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
padding: 1rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
text-decoration: none;
|
|
||||||
transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-block:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-resident {
|
|
||||||
background-color: var(--secondary-color);
|
|
||||||
color: white;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-staff {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-text {
|
.footer-text {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
@ -88,218 +58,49 @@ body.login-page {
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Landing Page Styles */
|
/* General Button Styles */
|
||||||
body:not(.login-page) {
|
.btn-primary-custom, .btn-secondary-custom, .btn-info-custom {
|
||||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
||||||
background-color: var(--surface-white);
|
|
||||||
color: var(--text-color-dark);
|
|
||||||
margin: 0;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 0 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header */
|
|
||||||
.site-header {
|
|
||||||
background-color: var(--surface-white);
|
|
||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
||||||
padding: 1rem 0;
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.site-header .container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.site-header .logo {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--text-color-dark);
|
|
||||||
font-family: 'Nunito', sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.site-header nav {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.site-header nav a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--text-color-light);
|
|
||||||
font-weight: 600;
|
|
||||||
transition: color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.site-header nav a:hover {
|
|
||||||
color: var(--primary-color-staff);
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
padding: 0.75rem 1.5rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: 600;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-primary {
|
|
||||||
background-color: var(--primary-color-staff);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-primary:hover {
|
|
||||||
background-color: #2563EB;
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-secondary {
|
|
||||||
background-color: var(--secondary-color-resident);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-secondary:hover {
|
|
||||||
background-color: #059669;
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Hero Section */
|
|
||||||
.hero {
|
|
||||||
background: linear-gradient(to right, #EAF4FB, #EAF7EF);
|
|
||||||
padding: 6rem 0;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-container {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-text h1 {
|
|
||||||
font-family: 'Nunito', sans-serif;
|
|
||||||
font-size: 3rem;
|
|
||||||
font-weight: 700;
|
|
||||||
line-height: 1.2;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
color: var(--text-color-dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-text p {
|
|
||||||
font-size: 1.125rem;
|
|
||||||
color: var(--text-color-light);
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-image img {
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mission Section */
|
|
||||||
.mission-section {
|
|
||||||
padding: 6rem 0;
|
|
||||||
background-color: var(--surface-white);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mission-container {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mission-text h2 {
|
|
||||||
font-family: 'Nunito', sans-serif;
|
|
||||||
font-size: 2.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
color: var(--text-color-dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mission-text blockquote {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
font-style: italic;
|
|
||||||
color: var(--text-color-light);
|
|
||||||
border-left: 4px solid var(--secondary-color-resident);
|
|
||||||
padding-left: 1.5rem;
|
|
||||||
margin: 0 0 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cta-link {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color-staff);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cta-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mission-image img {
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* How It Works Section */
|
|
||||||
.how-it-works-section {
|
|
||||||
padding: 6rem 0;
|
|
||||||
background-color: var(--background-light);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.how-it-works-section h2 {
|
|
||||||
font-family: 'Nunito', sans-serif;
|
|
||||||
font-size: 2.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.how-it-works-section p {
|
|
||||||
font-size: 1.125rem;
|
|
||||||
color: var(--text-color-light);
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer */
|
|
||||||
.site-footer-main {
|
|
||||||
background-color: var(--text-color-dark);
|
|
||||||
color: var(--background-light);
|
|
||||||
padding: 2rem 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Login Form Styles */
|
|
||||||
.btn-primary-custom {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
|
padding: 1rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary-custom:hover, .btn-secondary-custom:hover, .btn-info-custom:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary-custom {
|
||||||
|
background-color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary-custom:hover {
|
.btn-primary-custom:hover {
|
||||||
background-color: #2563EB;
|
background-color: #2563EB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-secondary-custom {
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary-custom:hover {
|
||||||
|
background-color: #059669;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-info-custom {
|
||||||
|
background-color: var(--info-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-info-custom:hover {
|
||||||
|
background-color: #0284C7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.login-card .form-footer {
|
.login-card .form-footer {
|
||||||
margin-top: 1.5rem;
|
margin-top: 1.5rem;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
@ -312,4 +113,46 @@ body:not(.login-page) {
|
|||||||
|
|
||||||
.login-card .form-footer a:hover {
|
.login-card .form-footer a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dashboard Navigation */
|
||||||
|
.navbar {
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dashboard Content */
|
||||||
|
.card {
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-custom {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 0 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-custom thead th {
|
||||||
|
border-bottom: 2px solid var(--border-color);
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-custom tbody tr {
|
||||||
|
background-color: var(--surface-color);
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-custom td, .table-custom th {
|
||||||
|
vertical-align: middle;
|
||||||
|
padding: 1rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-custom tbody tr:hover {
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-sm-custom {
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|||||||
117
create_action_plan.php
Normal file
117
create_action_plan.php
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resident_id = isset($_GET['resident_id']) ? (int)$_GET['resident_id'] : 0;
|
||||||
|
if ($resident_id === 0) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Fetch resident details to display on the page
|
||||||
|
$stmt = $pdo->prepare("SELECT first_name, last_name FROM residents WHERE id = ?");
|
||||||
|
$stmt->execute([$resident_id]);
|
||||||
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$resident) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error_message = '';
|
||||||
|
$success_message = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
if (empty($_POST['title'])) {
|
||||||
|
$error_message = 'Please provide a title for the action plan.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO action_plans (resident_id, staff_id, title, description, status, due_date) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
|
$stmt->execute([
|
||||||
|
$resident_id,
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$_POST['title'],
|
||||||
|
$_POST['description'] ?? null,
|
||||||
|
$_POST['status'] ?? 'In Progress',
|
||||||
|
!empty($_POST['due_date']) ? $_POST['due_date'] : null
|
||||||
|
]);
|
||||||
|
header("Location: resident_view.php?id=" . $resident_id . "&success=1");
|
||||||
|
exit;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = 'Database error: Could not create action plan. ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>New Action Plan - 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="staff_dashboard.php">Continuum of Healing</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">Create New Action Plan</h1>
|
||||||
|
<a href="resident_view.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary">← Back to Resident View</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Creating plan for: <strong><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></strong></p>
|
||||||
|
|
||||||
|
<?php if ($error_message): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="create_action_plan.php?resident_id=<?php echo $resident_id; ?>">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="title" class="form-label">Title</label>
|
||||||
|
<input type="text" class="form-control" id="title" name="title" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="description" class="form-label">Description</label>
|
||||||
|
<textarea class="form-control" id="description" name="description" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="status" class="form-label">Status</label>
|
||||||
|
<select class="form-select" id="status" name="status">
|
||||||
|
<option>Not Started</option>
|
||||||
|
<option selected>In Progress</option>
|
||||||
|
<option>Completed</option>
|
||||||
|
<option>On Hold</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="due_date" class="form-label">Due Date</label>
|
||||||
|
<input type="date" class="form-control" id="due_date" name="due_date">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary-custom">Save Action Plan</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
104
index.php
104
index.php
@ -1,72 +1,57 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
// Handle role-based sign-in
|
||||||
|
if (isset($_GET['login_as'])) {
|
||||||
|
$role = $_GET['login_as'];
|
||||||
|
if ($role === 'staff') {
|
||||||
|
$_SESSION['user_id'] = 2; // Sample staff user ID
|
||||||
|
$_SESSION['user_role'] = 'staff';
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
} elseif ($role === 'resident') {
|
||||||
|
$_SESSION['user_id'] = 1; // Sample resident user ID
|
||||||
|
$_SESSION['user_role'] = 'resident';
|
||||||
|
header("Location: resident_dashboard.php");
|
||||||
|
exit;
|
||||||
|
} elseif ($role === 'partner') {
|
||||||
|
$_SESSION['user_id'] = 3; // Sample partner user ID
|
||||||
|
$_SESSION['user_role'] = 'partner';
|
||||||
|
header("Location: partner_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If user is already logged in, redirect to their dashboard
|
// If user is already logged in, redirect to their dashboard
|
||||||
if (isset($_SESSION['user_id'])) {
|
if (isset($_SESSION['user_id'])) {
|
||||||
if ($_SESSION['user_role'] === 'staff') {
|
if ($_SESSION['user_role'] === 'staff') {
|
||||||
header("Location: staff_dashboard.php");
|
header("Location: staff_dashboard.php");
|
||||||
} else {
|
} elseif ($_SESSION['user_role'] === 'resident') {
|
||||||
header("Location: resident_dashboard.php");
|
header("Location: resident_dashboard.php");
|
||||||
|
} elseif ($_SESSION['user_role'] === 'partner') {
|
||||||
|
header("Location: partner_dashboard.php");
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once __DIR__ . '/db/config.php';
|
|
||||||
|
|
||||||
$error_message = '';
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
if (empty($_POST['email']) || empty($_POST['password'])) {
|
|
||||||
$error_message = 'Please enter both email and password.';
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
|
||||||
$stmt->execute([$_POST['email']]);
|
|
||||||
$user = $stmt->fetch();
|
|
||||||
|
|
||||||
if ($user && password_verify($_POST['password'], $user['password'])) {
|
|
||||||
// Password is correct, start session
|
|
||||||
$_SESSION['user_id'] = $user['id'];
|
|
||||||
$_SESSION['user_email'] = $user['email'];
|
|
||||||
$_SESSION['user_role'] = $user['role'];
|
|
||||||
|
|
||||||
// Redirect to the appropriate dashboard
|
|
||||||
if ($user['role'] === 'staff') {
|
|
||||||
header("Location: staff_dashboard.php");
|
|
||||||
} else {
|
|
||||||
header("Location: resident_dashboard.php");
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$error_message = 'Invalid email or password.';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$error_message = 'Database error. Please try again later.';
|
|
||||||
// In a real app, you would log this error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<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>Welcome - Continuum of Healing</title>
|
||||||
<title>Login - Continuum of Healing</title>
|
<meta name="description" content="Sign in to the Continuum of Healing platform.">
|
||||||
<meta name="description" content="Login to the Continuum of Healing platform.">
|
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
<!-- Open Graph / Facebook -->
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:title" content="Login - Continuum of Healing">
|
<meta property="og:title" content="Welcome - Continuum of Healing">
|
||||||
<meta property="og:description" content="Login to the Continuum of Healing platform.">
|
<meta property="og:description" content="Sign in to the Continuum of Healing platform.">
|
||||||
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Twitter -->
|
||||||
<meta property="twitter:card" content="summary_large_image">
|
<meta property="twitter:card" content="summary_large_image">
|
||||||
<meta property="twitter:title" content="Login - Continuum of Healing">
|
<meta property="twitter:title" content="Welcome - Continuum of Healing">
|
||||||
<meta property="twitter:description" content="Login to the Continuum of Healing platform.">
|
<meta property="twitter:description" content="Sign in to the Continuum of Healing platform.">
|
||||||
<meta property="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
<meta property="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||||
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
@ -75,29 +60,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
<body class="login-page">
|
<body class="login-page">
|
||||||
|
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<div class="login-card">
|
<div class="login-card text-center">
|
||||||
<h1>Sign In</h1>
|
<h1>Continuum of Healing™</h1>
|
||||||
<p class="subtitle">Welcome to the Continuum of Healing™</p>
|
<p class="subtitle">Please select your portal to continue</p>
|
||||||
|
|
||||||
<?php if ($error_message): ?>
|
<div class="d-grid gap-3">
|
||||||
<div class="alert alert-danger" role="alert">
|
<a href="index.php?login_as=staff" class="btn btn-primary-custom btn-lg">Staff Portal</a>
|
||||||
<?php echo htmlspecialchars($error_message); ?>
|
<a href="index.php?login_as=resident" class="btn btn-secondary-custom btn-lg">Resident Portal</a>
|
||||||
</div>
|
<a href="index.php?login_as=partner" class="btn btn-info-custom btn-lg">Partner Portal</a>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form method="POST" action="index.php">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="email" class="form-label">Email address</label>
|
|
||||||
<input type="email" class="form-control" id="email" name="email" required>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="password" class="form-label">Password</label>
|
|
||||||
<input type="password" class="form-control" id="password" name="password" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn-block btn-primary-custom">Sign In</button>
|
|
||||||
</form>
|
|
||||||
<div class="form-footer">
|
|
||||||
<a href="index.php">← Back to Home</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-text">
|
<div class="footer-text">
|
||||||
|
|||||||
96
partner_dashboard.php
Normal file
96
partner_dashboard.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Get partner details
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM partners WHERE user_id = ?");
|
||||||
|
$stmt->execute([$_SESSION['user_id']]);
|
||||||
|
$partner = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$partner) {
|
||||||
|
$error_message = "Could not find a partner profile linked to your user account.";
|
||||||
|
} else {
|
||||||
|
// Get residents assigned to this partner
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE partner_id = ? ORDER BY last_name, first_name");
|
||||||
|
$stmt->execute([$partner['id']]);
|
||||||
|
$residents = $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>Partner 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="partner_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="#">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($error_message)): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||||
|
<?php elseif (isset($partner)): ?>
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">Partner Dashboard: <?php echo htmlspecialchars($partner['name']); ?></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Assigned Residents</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Program</th>
|
||||||
|
<th>Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if (empty($residents)): ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3" class="text-center">No residents are currently assigned to you.</td>
|
||||||
|
</tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($residents as $resident): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($resident['program']); ?></td>
|
||||||
|
<td><span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></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>
|
||||||
@ -2,26 +2,25 @@
|
|||||||
session_start();
|
session_start();
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
// Check if user is logged in and has the 'resident' role
|
|
||||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
// Fetch the logged-in resident's data
|
// Fetch the logged-in resident's data
|
||||||
try {
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE user_id = ?");
|
||||||
$pdo = db();
|
$stmt->execute([$_SESSION['user_id']]);
|
||||||
$stmt = $pdo->prepare("SELECT * FROM residents WHERE user_id = ?");
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->execute([$_SESSION['user_id']]);
|
|
||||||
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
// If no resident profile is linked to this user account, show a message.
|
if (!$resident) {
|
||||||
if (!$resident) {
|
$no_profile_message = "Your profile is not yet linked. Please contact support.";
|
||||||
$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");
|
||||||
} catch (PDOException $e) {
|
$stmt->execute([$resident['id']]);
|
||||||
$error_message = "Error fetching your data.";
|
$action_plans = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -30,49 +29,37 @@ try {
|
|||||||
<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 of Healing</title>
|
<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 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">
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">Continuum of Healing</a>
|
<a class="navbar-brand" href="resident_dashboard.php">Continuum of Healing</a>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" href="resident_dashboard.php">Dashboard</a>
|
<a class="nav-link active" href="resident_dashboard.php">Dashboard</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
<div class="d-flex">
|
|
||||||
<span class="navbar-text me-3">
|
|
||||||
Logged in as: <?php echo htmlspecialchars($_SESSION['user_email']); ?>
|
|
||||||
</span>
|
|
||||||
<a href="logout.php" class="btn btn-outline-danger">Logout</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
<?php if (isset($no_profile_message)): ?>
|
||||||
<?php if (isset($resident) && $resident): ?>
|
|
||||||
<h1 class="h2">Welcome, <?php echo htmlspecialchars($resident['first_name']); ?>!</h1>
|
|
||||||
<?php else: ?>
|
|
||||||
<h1 class="h2">Welcome, Resident!</h1>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if (isset($error_message)): ?>
|
|
||||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
|
||||||
<?php elseif (isset($no_profile_message)): ?>
|
|
||||||
<div class="alert alert-warning"><?php echo $no_profile_message; ?></div>
|
<div class="alert alert-warning"><?php echo $no_profile_message; ?></div>
|
||||||
<?php elseif (isset($resident)): ?>
|
<?php elseif (isset($resident)): ?>
|
||||||
<div class="card">
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<div class="card-header">
|
<h1 class="h2">Welcome, <?php echo htmlspecialchars($resident['first_name']); ?>!</h1>
|
||||||
Your Progress
|
</div>
|
||||||
</div>
|
|
||||||
|
<!-- Your Information Card -->
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-header">Your Information</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@ -81,14 +68,46 @@ try {
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<p><strong>Status:</strong> <span class="badge bg-success"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
<p><strong>Status:</strong> <span class="badge bg-success"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
||||||
<p><strong>Last Check-in:</strong> <?php echo htmlspecialchars(date("M j, Y, g:i a", strtotime($resident['last_check_in']))); ?></p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
128
resident_edit.php
Normal file
128
resident_edit.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resident_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||||
|
if ($resident_id === 0) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Handle form submission
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
try {
|
||||||
|
$sql = "UPDATE residents SET first_name = ?, last_name = ?, email = ?, phone_number = ?, date_of_birth = ?, program = ?, status = ? WHERE id = ?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([
|
||||||
|
$_POST['first_name'],
|
||||||
|
$_POST['last_name'],
|
||||||
|
$_POST['email'],
|
||||||
|
$_POST['phone_number'],
|
||||||
|
$_POST['date_of_birth'],
|
||||||
|
$_POST['program'],
|
||||||
|
$_POST['status'],
|
||||||
|
$resident_id
|
||||||
|
]);
|
||||||
|
header("Location: resident_view.php?id=" . $resident_id . "&success=2"); // Success code for update
|
||||||
|
exit;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: Could not update resident. " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch resident details to pre-fill the form
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE id = ?");
|
||||||
|
$stmt->execute([$resident_id]);
|
||||||
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$resident) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Edit Resident - 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="staff_dashboard.php">Continuum of Healing</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">Edit Resident Information</h1>
|
||||||
|
<a href="resident_view.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary">← Back to View</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="resident_edit.php?id=<?php echo $resident_id; ?>">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="first_name" class="form-label">First Name</label>
|
||||||
|
<input type="text" class="form-control" id="first_name" name="first_name" value="<?php echo htmlspecialchars($resident['first_name']); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="last_name" class="form-label">Last Name</label>
|
||||||
|
<input type="text" class="form-control" id="last_name" name="last_name" value="<?php echo htmlspecialchars($resident['last_name']); ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($resident['email']); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="phone_number" class="form-label">Phone Number</label>
|
||||||
|
<input type="tel" class="form-control" id="phone_number" name="phone_number" value="<?php echo htmlspecialchars($resident['phone_number']); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="date_of_birth" class="form-label">Date of Birth</label>
|
||||||
|
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" value="<?php echo htmlspecialchars($resident['date_of_birth']); ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="program" class="form-label">Program</label>
|
||||||
|
<select class="form-select" id="program" name="program">
|
||||||
|
<option <?php echo ($resident['program'] == 'General Support') ? 'selected' : ''; ?>>General Support</option>
|
||||||
|
<option <?php echo ($resident['program'] == 'Transitional Housing') ? 'selected' : ''; ?>>Transitional Housing</option>
|
||||||
|
<option <?php echo ($resident['program'] == 'Outreach') ? 'selected' : ''; ?>>Outreach</option>
|
||||||
|
<option <?php echo ($resident['program'] == 'Aftercare') ? 'selected' : ''; ?>>Aftercare</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="status" class="form-label">Status</label>
|
||||||
|
<select class="form-select" id="status" name="status">
|
||||||
|
<option <?php echo ($resident['status'] == 'Active') ? 'selected' : ''; ?>>Active</option>
|
||||||
|
<option <?php echo ($resident['status'] == 'Inactive') ? 'selected' : ''; ?>>Inactive</option>
|
||||||
|
<option <?php echo ($resident['status'] == 'Pending') ? 'selected' : ''; ?>>Pending</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary-custom">Save Changes</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
130
resident_intake.php
Normal file
130
resident_intake.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error_message = '';
|
||||||
|
$success_message = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
// Basic validation
|
||||||
|
if (empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['email'])) {
|
||||||
|
$error_message = 'Please fill in all required fields.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO residents (first_name, last_name, email, phone_number, date_of_birth, program, status) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
$stmt->execute([
|
||||||
|
$_POST['first_name'],
|
||||||
|
$_POST['last_name'],
|
||||||
|
$_POST['email'],
|
||||||
|
$_POST['phone_number'] ?? null,
|
||||||
|
$_POST['date_of_birth'] ?? null,
|
||||||
|
$_POST['program'] ?? 'General Support',
|
||||||
|
$_POST['status'] ?? 'Active'
|
||||||
|
]);
|
||||||
|
$success_message = "Resident '" . htmlspecialchars($_POST['first_name']) . " " . htmlspecialchars($_POST['last_name']) . "' has been successfully added.";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = 'Database error: Could not add resident. ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>New Resident Intake - 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="staff_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="staff_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">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">New Resident Intake Form</h1>
|
||||||
|
<a href="staff_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($error_message): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($success_message): ?>
|
||||||
|
<div class="alert alert-success"><?php echo $success_message; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="resident_intake.php">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="first_name" class="form-label">First Name</label>
|
||||||
|
<input type="text" class="form-control" id="first_name" name="first_name" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="last_name" class="form-label">Last Name</label>
|
||||||
|
<input type="text" class="form-control" id="last_name" name="last_name" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="phone_number" class="form-label">Phone Number</label>
|
||||||
|
<input type="tel" class="form-control" id="phone_number" name="phone_number">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="date_of_birth" class="form-label">Date of Birth</label>
|
||||||
|
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="program" class="form-label">Program</label>
|
||||||
|
<select class="form-select" id="program" name="program">
|
||||||
|
<option>General Support</option>
|
||||||
|
<option>Transitional Housing</option>
|
||||||
|
<option>Outreach</option>
|
||||||
|
<option>Aftercare</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="status" class="form-label">Status</label>
|
||||||
|
<select class="form-select" id="status" name="status">
|
||||||
|
<option>Active</option>
|
||||||
|
<option>Inactive</option>
|
||||||
|
<option>Pending</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary-custom">Add Resident</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -8,91 +8,126 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get resident ID from URL
|
|
||||||
$resident_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
$resident_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||||
|
|
||||||
if ($resident_id === 0) {
|
if ($resident_id === 0) {
|
||||||
header("Location: staff_dashboard.php");
|
header("Location: staff_dashboard.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch resident details from the database
|
$pdo = db();
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("SELECT * FROM residents WHERE id = ?");
|
|
||||||
$stmt->execute([$resident_id]);
|
|
||||||
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if (!$resident) {
|
// Fetch resident details
|
||||||
// No resident found, redirect
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE id = ?");
|
||||||
header("Location: staff_dashboard.php");
|
$stmt->execute([$resident_id]);
|
||||||
exit;
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
}
|
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
if (!$resident) {
|
||||||
$error_message = "Error fetching resident data.";
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<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>View Resident | Continuum of Healing</title>
|
<title>View Resident - <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
<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">
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="staff_dashboard.php">Continuum of Healing</a>
|
<a class="navbar-brand" href="staff_dashboard.php">Continuum of Healing</a>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="staff_dashboard.php">Dashboard</a>
|
<a class="nav-link" href="staff_dashboard.php">Dashboard</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
<div class="d-flex">
|
|
||||||
<span class="navbar-text me-3">
|
|
||||||
Logged in as: <?php echo htmlspecialchars($_SESSION['user_email']); ?>
|
|
||||||
</span>
|
|
||||||
<a href="logout.php" class="btn btn-outline-danger">Logout</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<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">
|
||||||
<h1 class="h2">Resident Details</h1>
|
<h1 class="h2">Resident: <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h1>
|
||||||
<a href="staff_dashboard.php" class="btn btn-light">« Back to Dashboard</a>
|
<a href="staff_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (isset($error_message)): ?>
|
<!-- Resident Details Card -->
|
||||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
<div class="card mb-4">
|
||||||
<?php elseif (isset($resident)): ?>
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<div class="card">
|
Resident Information
|
||||||
<div class="card-header">
|
<a href="resident_edit.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary btn-sm">Edit</a>
|
||||||
Viewing <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?>
|
</div>
|
||||||
</div>
|
<div class="card-body">
|
||||||
<div class="card-body">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-md-6">
|
||||||
<div class="col-md-6">
|
<p><strong>Name:</strong> <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></p>
|
||||||
<p><strong>Name:</strong> <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></p>
|
<p><strong>Email:</strong> <?php echo htmlspecialchars($resident['email']); ?></p>
|
||||||
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
<p><strong>Phone:</strong> <?php echo htmlspecialchars($resident['phone_number'] ?? 'N/A'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<p><strong>Status:</strong> <span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
||||||
<p><strong>Last Check-in:</strong> <?php echo htmlspecialchars(date("M j, Y, g:i a", strtotime($resident['last_check_in']))); ?></p>
|
<p><strong>Status:</strong> <span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
||||||
</div>
|
<p><strong>Date of Birth:</strong> <?php echo htmlspecialchars($resident['date_of_birth'] ? date("M j, Y", strtotime($resident['date_of_birth'])) : 'N/A'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Plans Card -->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
|
Action Plans
|
||||||
|
<a href="create_action_plan.php?resident_id=<?php echo $resident_id; ?>" class="btn btn-primary-custom btn-sm">+ New Action Plan</a>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Due Date</th>
|
||||||
|
<th>Created On</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if (empty($action_plans)): ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="text-center">No action plans found for this resident.</td>
|
||||||
|
</tr>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($action_plans as $plan): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($plan['title']); ?></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>
|
||||||
|
<td><?php echo htmlspecialchars(date("M j, Y", strtotime($plan['created_at']))); ?></td>
|
||||||
|
<td>
|
||||||
|
<a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-outline-secondary btn-sm">View/Edit</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</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://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -31,24 +31,19 @@ try {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">Continuum of Healing</a>
|
<a class="navbar-brand" href="staff_dashboard.php">Continuum of Healing</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">
|
<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>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
<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>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
<div class="d-flex">
|
|
||||||
<span class="navbar-text me-3">
|
|
||||||
Logged in as: <?php echo htmlspecialchars($_SESSION['user_email']); ?>
|
|
||||||
</span>
|
|
||||||
<a href="logout.php" class="btn btn-outline-danger">Logout</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@ -56,6 +51,7 @@ try {
|
|||||||
<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">
|
||||||
<h1 class="h2">Continuum Control Center</h1>
|
<h1 class="h2">Continuum Control Center</h1>
|
||||||
|
<a href="resident_intake.php" class="btn btn-primary-custom">+ New Resident</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (isset($error_message)): ?>
|
<?php if (isset($error_message)): ?>
|
||||||
|
|||||||
123
view_action_plan.php
Normal file
123
view_action_plan.php
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// Check if user is logged in and has a staff role
|
||||||
|
if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_role'], ['staff', 'resident'])) {
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$action_plan_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||||
|
if ($action_plan_id === 0) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Handle status update
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['user_role'] === 'staff') {
|
||||||
|
try {
|
||||||
|
$sql = "UPDATE action_plans SET status = ? WHERE id = ?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute([$_POST['status'], $action_plan_id]);
|
||||||
|
header("Location: view_action_plan.php?id=" . $action_plan_id . "&success=1");
|
||||||
|
exit;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: Could not update status. " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch action plan details and resident info
|
||||||
|
$stmt = $pdo->prepare("SELECT ap.*, r.first_name, r.last_name FROM action_plans ap JOIN residents r ON ap.resident_id = r.id WHERE ap.id = ?");
|
||||||
|
$stmt->execute([$action_plan_id]);
|
||||||
|
$action_plan = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$action_plan) {
|
||||||
|
header("Location: staff_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Security check: if resident is logged in, ensure they own this action plan
|
||||||
|
if ($_SESSION['user_role'] === 'resident') {
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM residents WHERE user_id = ?");
|
||||||
|
$stmt->execute([$_SESSION['user_id']]);
|
||||||
|
$current_resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if (!$current_resident || $action_plan['resident_id'] !== $current_resident['id']) {
|
||||||
|
header("Location: resident_dashboard.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>View Action Plan - 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="#">Continuum of Healing</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">Action Plan Details</h1>
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['user_role'] === 'staff') {
|
||||||
|
$back_link = "resident_view.php?id=" . $action_plan['resident_id'];
|
||||||
|
$back_text = "← Back to Resident View";
|
||||||
|
} else {
|
||||||
|
$back_link = "resident_dashboard.php";
|
||||||
|
$back_text = "← Back to Dashboard";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<a href="<?php echo $back_link; ?>" class="btn btn-secondary"><?php echo $back_text; ?></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
Plan for <?php echo htmlspecialchars($action_plan['first_name'] . ' ' . $action_plan['last_name']); ?>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h3><?php echo htmlspecialchars($action_plan['title']); ?></h3>
|
||||||
|
<p class="text-muted">Created on <?php echo date("F j, Y", strtotime($action_plan['created_at'])); ?></p>
|
||||||
|
<p><strong>Status:</strong> <span class="badge bg-info"><?php echo htmlspecialchars($action_plan['status']); ?></span></p>
|
||||||
|
<p><strong>Due Date:</strong> <?php echo $action_plan['due_date'] ? date("F j, Y", strtotime($action_plan['due_date'])) : 'N/A'; ?></p>
|
||||||
|
<hr>
|
||||||
|
<p><?php echo nl2br(htmlspecialchars($action_plan['description'])); ?></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($_SESSION['user_role'] === 'staff'): ?>
|
||||||
|
<div class="card mt-4">
|
||||||
|
<div class="card-header">Update Status</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="view_action_plan.php?id=<?php echo $action_plan_id; ?>">
|
||||||
|
<div class="input-group">
|
||||||
|
<select class="form-select" name="status">
|
||||||
|
<option <?php echo ($action_plan['status'] == 'Not Started') ? 'selected' : ''; ?>>Not Started</option>
|
||||||
|
<option <?php echo ($action_plan['status'] == 'In Progress') ? 'selected' : ''; ?>>In Progress</option>
|
||||||
|
<option <?php echo ($action_plan['status'] == 'Completed') ? 'selected' : ''; ?>>Completed</option>
|
||||||
|
<option <?php echo ($action_plan['status'] == 'On Hold') ? 'selected' : ''; ?>>On Hold</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit" class="btn btn-primary-custom">Update</button>
|
||||||
|
</div>
|
||||||
|
</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>
|
||||||
Loading…
x
Reference in New Issue
Block a user