Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/modules/notifications/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/modules/notifications/index.php

<?php
require_once '../../config/config.php';
checkLogin();

$pageTitle = "Notifications - " . APP_NAME;

$notification = new Notification();
$userId = $_SESSION['user_id'];

// Handle actions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['mark_all_read'])) {
        $notification->markAllAsRead($userId);
    } elseif (isset($_POST['delete_notification'])) {
        $notification->delete($_POST['notification_id'], $userId);
    }
}

$notifications = $notification->getUserNotifications($userId, false, 100);

include '../../includes/header.php';
?>

<?php include '../../includes/sidebar.php'; ?>

<!-- Main Content -->
<main class="flex-1 md:ml-64 mt-16">
<div class="container mx-auto px-4 py-8">
    <div class="max-w-4xl mx-auto">
        <div class="flex justify-between items-center mb-6">
            <div>
                <h1 class="text-3xl font-bold text-gray-800">
                    <i class="fas fa-bell mr-2 text-blue-500"></i>Notifications
                </h1>
                <p class="text-gray-600 mt-2">View and manage your notifications</p>
            </div>
            
            <?php if (!empty($notifications)): ?>
                <form method="POST" class="inline">
                    <button type="submit" name="mark_all_read" 
                            class="bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition">
                        <i class="fas fa-check-double mr-2"></i>Mark All as Read
                    </button>
                </form>
            <?php endif; ?>
        </div>
        
        <!-- Notifications List -->
        <div class="bg-white rounded-xl shadow-lg overflow-hidden">
            <?php if (empty($notifications)): ?>
                <div class="text-center py-16">
                    <i class="fas fa-bell-slash text-6xl text-gray-300 mb-4"></i>
                    <h3 class="text-xl font-semibold text-gray-600 mb-2">No Notifications</h3>
                    <p class="text-gray-500">You're all caught up!</p>
                </div>
            <?php else: ?>
                <div class="divide-y divide-gray-200">
                    <?php foreach ($notifications as $notif): ?>
                        <div class="p-6 hover:bg-gray-50 transition <?php echo !$notif['is_read'] ? 'bg-blue-50' : ''; ?>">
                            <div class="flex items-start">
                                <div class="flex-shrink-0">
                                    <div class="w-12 h-12 rounded-full bg-gradient-to-r from-blue-500 to-yellow-400 flex items-center justify-center">
                                        <i class="fas fa-<?php 
                                            echo $notif['notification_type'] === 'success' ? 'check-circle' :
                                                ($notif['notification_type'] === 'warning' ? 'exclamation-triangle' :
                                                ($notif['notification_type'] === 'error' ? 'times-circle' : 'info-circle'));
                                        ?> text-white text-xl"></i>
                                    </div>
                                </div>
                                
                                <div class="ml-4 flex-1">
                                    <div class="flex items-start justify-between">
                                        <div class="flex-1">
                                            <h4 class="text-lg font-semibold text-gray-800">
                                                <?php echo htmlspecialchars($notif['title']); ?>
                                                <?php if (!$notif['is_read']): ?>
                                                    <span class="ml-2 inline-block w-2 h-2 bg-blue-500 rounded-full"></span>
                                                <?php endif; ?>
                                            </h4>
                                            <p class="mt-1 text-gray-600"><?php echo htmlspecialchars($notif['message']); ?></p>
                                            <div class="mt-2 flex items-center space-x-4 text-sm text-gray-500">
                                                <span>
                                                    <i class="fas fa-clock mr-1"></i>
                                                    <?php echo timeAgo($notif['created_at']); ?>
                                                </span>
                                                <?php if ($notif['link']): ?>
                                                    <a href="<?php echo htmlspecialchars($notif['link']); ?>" 
                                                       class="text-blue-500 hover:text-blue-600">
                                                        <i class="fas fa-external-link-alt mr-1"></i>View Details
                                                    </a>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        
                                        <form method="POST" class="ml-4">
                                            <input type="hidden" name="notification_id" value="<?php echo $notif['id']; ?>">
                                            <button type="submit" name="delete_notification" 
                                                    class="text-gray-400 hover:text-red-600 transition">
                                                <i class="fas fa-trash"></i>
                                            </button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

</main>

<?php include '../../includes/footer.php'; ?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists