-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_notice_read.php
More file actions
211 lines (177 loc) · 4.28 KB
/
Copy pathadmin_notice_read.php
File metadata and controls
211 lines (177 loc) · 4.28 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
210
211
<?php
session_start();
require "config.php";
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'admin') {
die("Access denied");
}
$stmt = $pdo->query("
SELECT
nr.id,
u.full_name,
u.reg_number,
n.title AS notice_title,
nr.read_at
FROM notice_reads nr
JOIN users u ON nr.user_id = u.id
JOIN notices n ON nr.notice_id = n.id
ORDER BY nr.read_at DESC
");
$noticeReads = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin • Notice Read Logs</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Arial, sans-serif;
background: #f4f6f9;
padding: 30px;
}
/* Card */
.card {
background: #fff;
border-radius: 14px;
padding: 24px;
box-shadow: 0 12px 30px rgba(0,0,0,.08);
max-width: 1400px;
margin: auto;
}
/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.header h2 {
margin: 0;
color: #1f2937;
font-size: 1.4rem;
}
/* Search */
.search {
padding: 10px 14px;
border-radius: 8px;
border: 1px solid #d1d5db;
width: 300px;
font-size: 0.9rem;
}
/* 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: 14px 12px;
font-size: 0.85rem;
border-bottom: 1px solid #e5e7eb;
color: #111827;
}
tbody tr:hover {
background: #f9fafb;
}
/* Badges */
.badge {
display: inline-block;
padding: 6px 12px;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 600;
}
.badge.read {
background: #dcfce7;
color: #166534;
}
/* Empty */
.empty {
text-align: center;
padding: 40px;
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>📖 Notice Read Logs</h2>
<input
type="text"
id="searchInput"
class="search"
placeholder="Search student or notice..."
>
</div>
<table id="noticeTable">
<thead>
<tr>
<th>Student Name</th>
<th>Reg Number</th>
<th>Notice Title</th>
<th>Status</th>
<th>Read At</th>
</tr>
</thead>
<tbody>
<?php if (empty($noticeReads)): ?>
<tr>
<td colspan="5" class="empty">
No notice read records found.
</td>
</tr>
<?php else: ?>
<?php foreach ($noticeReads as $n): ?>
<tr>
<td><?= htmlspecialchars($n['full_name']) ?></td>
<td><?= htmlspecialchars($n['reg_number'] ?? 'N/A') ?></td>
<td>
<strong><?= htmlspecialchars($n['notice_title']) ?></strong>
</td>
<td>
<span class="badge read">Read</span>
</td>
<td>
<?= $n['read_at']
? date('M d, Y • H:i', strtotime($n['read_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('#noticeTable tbody tr').forEach(row => {
row.style.display = row.innerText.toLowerCase().includes(value) ? '' : 'none';
});
});
</script>
</body>
</html>