96 lines
3.9 KiB
PHP
96 lines
3.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'partner') {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
$pdo = db();
|
|
|
|
// Get partner details
|
|
$stmt = $pdo->prepare("SELECT * FROM partners WHERE user_id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$partner = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$partner) {
|
|
$error_message = "Could not find a partner profile linked to your user account.";
|
|
} else {
|
|
// Get residents assigned to this partner
|
|
$stmt = $pdo->prepare("SELECT * FROM residents WHERE partner_id = ? ORDER BY last_name, first_name");
|
|
$stmt->execute([$partner['id']]);
|
|
$residents = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Partner Dashboard - Continuum of Healing</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="partner_dashboard.php">Continuum of Healing</a>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="#">Dashboard</a>
|
|
</li>
|
|
</ul>
|
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-4">
|
|
<?php if (isset($error_message)): ?>
|
|
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
|
<?php elseif (isset($partner)): ?>
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h2">Partner Dashboard: <?php echo htmlspecialchars($partner['name']); ?></h1>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">Assigned Residents</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Program</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($residents)): ?>
|
|
<tr>
|
|
<td colspan="3" class="text-center">No residents are currently assigned to you.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($residents as $resident): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($resident['first_name'] . ' ' . $resident['last_name']); ?></td>
|
|
<td><?php echo htmlspecialchars($resident['program']); ?></td>
|
|
<td><span class="badge bg-primary"><?php echo htmlspecialchars($resident['status']); ?></span></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|