-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications.php
More file actions
485 lines (452 loc) · 26.7 KB
/
notifications.php
File metadata and controls
485 lines (452 loc) · 26.7 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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<?php
session_start();
require_once 'db/config.php';
// Check if user is logged in
if (!isset($_SESSION['user_id']) && !isset($_SESSION['expert_id'])) {
header('Location: login_signup.php');
exit();
}
// Get user/expert ID and role
$userId = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null;
$expertId = isset($_SESSION['expert_id']) ? $_SESSION['expert_id'] : null;
$role = $_SESSION['role'] ?? 'user';
// Fetch notifications from database
$notifications = [];
if ($userId) {
// Fetch notifications for user (personal + global)
$sql = "SELECT * FROM notification
WHERE (is_personal = 0) OR (is_personal = 1 AND uid = ?)
ORDER BY created_at DESC LIMIT 20";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $userId);
} else {
// Fetch notifications for expert (personal + global)
$sql = "SELECT * FROM notification
WHERE (is_personal = 0) OR (is_personal = 1 AND eid = ?)
ORDER BY created_at DESC LIMIT 20";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $expertId);
}
if ($stmt) {
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// Determine notification icon and color based on type
$icon = '📢';
$bgColor = 'bg-blue-50 border-blue-200';
$iconColor = 'text-blue-600';
switch ($row['type']) {
case 'new_blog':
$icon = '📝';
$bgColor = 'bg-green-50 border-green-200';
$iconColor = 'text-green-600';
break;
case 'blog_like':
$icon = '❤️';
$bgColor = 'bg-red-50 border-red-200';
$iconColor = 'text-red-600';
break;
case 'blog_comment':
$icon = '💬';
$bgColor = 'bg-yellow-50 border-yellow-200';
$iconColor = 'text-yellow-600';
break;
case 'course_new_member':
$icon = '👥';
$bgColor = 'bg-indigo-50 border-indigo-200';
$iconColor = 'text-indigo-600';
break;
case 'course_feedback':
$icon = '⭐';
$bgColor = 'bg-purple-50 border-purple-200';
$iconColor = 'text-purple-600';
break;
case 'appointment_new':
$icon = '📅';
$bgColor = 'bg-cyan-50 border-cyan-200';
$iconColor = 'text-cyan-600';
break;
case 'appointment_accepted':
$icon = '✅';
$bgColor = 'bg-green-50 border-green-200';
$iconColor = 'text-green-600';
break;
case 'appointment_declined':
$icon = '❌';
$bgColor = 'bg-red-50 border-red-200';
$iconColor = 'text-red-600';
break;
}
$notifications[] = [
'id' => $row['nid'],
'type' => $row['type'],
'description' => $row['description'],
'created_at' => $row['created_at'],
'time_ago' => timeAgo($row['created_at']),
'icon' => $icon,
'bg_color' => $bgColor,
'icon_color' => $iconColor
];
}
$stmt->close();
}
// Helper function to calculate time ago
function timeAgo($datetime) {
$time = time() - strtotime($datetime);
if ($time < 60) return 'Just now';
if ($time < 3600) return floor($time/60) . ' minutes ago';
if ($time < 86400) return floor($time/3600) . ' hours ago';
if ($time < 2592000) return floor($time/86400) . ' days ago';
if ($time < 31104000) return floor($time/2592000) . ' months ago';
return floor($time/31104000) . ' years ago';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Notifications - Soullift</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: {
50: '#f0fdfc',
100: '#ccfbf1',
200: '#99f6e4',
300: '#5eead4',
400: '#2dd4bf',
500: '#14b8a6',
600: '#0d9488',
700: '#0f766e',
800: '#115e59',
900: '#134e4a',
},
secondary: {
50: '#fdf4ff',
100: '#fae8ff',
200: '#f5d0fe',
300: '#f0abfc',
400: '#e879f9',
500: '#dc4cff',
600: '#c026d3',
700: '#a21caf',
800: '#86198f',
900: '#701a75',
},
accent: {
50: '#fff7ed',
100: '#ffedd5',
200: '#fed7aa',
300: '#fdba74',
400: '#fb923c',
500: '#f97316',
600: '#ea580c',
700: '#c2410c',
800: '#9a3412',
900: '#7c2d12',
}
},
fontFamily: {
'heading': ['Poppins', 'sans-serif'],
'body': ['Inter', 'sans-serif'],
},
animation: {
'float': 'float 6s ease-in-out infinite',
'fade-in': 'fadeIn 0.5s ease-in',
'slide-up': 'slideUp 0.5s ease-out',
'bounce-in': 'bounceIn 0.5s ease-out',
}
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700;800&display=swap');
.glass-effect {
background: rgba(255, 255, 255, 0.25);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
.glass-card {
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-primary {
background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
}
.btn-secondary {
background: linear-gradient(135deg, #dc4cff 0%, #a21caf 100%);
}
.gradient-text {
background: linear-gradient(135deg, #14b8a6 0%, #dc4cff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-20px); }
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
function toggleMobileMenu() {
const menu = document.getElementById('mobile-menu');
menu.classList.toggle('hidden');
}
</style>
</head>
<body class="bg-gradient-to-br from-primary-50 via-white to-secondary-50 min-h-screen font-body">
<!-- Floating Background Elements -->
<div class="fixed inset-0 overflow-hidden pointer-events-none">
<div class="absolute top-20 left-10 w-32 h-32 bg-primary-200 rounded-full opacity-20 animate-float"></div>
<div class="absolute top-40 right-20 w-24 h-24 bg-secondary-300 rounded-full opacity-20 animate-float" style="animation-delay: 2s;"></div>
<div class="absolute bottom-40 left-1/4 w-20 h-20 bg-accent-200 rounded-full opacity-20 animate-float" style="animation-delay: 4s;"></div>
<div class="absolute bottom-20 right-1/3 w-28 h-28 bg-primary-300 rounded-full opacity-20 animate-float" style="animation-delay: 1s;"></div>
</div>
<!-- Navigation -->
<header class="glass-effect sticky top-0 z-50 border-b border-white/20">
<div class="container mx-auto px-6">
<nav class="flex justify-between items-center py-4">
<!-- Logo -->
<a href="Homepage.php" class="flex items-center space-x-3 group">
<div class="relative">
<img src="resources/soullift-logo.svg" alt="SoulLift Logo" class="h-10 w-auto group-hover:scale-105 transition-transform duration-300">
</div>
</a>
<!-- Desktop Navigation -->
<ul class="hidden lg:flex items-center space-x-8">
<li><a href="Homepage.php?page=home" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Home</a></li>
<li><a href="user_profile.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">My Profile</a></li>
<li><a href="blog.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Blog</a></li>
<?php
// choose appointments page based on role
$appointmentsPage = (isset($_SESSION['role']) && $_SESSION['role'] === 'expert') ? 'expert_appointments.php' : 'user_appointments.php';
?>
<?php if (isset($_SESSION['role']) && $_SESSION['role'] === 'user'): ?>
<li><a href="experts.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Experts</a></li>
<li><a href="courses.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Courses</a></li>
<li><a href="services.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Services</a></li>
<li><a href="<?php echo $appointmentsPage; ?>" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Appointments</a></li>
<?php elseif (isset($_SESSION['role']) && $_SESSION['role'] === 'expert'): ?>
<li><a href="courses.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Courses</a></li>
<li><a href="schedule.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Schedule</a></li>
<li><a href="<?php echo $appointmentsPage; ?>" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Appointments</a></li>
<?php else: ?>
<li><a href="courses.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">Courses</a></li>
<?php endif; ?>
<li><a href="about.php" class="text-gray-700 hover:text-primary-600 transition-colors font-medium px-4 py-2 rounded-xl hover:bg-white/50">About Us</a></li>
</ul>
<!-- Right side buttons -->
<div class="flex items-center space-x-4">
<!-- Notification Button -->
<a href="notifications.php" class="relative glass-effect text-primary-600 px-4 py-2 rounded-xl bg-primary-50/50 transition-all duration-300 group">
<i class="fas fa-bell mr-2 group-hover:animate-pulse"></i>
<span class="hidden sm:inline font-semibold">Notifications</span>
</a>
<?php if (isset($_SESSION['role'])): ?>
<a href="Homepage.php?logout=1" class="btn-secondary text-white px-6 py-2 rounded-xl font-semibold shadow-lg hover:shadow-xl transition-all duration-300">
<i class="fas fa-sign-out-alt mr-2"></i>
Log Out
</a>
<?php else: ?>
<a href="login_signup.php" class="btn-primary text-white px-6 py-2 rounded-xl font-semibold shadow-lg hover:shadow-xl transition-all duration-300">
<i class="fas fa-rocket mr-2"></i>
Get Started
</a>
<?php endif; ?>
</div>
<!-- Mobile Menu Button -->
<button class="lg:hidden text-gray-700 hover:text-primary-600 transition-colors p-2" onclick="toggleMobileMenu()">
<i class="fas fa-bars text-xl"></i>
</button>
</nav>
<!-- Mobile Navigation -->
<div id="mobile-menu" class="lg:hidden hidden pb-4">
<div class="glass-card rounded-2xl p-4 mt-4">
<ul class="space-y-2">
<li><a href="Homepage.php?page=home" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Home</a></li>
<li><a href="user_profile.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">My Profile</a></li>
<li><a href="blog.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Blog</a></li>
<?php if (isset($_SESSION['role']) && $_SESSION['role'] === 'user'): ?>
<li><a href="experts.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Experts</a></li>
<li><a href="courses.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Courses</a></li>
<li><a href="services.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Services</a></li>
<li><a href="<?php echo $appointmentsPage; ?>" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Appointments</a></li>
<?php elseif (isset($_SESSION['role']) && $_SESSION['role'] === 'expert'): ?>
<li><a href="courses.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Courses</a></li>
<li><a href="schedule.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Schedule</a></li>
<li><a href="<?php echo $appointmentsPage; ?>" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Appointments</a></li>
<?php else: ?>
<li><a href="courses.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">Courses</a></li>
<?php endif; ?>
<li><a href="about.php" class="block text-gray-700 hover:text-primary-600 transition-colors px-4 py-3 rounded-xl hover:bg-white/50">About Us</a></li>
</ul>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<div class="container mx-auto px-4 py-8 pt-24 relative z-10">
<!-- Page Header -->
<div class="glass-card rounded-2xl p-6 sm:p-8 mb-8 shadow-lg animate-fade-in">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl sm:text-4xl font-heading font-bold gradient-text mb-2">Notifications</h1>
<p class="text-slate-600 text-sm sm:text-base">Stay updated with your latest messages and updates</p>
</div>
<div class="hidden sm:block">
<div class="bg-gradient-to-br from-primary-100 to-secondary-100 p-4 rounded-xl">
<svg class="w-8 h-8 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-5 5v-5z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
</svg>
</div>
</div>
</div>
</div>
<!-- Notifications Section -->
<div class="glass-card rounded-2xl p-6 sm:p-8 shadow-lg animate-slide-up">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl sm:text-2xl font-heading font-semibold text-slate-800">Recent Notifications</h2>
<button class="btn-primary text-white px-4 py-2 rounded-lg hover:opacity-90 transition-all duration-300 transform hover:scale-105 text-sm font-medium">
<i class="fas fa-check-double mr-2"></i>Mark all as read
</button>
</div>
<div class="space-y-4">
<?php if (empty($notifications)): ?>
<div class="glass-card rounded-xl p-8 text-center border border-slate-200">
<div class="text-slate-400 mb-4">
<i class="fas fa-bell-slash text-4xl"></i>
</div>
<h3 class="text-lg font-heading font-semibold text-slate-600 mb-2">No Notifications Yet</h3>
<p class="text-slate-500">You're all caught up! Check back later for updates.</p>
</div>
<?php else: ?>
<?php foreach ($notifications as $notification): ?>
<div class="glass-card rounded-xl p-6 shadow-sm hover:shadow-lg transition-all duration-300 border border-slate-200 hover:border-primary-300 group">
<div class="flex items-start justify-between">
<div class="flex items-start space-x-4">
<div class="flex-shrink-0">
<div class="w-12 h-12 rounded-full bg-gradient-to-br from-primary-100 to-secondary-100 flex items-center justify-center shadow-sm group-hover:shadow-md transition-shadow">
<span class="text-lg"><?= $notification['icon'] ?></span>
</div>
</div>
<div class="flex-1 min-w-0">
<div class="mb-2">
<p class="text-slate-900 font-medium leading-relaxed">
<?= htmlspecialchars($notification['description']) ?>
</p>
</div>
<div class="flex items-center space-x-4 text-sm text-slate-500">
<span class="flex items-center">
<i class="fas fa-clock mr-1"></i>
<?= $notification['time_ago'] ?>
</span>
<span class="flex items-center">
<i class="fas fa-tag mr-1"></i>
<?= ucfirst(str_replace('_', ' ', $notification['type'])) ?>
</span>
</div>
</div>
</div>
<div class="flex-shrink-0 ml-4">
<div class="flex items-center space-x-2">
<span class="text-xs text-gray-400">
<?= date('M j, Y', strtotime($notification['created_at'])) ?>
</span>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-gray-900 text-white">
<div class="max-w-7xl mx-auto px-4 py-16">
<div class="grid md:grid-cols-4 gap-8">
<div class="space-y-6">
<div class="flex items-center space-x-3">
<img src="resources/soullift-logo.svg" alt="Soullift Logo" class="w-10 h-10">
<span class="text-2xl font-heading font-bold bg-gradient-to-r from-primary-400 to-secondary-400 bg-clip-text text-transparent">
Soullift
</span>
</div>
<p class="text-gray-400 leading-relaxed">
Providing compassionate mental health support and counseling services to help you live a more fulfilling life.
</p>
<div class="flex space-x-4">
<a href="#" class="w-10 h-10 bg-primary-600 rounded-full flex items-center justify-center hover:bg-primary-700 transition-colors">
<i class="fab fa-facebook text-white"></i>
</a>
<a href="#" class="w-10 h-10 bg-secondary-600 rounded-full flex items-center justify-center hover:bg-secondary-700 transition-colors">
<i class="fab fa-instagram text-white"></i>
</a>
<a href="#" class="w-10 h-10 bg-primary-600 rounded-full flex items-center justify-center hover:bg-primary-700 transition-colors">
<i class="fab fa-twitter text-white"></i>
</a>
<a href="#" class="w-10 h-10 bg-accent-600 rounded-full flex items-center justify-center hover:bg-accent-700 transition-colors">
<i class="fab fa-linkedin text-white"></i>
</a>
</div>
</div>
<div>
<h3 class="font-heading text-lg font-semibold mb-6 text-white">Quick Links</h3>
<ul class="space-y-3 text-gray-400">
<li><a href="Homepage.php" class="hover:text-primary-400 transition-colors">Home</a></li>
<li><a href="services.php" class="hover:text-primary-400 transition-colors">Services</a></li>
<li><a href="experts.php" class="hover:text-primary-400 transition-colors">Therapists</a></li>
<li><a href="courses.php" class="hover:text-primary-400 transition-colors">Resources</a></li>
<li><a href="blog.php" class="hover:text-primary-400 transition-colors">Blog</a></li>
</ul>
</div>
<div>
<h3 class="font-heading text-lg font-semibold mb-6 text-white">Support</h3>
<ul class="space-y-3 text-gray-400">
<li><a href="mailto:info@soullift.com" class="hover:text-primary-400 transition-colors">Email Support</a></li>
<li><a href="tel:+15551234567" class="hover:text-primary-400 transition-colors">Emergency Hotline</a></li>
<li><span class="text-gray-500">Crisis Support: 24/7</span></li>
<li><a href="#" class="hover:text-primary-400 transition-colors">FAQs</a></li>
</ul>
</div>
<div>
<h3 class="font-heading text-lg font-semibold mb-6 text-white">Newsletter</h3>
<p class="text-gray-400 mb-4">Subscribe for mental health tips and updates.</p>
<div class="space-y-3">
<input type="email" placeholder="Your email address" class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-400 focus:ring-2 focus:ring-primary-500 focus:border-transparent">
<button class="w-full bg-gradient-to-r from-primary-600 to-secondary-600 text-white py-3 rounded-lg font-semibold hover:shadow-lg transition-all duration-300 transform hover:scale-105">
Subscribe
</button>
</div>
</div>
</div>
<div class="border-t border-gray-800 mt-12 pt-8">
<div class="flex flex-col md:flex-row justify-between items-center space-y-4 md:space-y-0">
<p class="text-gray-400 text-center md:text-left">
© <?php echo date("Y"); ?> Soullift. All rights reserved. | Mental wellness for everyone
</p>
<div class="flex space-x-6 text-sm text-gray-400">
<a href="#" class="hover:text-primary-400 transition-colors">Privacy Policy</a>
<a href="#" class="hover:text-primary-400 transition-colors">Terms of Service</a>
<a href="#" class="hover:text-primary-400 transition-colors">Cookie Policy</a>
</div>
</div>
</div>
</div>
</footer>
</body>
</html>