99 lines
3.6 KiB
PHP
99 lines
3.6 KiB
PHP
<?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;
|
|
}
|
|
|
|
// Get resident ID from URL
|
|
$resident_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|
|
|
if ($resident_id === 0) {
|
|
header("Location: staff_dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
// Fetch resident details from the database
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE id = ?");
|
|
$stmt->execute([$resident_id]);
|
|
$resident = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$resident) {
|
|
// No resident found, redirect
|
|
header("Location: staff_dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
$error_message = "Error fetching resident data.";
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>View Resident | Continuum of Healing</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="staff_dashboard.php">Continuum of Healing</a>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="staff_dashboard.php">Dashboard</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="d-flex">
|
|
<span class="navbar-text me-3">
|
|
Logged in as: <?php echo htmlspecialchars($_SESSION['user_email']); ?>
|
|
</span>
|
|
<a href="logout.php" class="btn btn-outline-danger">Logout</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h2">Resident Details</h1>
|
|
<a href="staff_dashboard.php" class="btn btn-light">« Back to Dashboard</a>
|
|
</div>
|
|
|
|
<?php if (isset($error_message)): ?>
|
|
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
|
<?php elseif (isset($resident)): ?>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
Viewing <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<p><strong>Name:</strong> <?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></p>
|
|
<p><strong>Program:</strong> <?php echo htmlspecialchars($resident['program']); ?></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<p><strong>Status:</strong> <span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></p>
|
|
<p><strong>Last Check-in:</strong> <?php echo htmlspecialchars(date("M j, Y, g:i a", strtotime($resident['last_check_in']))); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|