-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
455 lines (411 loc) · 27.8 KB
/
admin.php
File metadata and controls
455 lines (411 loc) · 27.8 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<?php
session_start();
/* ================= DATABASE ================= */
$conn = mysqli_connect("localhost", "root", "", "socmacs_db");
if (!$conn) { die("Database Connection Failed"); }
/* ================= SECURITY ================= */
if (!isset($_SESSION['role']) || !in_array(strtolower($_SESSION['role']), ['admin','staff'])) {
header("Location: index.php?error=unauthorized");
exit();
}
/* ================= VARIABLES ================= */
$msg = "";
$active_tab = $_GET['tab'] ?? 'notices';
$edit_data = [
'id' => '', 'title' => '', 'category' => 'General',
'content' => '', 'start_date' => '', 'end_date' => '',
'target_course' => 'All', 'target_year' => 'All',
'file_path' => '', 'reminder_before' => 24
];
if (isset($_SESSION['flash_msg'])) {
$msg = $_SESSION['flash_msg'];
unset($_SESSION['flash_msg']);
}
/* ================= ACTIONS ================= */
/* APPROVE STAFF */
if (isset($_GET['approve_staff'])) {
$id = intval($_GET['approve_staff']);
mysqli_query($conn, "UPDATE staff SET is_approved=1 WHERE id=$id");
$_SESSION['flash_msg'] = "Faculty approved successfully.";
header("Location: admin.php?tab=users"); exit();
}
/* DELETE STAFF */
if (isset($_GET['delete_staff'])) {
$id = intval($_GET['delete_staff']);
mysqli_query($conn, "DELETE FROM staff WHERE id=$id AND role!='admin'");
$_SESSION['flash_msg'] = "Staff removed.";
header("Location: admin.php?tab=users"); exit();
}
/* DELETE STUDENT */
if (isset($_GET['delete_student'])) {
$id = intval($_GET['delete_student']);
mysqli_query($conn, "DELETE FROM students WHERE id=$id");
$_SESSION['flash_msg'] = "Student removed.";
header("Location: admin.php?tab=users"); exit();
}
/* DELETE NOTICE */
if (isset($_GET['delete_notice'])) {
$id = intval($_GET['delete_notice']);
mysqli_query($conn, "DELETE FROM notices WHERE id=$id");
$_SESSION['flash_msg'] = "Notice deleted.";
header("Location: admin.php?tab=notices"); exit();
}
/* SAVE / UPDATE NOTICE */
/* SAVE / UPDATE NOTICE */
if (isset($_POST['save_notice'])) {
$id = $_POST['n_id'];
$title = mysqli_real_escape_string($conn, $_POST['n_title']);
$content = mysqli_real_escape_string($conn, $_POST['n_content']);
$category = $_POST['n_category'];
$course = $_POST['target_course'];
$year = $_POST['target_year'];
$start = $_POST['n_start_date'];
$end = $_POST['n_end_date'];
$reminder_before = intval($_POST['reminder_before']);
// Validate Dates (Must not be in the past)
if (strtotime($start) < time() && !$id) {
$_SESSION['flash_msg'] = "Error: Start date cannot be in the past.";
header("Location: admin.php?tab=notices"); exit();
}
$file_dest = $_POST['existing_file'] ?? null;
if (!empty($_FILES['n_file']['name'])) {
if (!is_dir('uploads')) mkdir('uploads', 0777, true);
$filename = basename($_FILES['n_file']['name']);
$file_dest = "uploads/" . time() . "_" . $filename;
move_uploaded_file($_FILES['n_file']['tmp_name'], $file_dest);
}
if ($id) {
$sql = "UPDATE notices SET title='$title', category='$category', content='$content', target_course='$course', target_year='$year', start_date='$start', end_date='$end', reminder_before='$reminder_before', file_path='$file_dest' WHERE id=$id";
} else {
$sql = "INSERT INTO notices (title, category, content, target_course, target_year, start_date, end_date, reminder_before, file_path, reminder_sent) VALUES ('$title','$category','$content','$course','$year','$start','$end','$reminder_before','$file_dest', 0)";
}
if (mysqli_query($conn, $sql)) {
// --- NEW: IMMEDIATE EMAIL LOGIC ---
if (!$id) { // Only send immediate mail for NEW notices
require_once 'mail_helper.php';
// Fetch target students
$student_query = "SELECT email FROM students WHERE otp_verified=1";
if ($course != 'All') $student_query .= " AND course='$course'";
if ($year != 'All') $student_query .= " AND year='$year'";
$students_res = mysqli_query($conn, $student_query);
$subject = "New Notice: $title";
$email_body = "<h3>$title</h3><p>$content</p><p><b>Date:</b> $start</p>";
while ($s = mysqli_fetch_assoc($students_res)) {
sendMail($s['email'], $subject, $email_body);
}
}
$_SESSION['flash_msg'] = "Bulletin published and immediate emails sent.";
} else {
$_SESSION['flash_msg'] = "SQL Error: " . mysqli_error($conn);
}
header("Location: admin.php?tab=notices"); exit();
}
/* EDIT NOTICE */
if (isset($_GET['edit_notice'])) {
$id = intval($_GET['edit_notice']);
$res = mysqli_query($conn, "SELECT * FROM notices WHERE id=$id");
if ($row = mysqli_fetch_assoc($res)) $edit_data = $row;
}
if (isset($_POST['send_test_mail'])) {
require_once 'mail_helper.php';
$test_email = mysqli_real_escape_string($conn, $_POST['test_email']);
if (sendMail($test_email, "SOCMACS Test Mail", "Your mailer is working perfectly! Time: " . date('h:i A'))) {
$_SESSION['flash_msg'] = "Test email sent to $test_email";
} else {
$_SESSION['flash_msg'] = "Mail failed. Check your SMTP settings in mail_helper.php";
}
header("Location: admin.php?tab=notices"); exit();
}
/* DASHBOARD COUNTS */
$total_students = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) c FROM students"))['c'];
$total_staff = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) c FROM staff WHERE role='staff'"))['c'];
$pending_staff = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) c FROM staff WHERE is_approved=0"))['c'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Panel | SOCMACS Portal</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;800&display=swap" rel="stylesheet">
<style>body { font-family: 'Plus Jakarta Sans', sans-serif; }</style>
</head>
<body class="bg-slate-50 text-slate-900">
<nav class="bg-blue-950 text-white p-5 shadow-2xl sticky top-0 z-50">
<div class="container mx-auto flex justify-between items-center px-4">
<div class="flex items-center gap-4">
<div class="bg-white p-1.5 rounded-xl shadow-inner">
<img src="https://socmacs.edu.in/assist/logo/logo1.png" alt="SOCMACS Logo" class="h-10 w-auto object-contain">
</div>
<div class="h-8 w-[1px] bg-white/20 mx-2 hidden md:block"></div>
<h1 class="font-extrabold text-xl tracking-tight uppercase">SOCMACS Hub</h1>
</div>
<div class="flex items-center gap-8">
<span class="hidden md:block text-[10px] font-black uppercase text-blue-300 tracking-widest">
<i class="fas fa-user-shield mr-2"></i>Admin: <?php echo htmlspecialchars($_SESSION['user_name'] ?? 'Authorized'); ?>
</span>
<a href="logout.php" class="bg-red-500 hover:bg-red-600 px-6 py-2.5 rounded-xl text-[10px] font-black tracking-widest transition-all shadow-lg shadow-red-900/20 uppercase">
Logout
</a>
</div>
</div>
</nav>
<div class="bg-white border-b sticky top-[72px] z-40">
<div class="container mx-auto flex flex-wrap justify-between items-center px-4 md:px-10">
<div class="flex gap-10">
<a href="?tab=notices" class="py-5 border-b-4 font-black text-xs uppercase tracking-widest <?php echo $active_tab == 'notices' ? 'border-blue-600 text-blue-600' : 'border-transparent text-slate-400 hover:text-slate-600'; ?>">Bulletin Board</a>
<a href="?tab=users" class="py-5 border-b-4 font-black text-xs uppercase tracking-widest <?php echo $active_tab == 'users' ? 'border-blue-600 text-blue-600' : 'border-transparent text-slate-400 hover:text-slate-600'; ?>">Directory</a>
</div>
<div class="hidden lg:flex gap-4 py-3">
<div class="bg-slate-50 px-5 py-2 rounded-2xl border border-slate-100 text-center">
<p class="text-[9px] font-black text-slate-400 uppercase tracking-tighter leading-none">Students</p>
<p class="text-lg font-black text-blue-600"><?php echo $total_students; ?></p>
</div>
<div class="bg-slate-50 px-5 py-2 rounded-2xl border border-slate-100 text-center">
<p class="text-[9px] font-black text-slate-400 uppercase tracking-tighter leading-none">Faculty</p>
<p class="text-lg font-black text-slate-700"><?php echo $total_staff; ?></p>
</div>
<?php if($pending_staff > 0): ?>
<div class="bg-orange-50 px-5 py-2 rounded-2xl border border-orange-100 text-center animate-pulse">
<p class="text-[9px] font-black text-orange-400 uppercase tracking-tighter leading-none">Pending</p>
<p class="text-lg font-black text-orange-600"><?php echo $pending_staff; ?></p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<main class="container mx-auto p-4 md:p-10">
<?php if($msg): ?>
<div class="bg-white border-l-4 border-green-500 shadow-xl p-5 rounded-2xl mb-8 flex items-center justify-between">
<div class="flex items-center gap-4">
<div class="bg-green-100 p-2 rounded-full text-green-600"><i class="fas fa-check"></i></div>
<p class="text-sm font-bold text-slate-700"><?php echo $msg; ?></p>
</div>
<button onclick="this.parentElement.remove()" class="text-slate-300 hover:text-slate-500"><i class="fas fa-times"></i></button>
</div>
<?php endif; ?>
<?php if($active_tab == 'users'): ?>
<div class="space-y-10">
<div class="bg-white rounded-[32px] shadow-sm border border-slate-200 overflow-hidden">
<div class="bg-slate-50/50 px-8 py-6 border-b flex justify-between items-center">
<h3 class="font-black text-xs uppercase text-slate-500 tracking-widest">Faculty Management</h3>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="text-[10px] uppercase text-slate-400 bg-slate-50/30">
<th class="p-6 font-black">Identity Details</th>
<th class="p-6 font-black text-center">Portal Status</th>
<th class="p-6 font-black text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<?php
$staff = mysqli_query($conn, "SELECT * FROM staff WHERE role='staff' ORDER BY is_approved ASC");
while($u = mysqli_fetch_assoc($staff)):
?>
<tr class="hover:bg-slate-50/80 transition-all">
<td class="p-6">
<p class="font-extrabold text-slate-800 text-sm"><?php echo htmlspecialchars($u['name']); ?></p>
<p class="text-xs text-slate-400 font-medium"><?php echo htmlspecialchars($u['email']); ?></p>
</td>
<td class="p-6 text-center">
<?php if(($u['is_approved'] ?? 0) == 0): ?>
<span class="bg-orange-100 text-orange-600 text-[9px] font-black px-4 py-1.5 rounded-full uppercase">Pending Review</span>
<?php else: ?>
<span class="bg-green-100 text-green-600 text-[9px] font-black px-4 py-1.5 rounded-full uppercase">Access Granted</span>
<?php endif; ?>
</td>
<td class="p-6 text-right space-x-2">
<?php if(($u['is_approved'] ?? 0) == 0): ?>
<a href="?tab=users&approve_staff=<?php echo $u['id']; ?>" class="bg-blue-600 hover:bg-blue-700 text-white px-5 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all">Approve</a>
<?php endif; ?>
<a href="?tab=users&delete_staff=<?php echo $u['id']; ?>" onclick="return confirm('Delete this faculty account?')" class="inline-flex items-center justify-center w-9 h-9 bg-slate-100 text-slate-400 hover:bg-red-50 hover:text-red-500 rounded-xl transition-all"><i class="fas fa-trash-alt text-xs"></i></a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
<div class="bg-white rounded-[32px] shadow-sm border border-slate-200 overflow-hidden">
<div class="bg-slate-50/50 px-8 py-6 border-b flex justify-between items-center">
<h3 class="font-black text-xs uppercase text-slate-500 tracking-widest">Student Enrollment</h3>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left">
<thead>
<tr class="text-[10px] uppercase text-slate-400 bg-slate-50/30">
<th class="p-6 font-black">Full Name / Email</th>
<th class="p-6 font-black">Department</th>
<th class="p-6 font-black">Roll Number</th>
<th class="p-6 font-black text-right">Delete</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<?php
$students = mysqli_query($conn, "SELECT * FROM students ORDER BY course, roll_no");
while($s = mysqli_fetch_assoc($students)):
?>
<tr class="hover:bg-slate-50/80 transition-all">
<td class="p-6">
<p class="font-extrabold text-slate-800 text-sm"><?php echo htmlspecialchars($s['name']); ?></p>
<p class="text-xs text-slate-400 font-medium lowercase"><?php echo htmlspecialchars($s['email']); ?></p>
</td>
<td class="p-6">
<div class="flex items-center gap-2">
<span class="bg-blue-50 text-blue-700 px-2 py-1 rounded text-[10px] font-black uppercase"><?php echo htmlspecialchars($s['course'] ?? 'N/A'); ?></span>
<span class="text-[10px] font-bold text-slate-400"><?php echo htmlspecialchars($s['year'] ?? ''); ?></span>
</div>
</td>
<td class="p-6 font-mono text-xs font-black text-slate-600"><?php echo htmlspecialchars($s['roll_no'] ?? '-'); ?></td>
<td class="p-6 text-right">
<a href="?tab=users&delete_student=<?php echo $s['id']; ?>" onclick="return confirm('Remove student?')" class="inline-flex items-center justify-center w-9 h-9 bg-slate-100 text-slate-400 hover:bg-red-50 hover:text-red-500 rounded-xl transition-all"><i class="fas fa-user-minus text-xs"></i></a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php endif; ?>
<?php if($active_tab == 'notices'): ?>
<div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
<div class="lg:col-span-4">
<div class="bg-white p-8 rounded-[32px] shadow-sm border border-slate-200 sticky top-48">
<div class="flex items-center gap-3 mb-8">
<div class="w-10 h-10 bg-blue-50 text-blue-600 rounded-2xl flex items-center justify-center"><i class="fas fa-feather-alt"></i></div>
<h3 class="font-black text-sm uppercase text-slate-800 tracking-tighter"><?php echo $edit_data['id'] ? 'Edit Bulletin' : 'Compose Bulletin'; ?></h3>
</div>
<form method="POST" enctype="multipart/form-data" class="space-y-5">
<input type="hidden" name="n_id" value="<?php echo $edit_data['id']; ?>">
<input type="hidden" name="existing_file" value="<?php echo $edit_data['file_path']; ?>">
<div>
<label class="text-[10px] font-black uppercase text-slate-400 tracking-widest ml-1 mb-2 block">Bulletin Headline</label>
<input type="text" name="n_title" value="<?php echo htmlspecialchars($edit_data['title']); ?>" required class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-sm focus:border-blue-500 outline-none transition-all font-semibold" placeholder="Headline...">
</div>
<div>
<label class="text-[10px] font-black uppercase text-slate-400 tracking-widest ml-1 mb-2 block">Category</label>
<select name="n_category" class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-xs font-black appearance-none">
<option value="General" <?php echo ($edit_data['category'] == 'General') ? 'selected' : ''; ?>>General</option>
<option value="Event" <?php echo ($edit_data['category'] == 'Event') ? 'selected' : ''; ?>>Event</option>
<option value="Exam" <?php echo ($edit_data['category'] == 'Exam') ? 'selected' : ''; ?>>Exam</option>
</select>
</div>
<div>
<label class="text-[10px] font-black uppercase text-slate-400 tracking-widest ml-1 mb-2 block">Description</label>
<textarea name="n_content" rows="4" required class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-sm focus:border-blue-500 outline-none transition-all font-semibold"><?php echo htmlspecialchars($edit_data['content']); ?></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-[10px] font-black uppercase text-slate-400 block mb-2">Start Date</label>
<input type="datetime-local" name="n_start_date" id="n_start_date"
value="<?php echo !empty($edit_data['start_date']) ? date('Y-m-d\TH:i', strtotime($edit_data['start_date'])) : ''; ?>"
required class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-[10px] font-bold">
</div>
<div>
<label class="text-[10px] font-black uppercase text-slate-400 tracking-widest ml-1 mb-2 block">End Date</label>
<input type="datetime-local" name="n_end_date" value="<?php echo !empty($edit_data['end_date']) ? date('Y-m-d\TH:i', strtotime($edit_data['end_date'])) : ''; ?>" required class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-[10px] font-bold">
</div>
<script>
// Set minimum selectable date to "Now"
const now = new Date();
now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
const minDate = now.toISOString().slice(0, 16);
document.getElementById('n_start_date').setAttribute('min', minDate);
if(document.getElementsByName('n_end_date')[0]) {
document.getElementsByName('n_end_date')[0].setAttribute('min', minDate);
}
</script>
</div>
<div>
<label class="text-[10px] font-black uppercase text-slate-400">Reminder Time</label>
<select name="reminder_before"
class="w-full bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-xs font-black">
<option value="24">24 Hours Before</option>
<option value="12">12 Hours Before</option>
<option value="1">1 Hour Before</option>
</select>
</div>
<div class="grid grid-cols-2 gap-4">
<select name="target_course" class="bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-[10px] font-black">
<option value="All">All Courses</option>
<option value="BCA" <?php echo ($edit_data['target_course'] == 'BCA') ? 'selected' : ''; ?>>BCA</option>
<option value="BCS" <?php echo ($edit_data['target_course'] == 'BCS') ? 'selected' : ''; ?>>BCS</option>
</select>
<select name="target_year" class="bg-slate-50 border-2 border-slate-100 p-4 rounded-2xl text-[10px] font-black">
<option value="All">All Years</option>
<option value="FY" <?php echo ($edit_data['target_year'] == 'FY') ? 'selected' : ''; ?>>FY</option>
<option value="SY" <?php echo ($edit_data['target_year'] == 'SY') ? 'selected' : ''; ?>>SY</option>
<option value="TY" <?php echo ($edit_data['target_year'] == 'TY') ? 'selected' : ''; ?>>TY</option>
</select>
</div>
<div class="bg-blue-50/50 p-4 rounded-2xl border border-blue-100">
<label class="text-[10px] font-black uppercase text-blue-400 tracking-widest block mb-2">Upload File</label>
<input type="file" name="n_file" class="text-[10px] text-slate-500 file:bg-blue-600 file:text-white file:border-0 file:px-3 file:py-1 file:rounded-full">
</div>
<button type="submit" name="save_notice" class="w-full bg-blue-900 text-white font-black py-5 rounded-2xl shadow-xl hover:scale-[1.02] transition-all uppercase text-[10px] tracking-widest">
<?php echo $edit_data['id'] ? 'Update Bulletin' : 'Publish Bulletin'; ?>
</button>
</form>
<div class="mt-6 p-6 bg-slate-900 rounded-[2rem] border border-slate-800 shadow-xl">
<h4 class="text-[10px] font-black uppercase text-blue-400 mb-4 tracking-widest">System Check</h4>
<form method="POST" class="space-y-3">
<input type="email" name="test_email" required
placeholder="Enter test email..."
class="w-full bg-slate-800 border border-slate-700 p-3 rounded-xl text-xs text-white outline-none focus:border-blue-500">
<button type="submit" name="send_test_mail"
class="w-full bg-blue-600 hover:bg-blue-500 text-white font-black py-3 rounded-xl text-[10px] uppercase tracking-widest transition-all">
<i class="fas fa-paper-plane mr-2"></i> Send Test Mail
</button>
</form>
</div>
</div>
</div>
<div class="lg:col-span-8 space-y-6">
<?php
$notices = mysqli_query($conn, "SELECT * FROM notices ORDER BY created_at DESC");
if(mysqli_num_rows($notices) > 0):
while($n = mysqli_fetch_assoc($notices)):
?>
<div class="bg-white p-7 rounded-[32px] shadow-sm border border-slate-200 group hover:border-blue-300 transition-all">
<div class="flex flex-col md:flex-row justify-between gap-6">
<div class="flex-1">
<div class="flex items-center flex-wrap gap-2 mb-4">
<span class="text-[9px] font-black bg-blue-600 text-white px-3 py-1.5 rounded-full uppercase tracking-widest">Target: <?php echo htmlspecialchars($n['target_course'] ?? 'All'); ?></span>
<span class="text-[9px] font-black bg-amber-50 text-amber-600 px-3 py-1.5 rounded-full uppercase tracking-widest"><?php echo htmlspecialchars($n['category'] ?? 'General'); ?></span>
<span class="text-[9px] font-bold text-slate-400 ml-2 uppercase tracking-tighter">
<i class="far fa-calendar-alt mr-1"></i>
<?php echo date('d M', strtotime($n['start_date'])); ?> to <?php echo date('d M Y', strtotime($n['end_date'])); ?>
</span>
</div>
<h4 class="font-black text-slate-800 text-xl tracking-tight uppercase"><?php echo htmlspecialchars($n['title']); ?></h4>
<p class="text-sm text-slate-500 mt-3 font-medium leading-relaxed"><?php echo nl2br(htmlspecialchars($n['content'])); ?></p>
<?php if(!empty($n['file_path'])): ?>
<div class="mt-5">
<a href="<?php echo $n['file_path']; ?>" target="_blank" class="inline-flex items-center gap-2 bg-slate-50 text-slate-600 hover:bg-blue-50 px-5 py-2 rounded-xl text-[10px] font-black uppercase border border-slate-100 transition-all">
<i class="fas fa-paperclip"></i> View Attachment
</a>
</div>
<?php endif; ?>
</div>
<div class="flex md:flex-col gap-2 opacity-0 group-hover:opacity-100 transition-all justify-end">
<a href="?tab=notices&edit_notice=<?php echo $n['id']; ?>" class="w-11 h-11 bg-blue-50 text-blue-600 rounded-2xl flex items-center justify-center hover:bg-blue-600 hover:text-white transition-all"><i class="fas fa-edit"></i></a>
<a href="?tab=notices&delete_notice=<?php echo $n['id']; ?>" onclick="return confirm('Remove notice?')" class="w-11 h-11 bg-red-50 text-red-500 rounded-2xl flex items-center justify-center hover:bg-red-500 hover:text-white transition-all"><i class="fas fa-trash-alt"></i></a>
</div>
</div>
</div>
<?php endwhile; else: ?>
<div class="bg-white p-20 rounded-[32px] border-2 border-dashed border-slate-200 text-center">
<i class="fas fa-bullhorn text-slate-200 text-5xl mb-4"></i>
<p class="text-slate-400 font-bold uppercase tracking-widest text-sm">No Bulletins currently posted</p>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</main>
</body>
</html>