-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_view_registration.php
More file actions
209 lines (178 loc) · 4.75 KB
/
Copy pathadmin_view_registration.php
File metadata and controls
209 lines (178 loc) · 4.75 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
session_start();
require "config.php";
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'admin') {
die("Access denied");
}
$stmt = $pdo->query("
SELECT
r.id,
u.full_name,
u.reg_number,
c.code AS course_code,
c.title AS course_title,
s.subject_code,
s.subject_title,
r.created_at
FROM registrations r
JOIN users u ON r.user_id = u.id
JOIN courses c ON r.course_id = c.id
LEFT JOIN course_subjects s ON r.subject_id = s.id
ORDER BY r.created_at DESC
");
$registrations = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin • Course Registrations</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Arial, sans-serif;
background: #f4f6f9;
padding: 30px;
}
/* Card */
.card {
background: #ffffff;
border-radius: 12px;
padding: 24px;
box-shadow: 0 10px 25px rgba(0,0,0,.08);
max-width: 1600px;
margin: auto;
}
/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.header h2 {
margin: 0;
color: #1f2937;
}
/* Search */
.search {
padding: 10px 14px;
border-radius: 8px;
border: 1px solid #d1d5db;
width: 280px;
}
/* Table */
table {
width: 100%;
border-collapse: collapse;
}
thead {
background: #f1f5f9;
}
th {
padding: 12px;
font-size: 0.75rem;
text-transform: uppercase;
text-align: left;
color: #475569;
border-bottom: 1px solid #e5e7eb;
}
td {
padding: 12px;
font-size: 0.85rem;
border-bottom: 1px solid #e5e7eb;
color: #111827;
vertical-align: top;
}
tbody tr:hover {
background: #f9fafb;
}
/* Badge */
.badge {
display: inline-block;
padding: 4px 8px;
background: #e0e7ff;
color: #1e40af;
border-radius: 6px;
font-size: 0.75rem;
}
/* Empty state */
.empty {
text-align: center;
padding: 30px;
color: #6b7280;
font-style: italic;
}
.close-btn {
background: #2563eb;
color: #fff;
padding: 10px 14px;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
cursor: pointer;
}
</style>
</head>
<body>
<div class="card">
<div class="header">
<span class="close-btn" title="Close" onclick="window.location='student_dashboard.php'">×</span>
<h2>📘 Course Registrations</h2>
<input type="text" id="searchInput" class="search" placeholder="Search student, course, subject...">
</div>
<table id="regTable">
<thead>
<tr>
<th>Student Name</th>
<th>Reg Number</th>
<th>Course</th>
<th>Subject</th>
<th>Registered On</th>
</tr>
</thead>
<tbody>
<?php if (empty($registrations)): ?>
<tr>
<td colspan="5" class="empty">No registrations found.</td>
</tr>
<?php else: ?>
<?php foreach ($registrations as $r): ?>
<tr>
<td><?= htmlspecialchars($r['full_name']) ?></td>
<td><?= htmlspecialchars($r['reg_number'] ?? 'N/A') ?></td>
<td>
<strong><?= htmlspecialchars($r['course_code']) ?></strong><br>
<span style="color:#6b7280;font-size:0.8rem;">
<?= htmlspecialchars($r['course_title']) ?>
</span>
</td>
<td>
<?php if ($r['subject_code']): ?>
<span class="badge">
<?= htmlspecialchars($r['subject_code']) ?>
</span><br>
<span style="font-size:0.8rem;color:#475569;">
<?= htmlspecialchars($r['subject_title']) ?>
</span>
<?php else: ?>
<span style="color:#9ca3af;">N/A</span>
<?php endif; ?>
</td>
<td><?= date('M d, Y', strtotime($r['created_at'])) ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<script>
/* 🔍 Client-side search */
document.getElementById('searchInput').addEventListener('keyup', function () {
let value = this.value.toLowerCase();
document.querySelectorAll('#regTable tbody tr').forEach(row => {
row.style.display = row.innerText.toLowerCase().includes(value) ? '' : 'none';
});
});
</script>
</body>
</html>