-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin_dashboard.php
More file actions
101 lines (88 loc) · 3.3 KB
/
Copy pathadmin_dashboard.php
File metadata and controls
101 lines (88 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
session_start();
include_once('database.php');
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true || $_SESSION['isAdmin'] !== 1) {
header("Location: adminlogin.html");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Admin Dashboard</title>
<link rel="stylesheet" href="styles.css">
<style>
#inventory-summary table, #recent-donations table {
width: 80%;
margin: 20px auto;
border-collapse: collapse;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
th, td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<h1>Welcome, Admin!</h1>
<h2 style="text-align: center;">Inventory Summary</h2>
<div id="inventory-summary">
<?php
try {
$stmt = $conn->query("SELECT BloodType, COUNT(*) AS Count FROM Inventory GROUP BY BloodType");
$inventorySummary = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($inventorySummary)) {
echo "<table id='inventory-table'>";
echo "<tr><th>Blood Type</th><th>Count</th></tr>";
foreach ($inventorySummary as $row) {
echo "<tr><td>" . htmlspecialchars($row['BloodType'], ENT_QUOTES, 'UTF-8') .
"</td><td>" . htmlspecialchars($row['Count'], ENT_QUOTES, 'UTF-8') . "</td></tr>";
}
echo "</table>";
} else {
echo "<p>No inventory data found.</p>";
}
} catch (PDOException $e) {
error_log("Error fetching inventory: " . $e->getMessage());
echo "<p>Error fetching inventory summary.</p>";
}
?>
</div>
<h2 style="text-align: center;">Recent Donations</h2>
<div id="recent-donations">
<?php
try {
$stmt = $conn->query("SELECT DonorName, DonationDate, BloodType FROM Donation ORDER BY DonationDate DESC LIMIT 10");
$recentDonations = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($recentDonations)) {
echo "<table id='donations-table'>";
echo "<tr><th>Donor Name</th><th>Donation Date</th><th>Blood Type</th></tr>";
foreach ($recentDonations as $row) {
echo "<tr><td>" . htmlspecialchars($row['DonorName'], ENT_QUOTES, 'UTF-8') .
"</td><td>" . htmlspecialchars($row['DonationDate'], ENT_QUOTES, 'UTF-8') .
"</td><td>" . htmlspecialchars($row['BloodType'], ENT_QUOTES, 'UTF-8') . "</td></tr>";
}
echo "</table>";
} else {
echo "<p>No recent donations found.</p>";
}
} catch (PDOException $e) {
error_log("Error fetching donations: " . $e->getMessage());
echo "<p>Error fetching recent donations.</p>";
}
?>
</div>
<a href="useDonation.php">Manage Donations</a><br>
<a href="MedicalReport.html">Medical Reports</a><br>
<a href="user_info.php">Registered Users</a><br>
<a href="logout.php">Logout</a>
</body>
</html>