36695-vm/hospital_dashboard.php
2025-12-07 18:31:47 +00:00

104 lines
4.4 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['hospital_id'])) {
header("Location: hospital_login.php");
exit;
}
$hospitalName = $_SESSION['hospital_name'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hospital Dashboard - Organ Donation</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
}
</style>
</head>
<body class="bg-gray-100">
<nav class="bg-white shadow-md">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<a href="index.php" class="flex-shrink-0 flex items-center">
<span class="font-bold text-xl text-blue-600">OrganConnect</span>
</a>
</div>
<div class="flex items-center">
<span class="mr-4">Welcome, <?php echo htmlspecialchars($hospitalName); ?>!</span>
<a href="logout.php" class="px-3 py-2 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-200">Logout</a>
</div>
</div>
</div>
</nav>
<div class="container mx-auto px-4 py-12">
<h1 class="text-3xl font-bold text-gray-800 mb-6">Hospital Dashboard</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-white p-6 rounded-lg shadow-lg">
<h2 class="text-xl font-bold mb-4">Recipient Management</h2>
<p class="text-gray-600 mb-4">Register new recipients and manage existing patient records.</p>
<a href="recipient_registration.php" class="text-blue-600 hover:underline">Register a New Recipient &rarr;</a>
</div>
<div class="bg-white p-6 rounded-lg shadow-lg">
<h2 class="text-xl font-bold mb-4">View Registered Recipients</h2>
<p class="text-gray-600 mb-4">View a list of all patients registered by your hospital.</p>
<a href="hospital_dashboard.php?view=recipients" class="text-blue-600 hover:underline">View Recipients &rarr;</a>
</div>
</div>
<?php
if (isset($_GET['view']) && $_GET['view'] == 'recipients'):
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM recipients WHERE hospital_id = ? ORDER BY created_at DESC");
$stmt->execute([$_SESSION['hospital_id']]);
$recipients = $stmt->fetchAll();
?>
<div class="mt-12 bg-white p-8 rounded-lg shadow-lg">
<h2 class="text-2xl font-bold text-gray-800 mb-6">Registered Recipients</h2>
<div class="overflow-x-auto">
<table class="min-w-full bg-white">
<thead class="bg-gray-200">
<tr>
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">Patient Name</th>
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">Organ Needed</th>
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">Blood Type</th>
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">Registered On</th>
</tr>
</thead>
<tbody>
<?php if (empty($recipients)): ?>
<tr>
<td colspan="4" class="text-center py-4 text-gray-500">No recipients registered yet.</td>
</tr>
<?php else: ?>
<?php foreach ($recipients as $recipient): ?>
<tr class="border-b">
<td class="py-3 px-4"><?= htmlspecialchars($recipient['patient_name']) ?></td>
<td class="py-3 px-4"><?= htmlspecialchars($recipient['organ_needed']) ?></td>
<td class="py-3 px-4"><?= htmlspecialchars($recipient['blood_type']) ?></td>
<td class="py-3 px-4"><?= date("M d, Y", strtotime($recipient['created_at'])) ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
</div>
</body>
</html>