Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/conference/registrations/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/conference/registrations/index.php

<?php
require_once '../includes/functions.php';

// Check if user is logged in
if (!isLoggedIn()) {
    header('Location: ' . BASE_URL . 'login.php');
    exit();
}

$user = getCurrentUser();
if (!$user) {
    header('Location: ' . BASE_URL . 'login.php');
    exit();
}
$db = new CopMadinaDB();
$conn = $db->getConnection();

// Get registrations based on user role and permissions
$whereClause = "";
$params = [];

if (($user['role'] ?? '') === 'area_admin') {
    $whereClause = "WHERE e.area_id = ?";
    $params[] = $user['area_id'] ?? null;
} elseif (($user['role'] ?? '') === 'district_admin') {
    $whereClause = "WHERE e.district_id = ?";
    $params[] = $user['district_id'] ?? null;
} elseif (($user['role'] ?? '') === 'assembly_admin') {
    $whereClause = "WHERE e.assembly_id = ?";
    $params[] = $user['assembly_id'] ?? null;
} elseif (($user['role'] ?? '') === 'member') {
    $whereClause = "WHERE er.user_id = ?";
    $params[] = $user['id'] ?? null;
}

$sql = "SELECT er.*, e.title as event_title, e.start_date, e.location,
               u.first_name, u.last_name, u.email, u.phone,
               a.name as area_name, d.name as district_name, ass.name as assembly_name
        FROM event_registrations er
        JOIN events e ON er.event_id = e.id
        JOIN users u ON er.user_id = u.id
        LEFT JOIN areas a ON e.area_id = a.id
        LEFT JOIN districts d ON e.district_id = d.id
        LEFT JOIN assemblies ass ON e.assembly_id = ass.id
        $whereClause
        ORDER BY er.created_at DESC";

$stmt = executeQuery($sql, $params);
$registrations = $stmt ? $stmt->fetchAll() : [];

