-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarden_dashboard.php
More file actions
122 lines (94 loc) · 3.99 KB
/
warden_dashboard.php
File metadata and controls
122 lines (94 loc) · 3.99 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
include 'include/connect.php';
$popupMessage = isset($_GET['message']) ? urldecode($_GET['message']) : '';
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'warden') {
header('Location: warden_login.php');
exit();
}
$wardenId = $_SESSION['user_id'];
$hostelId = $_SESSION['hostel_id'];
$sqlCountPending = "SELECT COUNT(*) AS pending_count FROM application WHERE hostel_id = ? AND status = 'requested'";
$stmtCountPending = $conn->prepare($sqlCountPending);
$stmtCountPending->bind_param("s", $hostelId);
$stmtCountPending->execute();
$resultCountPending = $stmtCountPending->get_result();
if ($rowCountPending = $resultCountPending->fetch_assoc()) {
$pendingCount = $rowCountPending['pending_count'];
} else {
$pendingCount = 0;
}
$stmtCountPending->close();
$sqlRooms = "SELECT room_number, student_1, student_2, student_3 FROM room WHERE hostel_id = ?";
$stmtRooms = $conn->prepare($sqlRooms);
$stmtRooms->bind_param("s", $hostelId);
$stmtRooms->execute();
$resultRooms = $stmtRooms->get_result();
if ($resultRooms->num_rows > 0) {
$rooms = $resultRooms->fetch_all(MYSQLI_ASSOC);
} else {
$rooms = [];
}
$stmtRooms->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Warden Dashboard</title>
<link rel="stylesheet" href="https://cdn.tailwindcss.com">
</head>
<body class="bg-gray-100 h-screen flex items-center justify-center">
<script>
var popupMessage = '<?php echo $popupMessage; ?>';
if (popupMessage.trim() !== '') {
alert(popupMessage);
}
</script>
<?php include 'include/header.php'; ?>
<div class="container mx-auto mt-[10vh]">
<h1 class="text-2xl font-bold mb-4">Warden Dashboard - <?php echo $hostelId ?></h1>
<div class="mb-4">
<p class="text-lg">Pending Applications: <span class="font-bold text-red-500"><?php echo $pendingCount; ?></span></p>
</div>
<?php if (!empty($rooms)) { ?>
<table class="w-full border-collapse border border-gray-400">
<thead>
<tr class="bg-gray-200">
<th class="p-2 border">Room Number</th>
<th class="p-2 border">Student 1</th>
<th class="p-2 border">Student 2</th>
<th class="p-2 border">Student 3</th>
</tr>
</thead>
<tbody>
<?php foreach ($rooms as $room) { ?>
<tr>
<td class="p-2 border"><?php echo $room['room_number']; ?></td>
<td class="p-2 border"><?php echo $room['student_1']; ?></td>
<td class="p-2 border"><?php echo $room['student_2']; ?></td>
<td class="p-2 border"><?php echo $room['student_3']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } else { ?>
<p>No rooms found in the hostel.</p>
<?php } ?>
<div class="container mx-auto mt-[10vh]">
<h1 class="text-2xl font-bold mb-4">Add Room</h1>
<form action="include/room_create_process.php" method="post">
<div class="mb-4">
<label for="room_number" class="block text-sm font-medium text-gray-600">Room Number</label>
<input type="text" name="room_number" id="room_number" class="p-2 border rounded">
</div>
<div class="mb-4">
<label for="capacity" class="block text-sm font-medium text-gray-600">Capacity</label>
<input type="number" name="capacity" id="capacity" class="p-2 border rounded">
</div>
<button type="submit" class="p-2 bg-blue-500 text-white rounded">Add Room</button>
</form>
</div>
</div>
</body>
</html>