Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: staff_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if user is logged in and has the 'staff' role
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
||||
// You can redirect to a generic error page or the login page
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$resident_id = isset($_POST['resident_id']) ? (int)$_POST['resident_id'] : 0;
|
||||
$note = isset($_POST['note']) ? trim($_POST['note']) : '';
|
||||
|
||||
if ($resident_id === 0 || empty($note)) {
|
||||
// Basic validation failed
|
||||
// Redirect back with an error message (optional)
|
||||
header("Location: resident_view.php?id={$resident_id}&error=empty_note");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO case_notes (resident_id, note) VALUES (?, ?)");
|
||||
$stmt->execute([$resident_id, $note]);
|
||||
|
||||
// Redirect back to the resident's view page after successful insertion
|
||||
header("Location: resident_view.php?id={$resident_id}&success=note_added");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, log this error.
|
||||
// For simplicity, redirect with a generic error.
|
||||
header("Location: resident_view.php?id={$resident_id}&error=db_error");
|
||||
exit;
|
||||
}
|
||||
@ -1,158 +0,0 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap');
|
||||
|
||||
:root {
|
||||
--primary-color: #3B82F6;
|
||||
--secondary-color: #10B981;
|
||||
--info-color: #0EA5E9;
|
||||
--bg-color: #F9FAFB;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-color: #1F2937;
|
||||
--light-gray: #6B7280;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.login-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
max-width: 480px;
|
||||
width: 100%;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background-color: var(--surface-color);
|
||||
border-radius: 0.75rem;
|
||||
padding: 3rem;
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login-card h1 {
|
||||
font-family: 'Nunito', sans-serif;
|
||||
font-weight: 700;
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.login-card .subtitle {
|
||||
color: var(--light-gray);
|
||||
margin-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
.footer-text {
|
||||
text-align: center;
|
||||
margin-top: 2rem;
|
||||
color: var(--light-gray);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* General Button Styles */
|
||||
.btn-primary-custom, .btn-secondary-custom, .btn-info-custom {
|
||||
color: white;
|
||||
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 {
|
||||
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 {
|
||||
margin-top: 1.5rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.login-card .form-footer a {
|
||||
color: var(--light-gray);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.login-card .form-footer a:hover {
|
||||
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;
|
||||
}
|
||||
123
calendar.php
123
calendar.php
@ -1,123 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_role'], ['partner', 'staff'])) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch staff users to populate the 'To' dropdown
|
||||
$stmt = $pdo->query("SELECT id, email FROM users WHERE role = 'staff' ORDER BY email");
|
||||
$staff_users = $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>Compose Message - Continuum Nexus</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 Nexus</a>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</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="partner_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<select name="recipient_user_id" id="recipient" class="form-select" required>
|
||||
<option value="">Select a staff member...</option>
|
||||
<?php foreach ($staff_users as $staff): ?>
|
||||
<option value="<?php echo $staff['id']; ?>"><?php echo htmlspecialchars($staff['email']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
include 'includes/staff_header.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
// --- Sample Data Generation ---
|
||||
$residents = [];
|
||||
for ($i = 1; $i <= 20; $i++) {
|
||||
$residents[] = ['id' => $i, 'name' => "Resident #$i"];
|
||||
}
|
||||
|
||||
$domains = [
|
||||
'Economic Stability' => 'Enroll in financial literacy workshop and open a savings account.',
|
||||
'Education' => 'Complete high school equivalency diploma and apply for vocational training.',
|
||||
'Health and Healthcare' => 'Schedule annual physical and attend a nutrition seminar.',
|
||||
'Neighborhood and Environment' => 'Report local safety concerns and join a community garden.',
|
||||
'Social and Community Context' => 'Join a local support group and volunteer for a community event.'
|
||||
];
|
||||
|
||||
$success_message = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['resident_id'])) {
|
||||
$resident_id = $_POST['resident_id'];
|
||||
// In a real application, you would save this data to the database.
|
||||
// For now, we just show a success message.
|
||||
$resident_name = $residents[$resident_id - 1]['name'];
|
||||
$success_message = "Successfully generated a new action plan for " . htmlspecialchars($resident_name) . ".";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Generate New Action Plan</h1>
|
||||
<a href="staff_dashboard.php" class="btn btn-secondary"><i class="fas fa-arrow-left me-2"></i>Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<?php if ($success_message): ?>
|
||||
<div class="alert alert-success">
|
||||
<?php echo $success_message; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form action="create_action_plan.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="resident_id" class="form-label">Select Resident</label>
|
||||
<select class="form-select" id="resident_id" name="resident_id" required>
|
||||
<option value="" disabled selected>Choose a resident...</option>
|
||||
<?php foreach ($residents as $resident): ?>
|
||||
<option value="<?php echo $resident['id']; ?>"><?php echo htmlspecialchars($resident['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4">Action Plan Details (Prefilled Sample)</h5>
|
||||
<p class="text-muted">These are pre-filled suggestions. In the future, this content will be AI-generated based on the resident's specific needs.</p>
|
||||
|
||||
<?php foreach ($domains as $domain => $plan): ?>
|
||||
<div class="mb-3">
|
||||
<label for="plan_<?php echo str_replace(' ', '_', $domain); ?>" class="form-label fw-bold"><?php echo $domain; ?></label>
|
||||
<textarea class="form-control" id="plan_<?php echo str_replace(' ', '_', $domain); ?>" name="plans[<?php echo $domain; ?>]" rows="3"><?php echo htmlspecialchars($plan); ?></textarea>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div class="mt-4 text-end">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Generate and Save Plan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; // Assuming a footer file exists ?>
|
||||
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
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
|
||||
$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;
|
||||
}
|
||||
|
||||
// Fetch partners for the dropdown
|
||||
$stmt = $pdo->query("SELECT id, name FROM partners ORDER BY name");
|
||||
$partners = $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>New Referral - Continuum Nexus</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 Nexus</a>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">New Referral for <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h1>
|
||||
<a href="resident_view.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary">← Back to Resident</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="submit_referral.php" method="POST">
|
||||
<input type="hidden" name="resident_id" value="<?php echo $resident_id; ?>">
|
||||
<input type="hidden" name="staff_id" value="<?php echo $_SESSION['user_id']; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="partner_id" class="form-label">Refer to Partner</label>
|
||||
<select name="partner_id" id="partner_id" class="form-select" required>
|
||||
<option value="">Select a partner...</option>
|
||||
<?php foreach ($partners as $partner): ?>
|
||||
<option value="<?php echo $partner['id']; ?>"><?php echo htmlspecialchars($partner['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="notes" class="form-label">Referral Notes</label>
|
||||
<textarea name="notes" id="notes" class="form-control" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom">Submit Referral</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>
|
||||
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
try {
|
||||
$db = db();
|
||||
|
||||
// 1. Add columns to residents table
|
||||
$db->exec("ALTER TABLE residents ADD COLUMN risk_level VARCHAR(255) DEFAULT 'Low'");
|
||||
$db->exec("ALTER TABLE residents ADD COLUMN program VARCHAR(255) DEFAULT 'General'");
|
||||
$db->exec("ALTER TABLE residents ADD COLUMN status VARCHAR(255) DEFAULT 'Active'");
|
||||
|
||||
// 2. Create case_notes table
|
||||
$db->exec("
|
||||
CREATE TABLE IF NOT EXISTS case_notes (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
resident_id INT NOT NULL,
|
||||
note TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (resident_id) REFERENCES residents(id) ON DELETE CASCADE
|
||||
)
|
||||
");
|
||||
|
||||
// 3. Populate with some data
|
||||
$stmt = $db->query("SELECT id FROM residents");
|
||||
$resident_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
if ($resident_ids) {
|
||||
$programs = ['Housing', 'Health', 'Employment'];
|
||||
$risks = ['Low', 'Medium', 'High'];
|
||||
$statuses = ['Active', 'Inactive', 'Stabilized'];
|
||||
|
||||
foreach ($resident_ids as $id) {
|
||||
$program = $programs[array_rand($programs)];
|
||||
$risk = $risks[array_rand($risks)];
|
||||
$status = $statuses[array_rand($statuses)];
|
||||
$db->prepare("UPDATE residents SET program = ?, risk_level = ?, status = ? WHERE id = ?")->execute([$program, $risk, $status, $id]);
|
||||
|
||||
// Add a case note
|
||||
$db->prepare("INSERT INTO case_notes (resident_id, note) VALUES (?, ?)")->execute([$id, 'Initial intake assessment completed.']);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Database schema updated successfully.";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Database migration failed: " . $e->getMessage());
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
try {
|
||||
$db = db();
|
||||
|
||||
// 1. Create partners table
|
||||
$db->exec("
|
||||
CREATE TABLE IF NOT EXISTS partners (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INT UNIQUE
|
||||
)
|
||||
");
|
||||
|
||||
// 2. Add partner_id to residents table
|
||||
$db->exec("ALTER TABLE residents ADD COLUMN partner_id INT NULL");
|
||||
|
||||
// 3. Create a user for a partner (if not exists)
|
||||
$partner_email = 'partner@goodwill.example';
|
||||
$stmt = $db->prepare("SELECT id FROM users WHERE email = ?");
|
||||
$stmt->execute([$partner_email]);
|
||||
$partner_user_id = $stmt->fetchColumn();
|
||||
|
||||
if (!$partner_user_id) {
|
||||
$db->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)")->execute([$partner_email, password_hash('password123', PASSWORD_DEFAULT), 'partner']);
|
||||
$partner_user_id = $db->lastInsertId();
|
||||
}
|
||||
|
||||
// 4. Create a partner profile
|
||||
$stmt = $db->prepare("SELECT id FROM partners WHERE user_id = ?");
|
||||
$stmt->execute([$partner_user_id]);
|
||||
$partner_id = $stmt->fetchColumn();
|
||||
|
||||
if (!$partner_id) {
|
||||
$db->prepare("INSERT INTO partners (name, user_id) VALUES (?, ?)")->execute(['Goodwill Housing', $partner_user_id]);
|
||||
$partner_id = $db->lastInsertId();
|
||||
}
|
||||
|
||||
// 5. Assign some residents to the partner
|
||||
$db->exec("UPDATE residents SET partner_id = {$partner_id} WHERE program = 'Housing'");
|
||||
|
||||
echo "Database schema updated successfully for partner feature.";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Database migration failed: " . $e->getMessage());
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$document_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
if ($document_id === 0) {
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch document details
|
||||
$stmt = $pdo->prepare("SELECT * FROM documents WHERE id = ?");
|
||||
$stmt->execute([$document_id]);
|
||||
$document = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$document) {
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Permission check
|
||||
$user_role = $_SESSION['user_role'];
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$has_permission = false;
|
||||
|
||||
if ($user_role === 'staff') {
|
||||
$has_permission = true;
|
||||
} elseif ($user_role === 'partner') {
|
||||
$stmt = $pdo->prepare("SELECT id FROM partners WHERE user_id = ?");
|
||||
$stmt->execute([$user_id]);
|
||||
$partner_id = $stmt->fetchColumn();
|
||||
|
||||
if ($partner_id && $document['partner_id'] == $partner_id) {
|
||||
$has_permission = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$has_permission) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
exit("You do not have permission to access this file.");
|
||||
}
|
||||
|
||||
// Serve the file for download
|
||||
$file_path = $document['file_path'];
|
||||
if (file_exists($file_path)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . basename($document['file_name']) . '"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($file_path));
|
||||
readfile($file_path);
|
||||
exit;
|
||||
} else {
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
exit("File not found on server.");
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
<?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("HTTP/1.1 403 Forbidden");
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// -- Filtering (reuse logic from dashboard) --
|
||||
$program_filter = $_GET['program'] ?? '';
|
||||
$risk_filter = $_GET['risk_level'] ?? '';
|
||||
$status_filter = $_GET['status'] ?? '';
|
||||
|
||||
$where_clauses = [];
|
||||
$params = [];
|
||||
|
||||
if ($program_filter) {
|
||||
$where_clauses[] = "program = ?";
|
||||
$params[] = $program_filter;
|
||||
}
|
||||
if ($risk_filter) {
|
||||
$where_clauses[] = "risk_level = ?";
|
||||
$params[] = $risk_filter;
|
||||
}
|
||||
if ($status_filter) {
|
||||
$where_clauses[] = "status = ?";
|
||||
$params[] = $status_filter;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM residents"; // Select all columns for export
|
||||
if (!empty($where_clauses)) {
|
||||
$sql .= " WHERE " . implode(' AND ', $where_clauses);
|
||||
}
|
||||
$sql .= " ORDER BY last_name, first_name";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
// -- CSV Generation --
|
||||
$filename = "continuum_residents_" . date('Y-m-d') . ".csv";
|
||||
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename=' . $filename);
|
||||
|
||||
$output = fopen('php://output', 'w');
|
||||
|
||||
// Add header row
|
||||
fputcsv($output, [
|
||||
'ID', 'First Name', 'Last Name', 'Email', 'Phone Number', 'Date of Birth',
|
||||
'Program', 'Status', 'Risk Level', 'Health Progress', 'Housing Progress', 'Employment Progress', 'Created At'
|
||||
]);
|
||||
|
||||
// Add data rows
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
fputcsv($output, [
|
||||
$row['id'],
|
||||
$row['first_name'],
|
||||
$row['last_name'],
|
||||
$row['email'],
|
||||
$row['phone_number'],
|
||||
$row['date_of_birth'],
|
||||
$row['program'],
|
||||
$row['status'],
|
||||
$row['risk_level'],
|
||||
$row['health_progress'],
|
||||
$row['housing_progress'],
|
||||
$row['employment_progress'],
|
||||
$row['created_at']
|
||||
]);
|
||||
}
|
||||
|
||||
fclose($output);
|
||||
exit;
|
||||
@ -1,4 +0,0 @@
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,37 +0,0 @@
|
||||
<?php require_once 'includes/partner_session.php'; ?>
|
||||
<!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 Nexus</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<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 Nexus</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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="partner_dashboard.php"><i class="bi bi-people-fill me-2"></i>Assigned Residents</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="messages.php"><i class="bi bi-envelope-fill me-2"></i>Messages</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="resources.php"><i class="bi bi-info-circle-fill me-2"></i>Resources</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="logout.php"><i class="bi bi-box-arrow-right me-2"></i>Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container mt-4">
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Check if user is logged in and has the 'partner' role
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
require_once 'includes/resident_session.php';
|
||||
|
||||
$current_page = basename($_SERVER['PHP_SELF']);
|
||||
?>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="resident_dashboard.php">Continuum Nexus</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#residentNavbar" aria-controls="residentNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="residentNavbar">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($current_page == 'resident_dashboard.php') ? 'active' : ''; ?>" href="resident_dashboard.php"><i class="bi bi-grid-fill"></i> Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($current_page == 'messages.php' || $current_page == 'view_message.php' || $current_page == 'resident_compose_message.php') ? 'active' : ''; ?>" href="messages.php"><i class="bi bi-inbox-fill"></i> Messages</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($current_page == 'calendar.php') ? 'active' : ''; ?>" href="calendar.php"><i class="bi bi-calendar-event-fill"></i> Calendar</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($current_page == 'resources.php') ? 'active' : ''; ?>" href="resources.php"><i class="bi bi-journal-bookmark-fill"></i> Resources</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="logout.php"><i class="bi bi-box-arrow-right"></i> Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Check if user is logged in and has the 'resident' role
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'resident') {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
@ -1,42 +0,0 @@
|
||||
<?php require_once 'includes/staff_session.php'; ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Staff Dashboard - Continuum Nexus</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.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="staff_dashboard.php">Continuum Nexus</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#staffNavbar" aria-controls="staffNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="staffNavbar">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="staff_dashboard.php"><i class="fas fa-tachometer-alt me-1"></i>Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="location_view.php"><i class="fas fa-map-marked-alt me-1"></i>Locations</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="messages.php"><i class="fas fa-envelope me-1"></i>Messages</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="resources.php"><i class="fas fa-book me-1"></i>Resources</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="logout.php"><i class="fas fa-sign-out-alt me-1"></i>Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
?>
|
||||
210
index.php
210
index.php
@ -1,80 +1,150 @@
|
||||
<?php
|
||||
session_start();
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
// 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 (isset($_SESSION['user_id'])) {
|
||||
if ($_SESSION['user_role'] === 'staff') {
|
||||
header("Location: staff_dashboard.php");
|
||||
} elseif ($_SESSION['user_role'] === 'resident') {
|
||||
header("Location: resident_dashboard.php");
|
||||
} elseif ($_SESSION['user_role'] === 'partner') {
|
||||
header("Location: partner_dashboard.php");
|
||||
}
|
||||
exit;
|
||||
}
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Welcome - Continuum Nexus</title>
|
||||
<meta name="description" content="Sign in to the Continuum Nexus platform.">
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:title" content="Welcome - Continuum Nexus">
|
||||
<meta property="og:description" content="Sign in to the Continuum Nexus platform.">
|
||||
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta property="twitter:card" content="summary_large_image">
|
||||
<meta property="twitter:title" content="Welcome - Continuum Nexus">
|
||||
<meta property="twitter:description" content="Sign in to the Continuum Nexus platform.">
|
||||
<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 rel="stylesheet" href="assets/css/custom.css">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="login-page">
|
||||
|
||||
<div class="login-container">
|
||||
<div class="login-card text-center">
|
||||
<h1>Continuum Nexus™</h1>
|
||||
<p class="subtitle">Please select your portal to continue</p>
|
||||
|
||||
<div class="d-grid gap-3">
|
||||
<a href="index.php?login_as=staff" class="btn btn-primary-custom btn-lg">Staff Portal</a>
|
||||
<a href="index.php?login_as=resident" class="btn btn-secondary-custom btn-lg">Resident Portal</a>
|
||||
<a href="index.php?login_as=partner" class="btn btn-info-custom btn-lg">Partner Portal</a>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
<div class="footer-text">
|
||||
© <?php echo date("Y"); ?> Continuum Nexus. Built with Flatlogic.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,93 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch resident counts by location
|
||||
$location_counts = $pdo->query("
|
||||
SELECT state, county, city, COUNT(id) as resident_count
|
||||
FROM residents
|
||||
GROUP BY state, county, city
|
||||
ORDER BY state, county, city
|
||||
")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Resident Location View | Continuum Nexus</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<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 Nexus</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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<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>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="location_view.php">Location View</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<h1 class="h2 mb-4">Resident Counts by Location</h1>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>State</th>
|
||||
<th>County</th>
|
||||
<th>City</th>
|
||||
<th class="text-end">Resident Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($location_counts)): ?>
|
||||
<?php foreach ($location_counts as $location): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($location['state']); ?></td>
|
||||
<td><?php echo htmlspecialchars($location['county']); ?></td>
|
||||
<td><?php echo htmlspecialchars($location['city']); ?></td>
|
||||
<td class="text-end"><?php echo $location['resident_count']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">No location data available.</td>
|
||||
</tr>
|
||||
<?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>
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
?>
|
||||
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$resident_id = isset($_GET['resident_id']) ? (int)$_GET['resident_id'] : 0;
|
||||
if ($resident_id === 0) {
|
||||
header("Location: partner_dashboard.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch resident details
|
||||
$stmt = $pdo->prepare("SELECT * FROM residents WHERE id = ?");
|
||||
$stmt->execute([$resident_id]);
|
||||
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$resident) {
|
||||
header("Location: partner_dashboard.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch documents for this resident
|
||||
$stmt = $pdo->prepare("SELECT * FROM documents WHERE resident_id = ? ORDER BY uploaded_at DESC");
|
||||
$stmt->execute([$resident_id]);
|
||||
$documents = $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>Manage Documents - <?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 rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<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 Nexus</a>
|
||||
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Manage Documents for <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h1>
|
||||
<a href="partner_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header">Uploaded Documents</div>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File Name</th>
|
||||
<th>Description</th>
|
||||
<th>Uploaded On</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($documents)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">No documents uploaded yet.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($documents as $doc): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($doc['file_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($doc['description']); ?></td>
|
||||
<td><?php echo date("M j, Y", strtotime($doc['uploaded_at'])); ?></td>
|
||||
<td>
|
||||
<a href="download_document.php?id=<?php echo $doc['id']; ?>" class="btn btn-sm btn-outline-primary">Download</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<div class="card-header">Upload New Document</div>
|
||||
<div class="card-body">
|
||||
<form action="upload_document.php" method="POST" enctype="multipart/form-data">
|
||||
<input type="hidden" name="resident_id" value="<?php echo $resident_id; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="document" class="form-label">Select File</label>
|
||||
<input type="file" name="document" id="document" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea name="description" id="description" class="form-control" rows="3" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom">Upload File</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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
95
messages.php
@ -1,95 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
@ -1,353 +0,0 @@
|
||||
<?php
|
||||
require_once 'includes/partner_header.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
$current_user_id = $_SESSION['user_id'];
|
||||
|
||||
// Get partner details from user_id
|
||||
$stmt = $pdo->prepare("SELECT * FROM partners WHERE user_id = ?");
|
||||
$stmt->execute([$current_user_id]);
|
||||
$partner = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$partner) {
|
||||
$error_message = "Could not find a partner profile linked to your user account.";
|
||||
} else {
|
||||
$partner_id = $partner['id'];
|
||||
|
||||
// -- Fetch assigned residents and their domain scores --
|
||||
$resident_sql = "
|
||||
SELECT
|
||||
r.id, r.first_name, r.last_name, r.program, r.status,
|
||||
GROUP_CONCAT(rs.domain, ':', rs.score_int, ':', rs.level SEPARATOR ';') as domain_data
|
||||
FROM residents r
|
||||
LEFT JOIN risk_scores rs ON r.id = rs.resident_id
|
||||
WHERE r.partner_id = ?
|
||||
GROUP BY r.id
|
||||
ORDER BY r.last_name, r.first_name
|
||||
";
|
||||
$resident_stmt = $pdo->prepare($resident_sql);
|
||||
$resident_stmt->execute([$partner_id]);
|
||||
$residents_raw = $resident_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$residents = array_map(function($res) {
|
||||
$res['domains'] = [];
|
||||
if ($res['domain_data']) {
|
||||
$domains_list = explode(';', $res['domain_data']);
|
||||
foreach ($domains_list as $d) {
|
||||
list($domain, $score, $level) = explode(':', $d);
|
||||
$res['domains'][$domain] = ['score' => $score, 'level' => $level];
|
||||
}
|
||||
}
|
||||
unset($res['domain_data']);
|
||||
return $res;
|
||||
}, $residents_raw);
|
||||
|
||||
// -- Performance Summary --
|
||||
$total_assigned = count($residents);
|
||||
$active_assigned = count(array_filter($residents, fn($r) => $r['status'] === 'Active'));
|
||||
|
||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM referrals WHERE partner_id = ?");
|
||||
$stmt->execute([$partner_id]);
|
||||
$total_referrals = $stmt->fetchColumn();
|
||||
|
||||
// -- Referral Data --
|
||||
$referral_sql = "
|
||||
SELECT
|
||||
ref.id, ref.referral_date, ref.status, ref.notes,
|
||||
res.first_name, res.last_name,
|
||||
u.email as staff_email
|
||||
FROM referrals ref
|
||||
JOIN residents res ON ref.resident_id = res.id
|
||||
JOIN users u ON ref.staff_user_id = u.id
|
||||
WHERE ref.partner_id = ?
|
||||
ORDER BY ref.referral_date DESC
|
||||
";
|
||||
$referral_stmt = $pdo->prepare($referral_sql);
|
||||
$referral_stmt->execute([$partner_id]);
|
||||
$referrals = $referral_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
// -- Fetch Messages --
|
||||
$message_sql = "
|
||||
SELECT m.id, m.subject, m.created_at, m.read_at, u.email as sender_email
|
||||
FROM messages m
|
||||
JOIN users u ON m.sender_user_id = u.id
|
||||
WHERE m.recipient_user_id = ?
|
||||
ORDER BY m.created_at DESC
|
||||
";
|
||||
$message_stmt = $pdo->prepare($message_sql);
|
||||
$message_stmt->execute([$current_user_id]);
|
||||
$messages = $message_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="partner_dashboard.php">Continuum Nexus</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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<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: <?php echo htmlspecialchars($partner['name']); ?></h1>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="residents-tab" data-bs-toggle="tab" data-bs-target="#residents" type="button" role="tab" aria-controls="residents" aria-selected="true">Assigned Residents</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="referrals-tab" data-bs-toggle="tab" data-bs-target="#referrals" type="button" role="tab" aria-controls="referrals" aria-selected="false">Referrals</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="documents-tab" data-bs-toggle="tab" data-bs-target="#documents" type="button" role="tab" aria-controls="documents" aria-selected="false">Documents</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<!-- Residents Tab -->
|
||||
<div class="tab-pane fade show active" id="residents" role="tabpanel" aria-labelledby="residents-tab">
|
||||
<div class="pt-4">
|
||||
<!-- Performance Summary -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Total Assigned</h5>
|
||||
<p class="card-text fs-4"><?php echo $total_assigned; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Active Residents</h5>
|
||||
<p class="card-text fs-4"><?php echo $active_assigned; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Total Referrals</h5>
|
||||
<p class="card-text fs-4"><?php echo $total_referrals; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Resident Domain-Focused View -->
|
||||
<h3 class="h4 mb-3">Assigned Resident Overview</h3>
|
||||
<div class="row gy-4">
|
||||
<?php if (empty($residents)): ?>
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info">No residents are currently assigned to you.</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($residents as $resident): ?>
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<div class="card h-100 shadow-sm">
|
||||
<div class="card-header bg-light">
|
||||
<h5 class="mb-0"><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text mb-2">
|
||||
<strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?><br>
|
||||
<strong>Status:</strong>
|
||||
<span class="badge bg-<?php echo $resident['status'] === 'Active' ? 'success' : 'secondary'; ?>"><?php echo htmlspecialchars($resident['status']); ?></span>
|
||||
</p>
|
||||
<h6 class="card-subtitle mt-3 mb-2 text-muted">Domain Risk Levels:</h6>
|
||||
<div class="d-flex justify-content-around text-center">
|
||||
<?php
|
||||
$domain_map = ['economic' => 'EC', 'education' => 'ED', 'healthcare' => 'HC', 'neighborhood' => 'NB', 'social' => 'SO'];
|
||||
foreach ($domain_map as $domain_id => $abbr):
|
||||
$level = $resident['domains'][$domain_id]['level'] ?? 'N/A';
|
||||
$level_class = 'bg-secondary';
|
||||
if ($level === 'High') $level_class = 'bg-danger';
|
||||
if ($level === 'Moderate') $level_class = 'bg-warning text-dark';
|
||||
if ($level === 'Low') $level_class = 'bg-success';
|
||||
?>
|
||||
<div>
|
||||
<span class="badge <?php echo $level_class; ?>" title="<?php echo htmlspecialchars(ucfirst($domain_id)); ?>"><?php echo $abbr; ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-white text-end">
|
||||
<a href="#" class="btn btn-sm btn-outline-primary">View Details</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Referrals Tab -->
|
||||
<div class="tab-pane fade" id="referrals" role="tabpanel" aria-labelledby="referrals-tab">
|
||||
<div class="pt-4">
|
||||
<h3 class="h4 mb-3">Referral Tracker</h3>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Resident</th>
|
||||
<th>Referred By</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($referrals)): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted">No referrals found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($referrals as $referral): ?>
|
||||
<tr>
|
||||
<td><?php echo date("M j, Y", strtotime($referral['referral_date'])); ?></td>
|
||||
<td><?php echo htmlspecialchars($referral['first_name'] . ' ' . $referral['last_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($referral['staff_email']); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$ref_status_color = 'secondary';
|
||||
if ($referral['status'] === 'Accepted') $ref_status_color = 'success';
|
||||
if ($referral['status'] === 'Rejected') $ref_status_color = 'danger';
|
||||
?>
|
||||
<span class="badge bg-<?php echo $ref_status_color; ?>"><?php echo htmlspecialchars($referral['status']); ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($referral['status'] === 'Pending'): ?>
|
||||
<button class="btn btn-success btn-sm btn-action" data-action="Accepted" data-referral-id="<?php echo $referral['id']; ?>">Accept</button>
|
||||
<button class="btn btn-danger btn-sm btn-action" data-action="Rejected" data-referral-id="<?php echo $referral['id']; ?>">Reject</button>
|
||||
<?php else: ?>
|
||||
<button class="btn btn-secondary btn-sm" disabled>Handled</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Messages Tab -->
|
||||
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab">
|
||||
<div class="pt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h3 class="h4">Inbox</h3>
|
||||
<a href="compose_message.php" class="btn btn-primary-custom"><i class="bi bi-pencil-square me-2"></i>Compose Message</a>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php if (empty($messages)): ?>
|
||||
<div class="list-group-item text-center text-muted">You have no messages.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($messages as $message): ?>
|
||||
<a href="view_message.php?id=<?php echo $message['id']; ?>" class="list-group-item list-group-item-action <?php echo !$message['read_at'] ? 'fw-bold' : ''; ?>">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h6 class="mb-1"><?php echo htmlspecialchars($message['subject']); ?></h6>
|
||||
<small><?php echo date("M j, Y", strtotime($message['created_at'])); ?></small>
|
||||
</div>
|
||||
<p class="mb-1">From: <?php echo htmlspecialchars($message['sender_email']); ?></p>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Documents Tab -->
|
||||
<div class="tab-pane fade" id="documents" role="tabpanel" aria-labelledby="documents-tab">
|
||||
<div class="pt-4">
|
||||
<h3 class="h4 mb-3">Document Management</h3>
|
||||
<div class="list-group">
|
||||
<?php if (empty($residents)): ?>
|
||||
<div class="list-group-item text-center text-muted">No residents assigned to you.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($residents as $resident): ?>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></span>
|
||||
<a href="manage_documents.php?resident_id=<?php echo $resident['id']; ?>" class="btn btn-outline-primary btn-sm">Manage Documents</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const actionButtons = document.querySelectorAll('.btn-action');
|
||||
|
||||
actionButtons.forEach(button => {
|
||||
button.addEventListener('click', function () {
|
||||
const referralId = this.dataset.referralId;
|
||||
const newStatus = this.dataset.action;
|
||||
const row = this.closest('tr');
|
||||
|
||||
if (!confirm(`Are you sure you want to ${newStatus.toLowerCase()} this referral?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('update_referral_status.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
referral_id: referralId,
|
||||
status: newStatus
|
||||
}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// Update the UI
|
||||
const statusCell = row.querySelector('td:nth-child(4) span');
|
||||
statusCell.textContent = newStatus;
|
||||
statusCell.className = `badge bg-${newStatus === 'Accepted' ? 'success' : 'danger'}`;
|
||||
|
||||
const actionCell = row.querySelector('td:nth-child(5)');
|
||||
actionCell.innerHTML = '<button class="btn btn-secondary btn-sm" disabled>Handled</button>';
|
||||
|
||||
// Optional: show a success message
|
||||
// alert(data.message);
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fetch Error:', error);
|
||||
alert('An unexpected error occurred. Please try again.');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,84 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
@ -1,148 +0,0 @@
|
||||
<?php
|
||||
require_once 'includes/resident_session.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
$resident_id = $_SESSION['user_id'];
|
||||
$pdo = db();
|
||||
|
||||
// Fetch resident's first name
|
||||
$stmt = $pdo->prepare("SELECT first_name FROM residents WHERE id = ?");
|
||||
$stmt->execute([$resident_id]);
|
||||
$resident_name = $stmt->fetchColumn();
|
||||
|
||||
// Fetch resident's domain risk scores, levels, and drivers
|
||||
$risk_scores_stmt = $pdo->prepare("
|
||||
SELECT domain, score_int, level, drivers
|
||||
FROM risk_scores
|
||||
WHERE resident_id = ?
|
||||
ORDER BY domain
|
||||
");
|
||||
$risk_scores_stmt->execute([$resident_id]);
|
||||
$risk_scores = $risk_scores_stmt->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);
|
||||
|
||||
// Fetch resident's action plans
|
||||
$action_plans_stmt = $pdo->prepare("
|
||||
SELECT ap.id, ap.title, ap.status, ap.domain_key
|
||||
FROM action_plans ap
|
||||
WHERE ap.resident_id = ?
|
||||
ORDER BY ap.created_at DESC
|
||||
");
|
||||
$action_plans_stmt->execute([$resident_id]);
|
||||
$action_plans = $action_plans_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
// Domain names mapping
|
||||
$domains = [
|
||||
'economic' => 'Economic Stability',
|
||||
'education' => 'Education Access & Quality',
|
||||
'healthcare' => 'Health Care Access & Quality',
|
||||
'neighborhood' => 'Neighborhood & Built Environment',
|
||||
'social' => 'Social & Community Context',
|
||||
];
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Resident Dashboard | Continuum Nexus</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'includes/resident_header.php'; ?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Welcome, <?php echo htmlspecialchars($resident_name); ?>!</h1>
|
||||
<div>
|
||||
<a href="messages.php" class="btn btn-primary-custom"><i class="bi bi-inbox-fill me-2"></i>My Messages</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="mb-4">Your Domain Overview</h3>
|
||||
<div class="row">
|
||||
<?php foreach ($domains as $domain_id => $domain_name): ?>
|
||||
<?php
|
||||
$score_data = $risk_scores[$domain_id][0] ?? null;
|
||||
$score = $score_data ? (int)$score_data['score_int'] : 0;
|
||||
$level = $score_data ? ucfirst($score_data['level']) : 'N/A';
|
||||
$drivers = $score_data && $score_data['drivers'] ? json_decode($score_data['drivers'], true) : [];
|
||||
|
||||
$level_class = 'text-bg-secondary';
|
||||
if ($level === 'High') $level_class = 'text-bg-danger';
|
||||
if ($level === 'Moderate') $level_class = 'text-bg-warning';
|
||||
if ($level === 'Low') $level_class = 'text-bg-success';
|
||||
?>
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card h-100">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0"><?php echo htmlspecialchars($domain_name); ?></h5>
|
||||
<span class="badge <?php echo $level_class; ?>"><?php echo htmlspecialchars($level); ?></span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="text-center mb-3">
|
||||
<p class="display-4 fw-bold mb-0"><?php echo $score; ?><span class="fs-5">/100</span></p>
|
||||
<p class="text-muted mb-0">Risk Score</p>
|
||||
</div>
|
||||
<?php if (!empty($drivers)): ?>
|
||||
<h6 class="card-subtitle mb-2 text-muted">Key Factors:</h6>
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach ($drivers as $driver): ?>
|
||||
<li class="list-group-item">- <?php echo htmlspecialchars($driver['label']); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p class="text-muted text-center">No specific risk factors identified.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h4 class="mb-0"><i class="bi bi-list-check me-2"></i>Your Action Plans</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Domain</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($action_plans)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">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 text-bg-info"><?php echo htmlspecialchars($domains[$plan['domain_key']] ?? 'N/A'); ?></span></td>
|
||||
<td><span class="badge text-bg-primary"><?php echo htmlspecialchars(ucfirst($plan['status'])); ?></span></td>
|
||||
<td class="text-end">
|
||||
<a href="view_action_plan.php?id=<?php echo $plan['id']; ?>" class="btn btn-sm btn-outline-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>
|
||||
@ -1,150 +0,0 @@
|
||||
<?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 = ?, health_progress = ?, housing_progress = ?, employment_progress = ? 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'],
|
||||
$_POST['health_progress'],
|
||||
$_POST['housing_progress'],
|
||||
$_POST['employment_progress'],
|
||||
$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 Nexus</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 Nexus</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>
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<h5 class="mb-3">Continuum Progress</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="health_progress" class="form-label">Health Progress</label>
|
||||
<input type="range" class="form-range" id="health_progress" name="health_progress" min="0" max="100" step="10" value="<?php echo htmlspecialchars($resident['health_progress']); ?>">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="housing_progress" class="form-label">Housing Progress</label>
|
||||
<input type="range" class="form-range" id="housing_progress" name="housing_progress" min="0" max="100" step="10" value="<?php echo htmlspecialchars($resident['housing_progress']); ?>">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="employment_progress" class="form-label">Employment Progress</label>
|
||||
<input type="range" class="form-range" id="employment_progress" name="employment_progress" min="0" max="100" step="10" value="<?php echo htmlspecialchars($resident['employment_progress']); ?>">
|
||||
</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>
|
||||
@ -1,130 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
@ -1,179 +0,0 @@
|
||||
<?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();
|
||||
|
||||
// Fetch resident details
|
||||
$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;
|
||||
}
|
||||
|
||||
// Fetch action plans for the resident
|
||||
$action_plan_stmt = $pdo->prepare("SELECT * FROM action_plans WHERE resident_id = ? ORDER BY created_at DESC");
|
||||
$action_plan_stmt->execute([$resident_id]);
|
||||
$action_plans = $action_plan_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch case notes for the resident
|
||||
$case_notes_stmt = $pdo->prepare("SELECT * FROM case_notes WHERE resident_id = ? ORDER BY created_at DESC");
|
||||
$case_notes_stmt->execute([$resident_id]);
|
||||
$case_notes = $case_notes_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>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 rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<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 Nexus</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">Resident: <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></h1>
|
||||
<a href="staff_dashboard.php" class="btn btn-secondary">← Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<!-- Resident Details Card -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span>Resident Information</span>
|
||||
<div>
|
||||
<a href="resident_edit.php?id=<?php echo $resident_id; ?>" class="btn btn-secondary btn-sm">Edit</a>
|
||||
<?php if ($resident['status'] !== 'Stabilized'): ?>
|
||||
<form action="update_resident_status.php" method="POST" class="d-inline">
|
||||
<input type="hidden" name="resident_id" value="<?php echo $resident_id; ?>">
|
||||
<input type="hidden" name="status" value="Stabilized">
|
||||
<button type="submit" class="btn btn-success btn-sm">Mark as Stabilized</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</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>Email:</strong> <?php echo htmlspecialchars($resident['email']); ?></p>
|
||||
<p><strong>Phone:</strong> <?php echo htmlspecialchars($resident['phone_number'] ?? 'N/A'); ?></p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
||||
<p><strong>Status:</strong> <span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
||||
<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 class="row">
|
||||
<div class="col-md-8">
|
||||
<!-- Action Plans Card -->
|
||||
<div class="card mb-4">
|
||||
<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>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($action_plans)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">No action plans found.</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>
|
||||
<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 class="col-md-4">
|
||||
<!-- Case Notes Card -->
|
||||
<div class="card">
|
||||
<div class="card-header">Case Notes</div>
|
||||
<div class="card-body">
|
||||
<!-- Add Note Form -->
|
||||
<form action="add_case_note.php" method="POST" class="mb-3">
|
||||
<input type="hidden" name="resident_id" value="<?php echo $resident_id; ?>">
|
||||
<div class="mb-2">
|
||||
<textarea name="note" class="form-control" rows="3" placeholder="Add a new note..." required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom btn-sm w-100">Add Note</button>
|
||||
</form>
|
||||
<!-- Notes List -->
|
||||
<div class="list-group list-group-flush">
|
||||
<?php if (empty($case_notes)): ?>
|
||||
<div class="list-group-item text-muted text-center">No notes yet.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($case_notes as $note): ?>
|
||||
<div class="list-group-item">
|
||||
<p class="mb-1"><?php echo nl2br(htmlspecialchars($note['note'])); ?></p>
|
||||
<small class="text-muted">On <?php echo date("M j, Y, g:i a", strtotime($note['created_at'])); ?></small>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,74 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
@ -1,34 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$sender_user_id = $_SESSION['user_id'];
|
||||
$recipient_user_id = isset($_POST['recipient_user_id']) ? (int)$_POST['recipient_user_id'] : 0;
|
||||
$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
|
||||
header("Location: " . $redirect_url . "?error=empty_message");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$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]);
|
||||
|
||||
header("Location: " . $redirect_url . "?success=message_sent");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, log this error.
|
||||
header("Location: " . $redirect_url . "?error=db_error");
|
||||
exit;
|
||||
}
|
||||
@ -1,164 +0,0 @@
|
||||
<?php
|
||||
include 'includes/staff_header.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
// --- Data Fetching and Preparation ---
|
||||
|
||||
// Sample Data Generation (as requested)
|
||||
$residents = [];
|
||||
$domains = ['Economic Stability', 'Education', 'Health and Healthcare', 'Neighborhood and Environment', 'Social and Community Context'];
|
||||
$risk_levels = ['Low', 'Medium', 'High', 'Critical'];
|
||||
|
||||
for ($i = 1; $i <= 20; $i++) {
|
||||
$risk_score = rand(10, 95);
|
||||
$domain_scores = [];
|
||||
foreach ($domains as $domain) {
|
||||
$domain_scores[$domain] = $risk_levels[array_rand($risk_levels)];
|
||||
}
|
||||
|
||||
$residents[] = [
|
||||
'id' => $i,
|
||||
'name' => "Resident #$i",
|
||||
'risk_score' => $risk_score,
|
||||
'progress' => rand(-20, 20),
|
||||
'domain_scores' => $domain_scores,
|
||||
'last_check_in' => date('Y-m-d', time() - rand(0, 30) * 86400),
|
||||
'has_critical_alert' => $risk_score > 85
|
||||
];
|
||||
}
|
||||
|
||||
// --- Aggregate Calculations ---
|
||||
$total_residents = count($residents);
|
||||
$high_risk_alerts = array_reduce($residents, function($carry, $res) {
|
||||
return $carry + ($res['risk_score'] > 75 ? 1 : 0);
|
||||
}, 0);
|
||||
$avg_progress = array_reduce($residents, function($carry, $res) { return $carry + $res['progress']; }, 0) / $total_residents;
|
||||
|
||||
// Filter for search query
|
||||
$search_query = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||
if ($search_query) {
|
||||
$residents = array_filter($residents, function($res) use ($search_query) {
|
||||
return stripos($res['name'], $search_query) !== false;
|
||||
});
|
||||
}
|
||||
|
||||
// Get residents with critical alerts for the dedicated section
|
||||
$alert_residents = array_filter($residents, function($res) {
|
||||
return $res['has_critical_alert'];
|
||||
});
|
||||
|
||||
?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<!-- Page Title -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">Aggregate Dashboard</h1>
|
||||
<a href="create_action_plan.php" class="btn btn-success"><i class="fas fa-plus me-2"></i>Generate New Action Plan</a>
|
||||
</div>
|
||||
|
||||
<!-- Aggregate KPI Cards -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-title text-muted">Total Residents</p>
|
||||
<h2 class="display-5"><?php echo $total_residents; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center shadow-sm text-white bg-danger">
|
||||
<div class="card-body">
|
||||
<p class="card-title">High-Risk Alerts</p>
|
||||
<h2 class="display-5"><?php echo $high_risk_alerts; ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card text-center shadow-sm">
|
||||
<div class="card-body">
|
||||
<p class="card-title text-muted">Avg. Progress Change</p>
|
||||
<h2 class="display-5"><?php echo number_format($avg_progress, 1); ?>%</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Critical Alerts Section -->
|
||||
<?php if (!empty($alert_residents)): ?>
|
||||
<div class="card shadow-sm mb-4 border-danger">
|
||||
<div class="card-header bg-danger text-white">
|
||||
<h5 class="mb-0"><i class="fas fa-exclamation-triangle me-2"></i>Critical Warning Alerts</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach ($alert_residents as $res): ?>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<a href="resident_view.php?resident_id=<?php echo $res['id']; ?>" class="fw-bold text-decoration-none"><?php echo htmlspecialchars($res['name']); ?></a>
|
||||
<small class="text-muted ms-2">Risk Score: <?php echo $res['risk_score']; ?>%</small>
|
||||
</div>
|
||||
<a href="resident_view.php?resident_id=<?php echo $res['id']; ?>" class="btn btn-sm btn-outline-primary">View Plan</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- All Residents List -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">All Residents</h5>
|
||||
<form class="d-flex" method="GET" action="staff_dashboard.php">
|
||||
<input class="form-control me-2" type="search" placeholder="Search residents..." name="search" value="<?php echo htmlspecialchars($search_query); ?>">
|
||||
<button class="btn btn-outline-secondary" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th class="text-center">Risk Score</th>
|
||||
<th class="text-center">Progress</th>
|
||||
<th>Last Check-In</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($residents)): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted">No residents found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($residents as $resident): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="resident_view.php?resident_id=<?php echo $resident['id']; ?>" class="text-decoration-none fw-bold"><?php echo htmlspecialchars($resident['name']); ?></a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-<?php echo $resident['risk_score'] > 75 ? 'danger' : ($resident['risk_score'] > 50 ? 'warning' : 'success'); ?>">
|
||||
<?php echo $resident['risk_score']; ?>%
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="text-<?php echo $resident['progress'] >= 0 ? 'success' : 'danger'; ?>">
|
||||
<i class="fas fa-arrow-<?php echo $resident['progress'] >= 0 ? 'up' : 'down'; ?>"></i>
|
||||
<?php echo abs($resident['progress']); ?>%
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo $resident['last_check_in']; ?></td>
|
||||
<td class="text-end">
|
||||
<a href="resident_view.php?resident_id=<?php echo $resident['id']; ?>" class="btn btn-sm btn-primary">View</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'includes/footer.php'; // Assuming a footer file exists ?>
|
||||
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$resident_id = isset($_POST['resident_id']) ? (int)$_POST['resident_id'] : 0;
|
||||
$partner_id = isset($_POST['partner_id']) ? (int)$_POST['partner_id'] : 0;
|
||||
$staff_id = isset($_POST['staff_id']) ? (int)$_POST['staff_id'] : 0;
|
||||
$notes = isset($_POST['notes']) ? trim($_POST['notes']) : '';
|
||||
|
||||
if ($resident_id === 0 || $partner_id === 0 || $staff_id === 0 || empty($notes)) {
|
||||
header("Location: create_referral.php?resident_id={$resident_id}&error=invalid_data");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "INSERT INTO referrals (resident_id, partner_id, staff_id, notes) VALUES (?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$resident_id, $partner_id, $staff_id, $notes]);
|
||||
|
||||
header("Location: resident_view.php?id={$resident_id}&success=referral_sent");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// Log error in a real app
|
||||
header("Location: create_referral.php?resident_id={$resident_id}&error=db_error");
|
||||
exit;
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Check if user is a logged-in partner
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
||||
echo json_encode(['success' => false, 'message' => 'Unauthorized']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check for POST request
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid request method.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get and validate input
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$referral_id = $input['referral_id'] ?? null;
|
||||
$new_status = $input['status'] ?? null;
|
||||
|
||||
if (!$referral_id || !$new_status) {
|
||||
echo json_encode(['success' => false, 'message' => 'Missing required parameters.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!in_array($new_status, ['Accepted', 'Rejected'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid status.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Verify the partner owns this referral
|
||||
$stmt = $pdo->prepare("SELECT r.id FROM referrals r JOIN partners p ON r.partner_id = p.id WHERE r.id = ? AND p.user_id = ?");
|
||||
$stmt->execute([$referral_id, $_SESSION['user_id']]);
|
||||
$referral = $stmt->fetch();
|
||||
|
||||
if (!$referral) {
|
||||
echo json_encode(['success' => false, 'message' => 'Referral not found or you do not have permission to modify it.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Update the referral status
|
||||
try {
|
||||
$update_stmt = $pdo->prepare("UPDATE referrals SET status = ? WHERE id = ?");
|
||||
$update_stmt->execute([$new_status, $referral_id]);
|
||||
|
||||
if ($update_stmt->rowCount() > 0) {
|
||||
echo json_encode(['success' => true, 'message' => 'Referral status updated successfully.']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to update status or status was already set.']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Log error properly in a real application
|
||||
echo json_encode(['success' => false, 'message' => 'Database error: ' . $e->getMessage()]);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: staff_dashboard.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if user is logged in and has the 'staff' role
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'staff') {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$resident_id = isset($_POST['resident_id']) ? (int)$_POST['resident_id'] : 0;
|
||||
$status = isset($_POST['status']) ? trim($_POST['status']) : '';
|
||||
|
||||
// Basic validation
|
||||
if ($resident_id === 0 || empty($status)) {
|
||||
header("Location: staff_dashboard.php?error=invalid_data");
|
||||
exit;
|
||||
}
|
||||
|
||||
// You might want to validate the status against a list of allowed statuses
|
||||
$allowed_statuses = ['Active', 'Inactive', 'Stabilized'];
|
||||
if (!in_array($status, $allowed_statuses)) {
|
||||
header("Location: resident_view.php?id={$resident_id}&error=invalid_status");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE residents SET status = ? WHERE id = ?");
|
||||
$stmt->execute([$status, $resident_id]);
|
||||
|
||||
// Redirect back to the resident's view page
|
||||
header("Location: resident_view.php?id={$resident_id}&success=status_updated");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// Log the error in a real app
|
||||
header("Location: resident_view.php?id={$resident_id}&error=db_error");
|
||||
exit;
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
||||
header('HTTP/1.1 403 Forbidden');
|
||||
exit("Access denied.");
|
||||
}
|
||||
|
||||
$resident_id = isset($_POST['resident_id']) ? (int)$_POST['resident_id'] : 0;
|
||||
$description = isset($_POST['description']) ? trim($_POST['description']) : '';
|
||||
|
||||
if ($resident_id === 0 || empty($description) || !isset($_FILES['document']) || $_FILES['document']['error'] !== UPLOAD_ERR_OK) {
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&error=invalid_upload");
|
||||
exit;
|
||||
}
|
||||
|
||||
$file = $_FILES['document'];
|
||||
$upload_dir = __DIR__ . '/uploads/documents/';
|
||||
$original_name = basename($file['name']);
|
||||
$file_extension = pathinfo($original_name, PATHINFO_EXTENSION);
|
||||
$unique_name = uniqid('', true) . '.' . $file_extension;
|
||||
$target_path = $upload_dir . $unique_name;
|
||||
|
||||
// Basic security checks
|
||||
$allowed_extensions = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png'];
|
||||
if (!in_array(strtolower($file_extension), $allowed_extensions)) {
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&error=invalid_file_type");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($file['size'] > 5 * 1024 * 1024) { // 5MB limit
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&error=file_too_large");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (move_uploaded_file($file['tmp_name'], $target_path)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$partner_id = null;
|
||||
$stmt = $pdo->prepare("SELECT id FROM partners WHERE user_id = ?");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$partner_id = $stmt->fetchColumn();
|
||||
|
||||
$sql = "INSERT INTO documents (resident_id, partner_id, file_name, file_path, description) VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$resident_id, $partner_id, $original_name, $target_path, $description]);
|
||||
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&success=uploaded");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// Clean up the uploaded file if DB insert fails
|
||||
unlink($target_path);
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&error=db_error");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header("Location: manage_documents.php?resident_id={$resident_id}&error=upload_failed");
|
||||
exit;
|
||||
}
|
||||
@ -1,123 +0,0 @@
|
||||
<?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 Nexus</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 Nexus</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>
|
||||
125
view_message.php
125
view_message.php
@ -1,125 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_role = $_SESSION['user_role'];
|
||||
|
||||
$message_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
if ($message_id === 0) {
|
||||
$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;
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch message details
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT m.*, u.email as sender_email
|
||||
FROM messages m
|
||||
JOIN users u ON m.sender_user_id = u.id
|
||||
WHERE m.id = ?
|
||||
");
|
||||
$stmt->execute([$message_id]);
|
||||
$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 = '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;
|
||||
}
|
||||
|
||||
// Mark as read if the current user is the recipient
|
||||
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">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>View Message - Continuum Nexus</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 Nexus</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="<?php echo $back_link; ?>" class="btn btn-secondary">← Back to Messages</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5><?php echo htmlspecialchars($message['subject']); ?></h5>
|
||||
<small class="text-muted">From: <?php echo htmlspecialchars($message['sender_email']); ?> on <?php echo date("M j, Y, g:i a", strtotime($message['created_at'])); ?></small>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?php echo nl2br(htmlspecialchars($message['body'])); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Reply</div>
|
||||
<div class="card-body">
|
||||
<form action="send_message.php" method="POST">
|
||||
<input type="hidden" name="recipient_user_id" value="<?php echo $message['sender_user_id']; ?>">
|
||||
<input type="hidden" name="subject" value="Re: <?php echo htmlspecialchars($message['subject']); ?>">
|
||||
<div class="mb-3">
|
||||
<label for="body" class="form-label">Message</label>
|
||||
<textarea name="body" id="body" class="form-control" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary-custom">Send Reply</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>
|
||||
Loading…
x
Reference in New Issue
Block a user