$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Registrations - COP Madina Conference Management</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: {
                            50: '#eff6ff',
                            100: '#dbeafe',
                            500: '#3b82f6',
                            600: '#2563eb',
                            700: '#1d4ed8',
                            800: '#1e40af',
                            900: '#1e3a8a'
                        }
                    }
                }
            }
        }
    </script>
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .sidebar-active {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div id="app" class="flex h-screen">
        <?php include '../includes/public_sidebar.php'; ?>
        
        <!-- Main Content -->
        <div class="flex-1 flex flex-col overflow-hidden">
            <div class="flex-1 overflow-y-auto">
    <!-- Header -->
    <header class="bg-white shadow-sm border-b border-gray-200">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between items-center h-16">
                <div class="flex items-center">
                    <a href="<?php echo BASE_URL; ?>" class="flex items-center">
                        <img src="<?php echo BASE_URL; ?>assets/images/logo.png" alt="COP Madina" class="h-10 w-10 rounded-full mr-3">
                        <div>
                            <h1 class="text-xl font-bold text-gray-900">Event Registrations</h1>
                            <p class="text-xs text-gray-500">Registration Management</p>
                        </div>
                    </a>
                </div>
                
                <nav class="flex items-center space-x-4">
                    <a href="<?php echo BASE_URL; ?>" class="text-gray-600 hover:text-gray-900 transition-colors">
                        <i class="fas fa-home mr-1"></i>Home
                    </a>
                    <a href="<?php echo BASE_URL; ?>dashboard.php" class="text-gray-600 hover:text-gray-900 transition-colors">
                        <i class="fas fa-tachometer-alt mr-1"></i>Dashboard
                    </a>
                    <div class="relative">
                        <span class="text-gray-700 font-medium">
                            <?php echo htmlspecialchars($user['first_name'] . ' ' . $user['last_name']); ?>
                        </span>
                    </div>
                    <a href="<?php echo BASE_URL; ?>logout.php" class="text-red-600 hover:text-red-800 transition-colors">
                        <i class="fas fa-sign-out-alt"></i>
                    </a>
                </nav>
            </div>
        </div>
    </header>

    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        <!-- Page Header -->
        <div class="mb-8">
            <h1 class="text-3xl font-bold text-gray-900">Event Registrations</h1>
            <p class="mt-2 text-gray-600">
                <?php echo $user['role'] === 'member' ? 'Your event registrations' : 'Manage event registrations'; ?>
            </p>
        </div>

        <!-- Registrations Table -->
        <div class="bg-white rounded-xl shadow-lg overflow-hidden">
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Event</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Registrant</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Amount</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Registered</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <?php foreach ($registrations as $reg): ?>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap">
                                <div>
                                    <div class="text-sm font-medium text-gray-900">
                                        <?php echo htmlspecialchars($reg['event_title']); ?>
                                    </div>
                                    <div class="text-sm text-gray-500">
                                        <i class="fas fa-calendar mr-1"></i>
                                        <?php echo date('M j, Y', strtotime($reg['start_date'])); ?>
                                    </div>
                                    <?php if ($reg['location']): ?>
                                    <div class="text-sm text-gray-500">
                                        <i class="fas fa-map-marker-alt mr-1"></i>
                                        <?php echo htmlspecialchars($reg['location']); ?>
                                    </div>
                                    <?php endif; ?>
                                </div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap">
                                <div class="flex items-center">
                                    <div class="flex-shrink-0 h-10 w-10">
                                        <div class="h-10 w-10 rounded-full bg-primary-100 flex items-center justify-center">
                                            <span class="text-primary-600 font-medium text-sm">
                                                <?php echo strtoupper(substr($reg['first_name'], 0, 1) . substr($reg['last_name'], 0, 1)); ?>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="ml-4">
                                        <div class="text-sm font-medium text-gray-900">
                                            <?php echo htmlspecialchars($reg['first_name'] . ' ' . $reg['last_name']); ?>
                                        </div>
                                        <div class="text-sm text-gray-500">
                                            <?php echo htmlspecialchars($reg['email']); ?>
                                        </div>
                                        <?php if ($reg['phone']): ?>
                                        <div class="text-sm text-gray-500">
                                            <?php echo htmlspecialchars($reg['phone']); ?>
                                        </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap">
                                <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full
                                    <?php 
                                    echo $reg['status'] === 'confirmed' ? 'bg-green-100 text-green-800' : 
                                        ($reg['status'] === 'pending' ? 'bg-yellow-100 text-yellow-800' : 
                                        ($reg['status'] === 'cancelled' ? 'bg-red-100 text-red-800' : 'bg-gray-100 text-gray-800'));
                                    ?>">
                                    <?php echo ucfirst($reg['status']); ?>
                                </span>
                                <?php if ($reg['payment_status']): ?>
                                <div class="mt-1">
                                    <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full
                                        <?php 
                                        echo $reg['payment_status'] === 'paid' ? 'bg-green-100 text-green-800' : 
                                            ($reg['payment_status'] === 'pending' ? 'bg-yellow-100 text-yellow-800' : 'bg-red-100 text-red-800');
                                        ?>">
                                        <?php echo ucfirst($reg['payment_status']); ?>
                                    </span>
                                </div>
                                <?php endif; ?>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                <?php if ($reg['amount_paid'] > 0): ?>
                                    GH₵<?php echo number_format($reg['amount_paid'], 2); ?>
                                <?php else: ?>
                                    Free
                                <?php endif; ?>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                <?php echo date('M j, Y g:i A', strtotime($reg['created_at'])); ?>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
        
        <?php if (empty($registrations)): ?>
        <div class="text-center py-12">
            <i class="fas fa-ticket-alt text-gray-400 text-6xl mb-4"></i>
            <h3 class="text-xl font-semibold text-gray-900 mb-2">No Registrations Found</h3>
            <p class="text-gray-600">
                <?php echo $user['role'] === 'member' ? 'You have not registered for any events yet.' : 'There are currently no registrations to display.'; ?>
            </p>
        </div>
        <?php endif; ?>
    </div>
</body>
</html>

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