Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/conference/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/conference/check-event.php

<?php
session_start();
require_once 'includes/functions.php';

$db = new CopMadinaDB();
$conn = $db->getConnection();

$error = '';
$registration = null;
$event = null;

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $registrationCode = sanitizeInput($_POST['registration_code'] ?? '');
    
    if (empty($registrationCode)) {
        $error = 'Please enter a registration code.';
    } else {
        // Check in member registrations first
        $stmt = $conn->prepare("
            SELECT er.*, e.title, e.description, e.start_date, e.end_date, e.venue, 
                   e.registration_fee, e.status as event_status,
                   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,
                   'member' as registration_type
            FROM event_registrations er
            JOIN events e ON er.event_id = e.id
            LEFT 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
            WHERE er.registration_code = ?
        ");
        $stmt->execute([$registrationCode]);
        $registration = $stmt->fetch();
        
        // If not found in member registrations, check non-member registrations
        if (!$registration) {
            $stmt = $conn->prepare("
                SELECT nr.*, e.title, e.description, e.start_date, e.end_date, e.venue, 
                       e.registration_fee, e.status as event_status,
                       nr.first_name, nr.last_name, nr.email, nr.phone,
                       a.name as area_name, d.name as district_name, ass.name as assembly_name,
                       'non_member' as registration_type
                FROM nonmember_registrations nr
                JOIN events e ON nr.event_id = e.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
                WHERE nr.registration_code = ?
            ");
            $stmt->execute([$registrationCode]);
            $registration = $stmt->fetch();
        }
        
        if (!$registration) {
            $error = 'Registration code not found. Please check your code and try again.';
        }
    }
}

$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Check Event Registration - COP Madina</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></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>
</head>
<body class="bg-gradient-to-br from-slate-50 to-blue-50 min-h-screen">
    <div id="app">
        <!-- Navigation -->
        <nav class="bg-gradient-to-r from-blue-500 via-slate-600 to-violet-400 shadow-lg border-b border-slate-200/50 sticky top-0 z-50">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <div class="flex justify-between items-center h-16">
                    <!-- Logo -->
                    <div class="flex items-center space-x-3">
                        <div class="p-2 rounded-xl bg-gradient-to-br from-blue-500 to-purple-600">
                            <i class="fas fa-church text-white text-xl"></i>
                        </div>
                        <div>
                            <h1 class="text-xl font-bold text-white drop-shadow-lg">
                                COP Madina
                            </h1>
                            <p class="text-xs text-white/80">Conference Platform</p>
                        </div>
                    </div>
                    
                    <!-- Navigation Links -->
                    <div class="flex items-center space-x-6">
                        <a href="<?php echo BASE_URL; ?>" class="text-white/90 hover:text-white font-medium transition-colors">
                            <i class="fas fa-home mr-2"></i>Home
                        </a>
                        <?php if (isset($_SESSION['user_id'])): ?>
                        <a href="<?php echo BASE_URL; ?>dashboard.php" class="text-white/90 hover:text-white font-medium transition-colors">
                            <i class="fas fa-tachometer-alt mr-2"></i>Dashboard
                        </a>
                        <?php else: ?>
                        <a href="<?php echo BASE_URL; ?>login.php" class="px-4 py-2 bg-white/20 backdrop-blur-sm hover:bg-white/30 text-white font-medium rounded-lg transition-all duration-200 border border-white/30 hover:border-white/50">
                            <i class="fas fa-sign-in-alt mr-2"></i>Login
                        </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </nav>

        <!-- Main Content -->
        <main class="container mx-auto px-4 py-8">
            <div class="max-w-4xl mx-auto">
                <!-- Page Header -->
                <div class="text-center mb-8">
                    <h1 class="text-4xl font-bold text-slate-800 mb-4">Check Event Registration</h1>
                    <p class="text-lg text-slate-600">Enter your registration code to view your event details and registration status</p>
                </div>

                <!-- Search Form -->
                <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                    <form method="POST" class="max-w-md mx-auto">
                        <div class="mb-6">
                            <label for="registration_code" class="block text-sm font-medium text-slate-700 mb-2">
                                Registration Code
                            </label>
                            <div class="relative">
                                <input type="text" 
                                       id="registration_code" 
                                       name="registration_code" 
                                       required
                                       placeholder="Enter your 8-character code"
                                       class="w-full px-4 py-3 pl-12 border border-slate-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
                                       value="<?php echo htmlspecialchars($_POST['registration_code'] ?? ''); ?>">
                                <i class="fas fa-search absolute left-4 top-1/2 transform -translate-y-1/2 text-slate-400"></i>
                            </div>
                            <p class="text-sm text-slate-500 mt-2">
                                This is the 8-character code you received when you registered for an event.
                            </p>
                        </div>
                        
                        <button type="submit" 
                                class="w-full bg-gradient-to-r from-blue-500 via-slate-600 to-violet-400 text-white py-3 px-6 rounded-lg hover:opacity-90 transition-opacity font-medium text-lg">
                            <i class="fas fa-search mr-2"></i>Check Registration
                        </button>
                    </form>
                </div>

                <!-- Error Message -->
                <?php if ($error): ?>
                <div class="bg-red-50 border border-red-200 text-red-700 px-6 py-4 rounded-lg mb-8">
                    <div class="flex items-center">
                        <i class="fas fa-exclamation-circle mr-2"></i>
                        <?php echo htmlspecialchars($error); ?>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Registration Details -->
                <?php if ($registration): ?>
                <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                    <!-- Event Header -->
                    <div class="bg-gradient-to-r from-blue-500 via-slate-600 to-violet-400 text-white p-6">
                        <div class="flex items-center justify-between">
                            <div>
                                <h2 class="text-2xl font-bold mb-2"><?php echo htmlspecialchars($registration['title']); ?></h2>
                                <div class="flex items-center space-x-4 text-sm opacity-90">
                                    <span><i class="fas fa-calendar mr-1"></i><?php echo formatDate($registration['start_date'], 'M d, Y g:i A'); ?></span>
                                    <?php if ($registration['venue']): ?>
                                    <span><i class="fas fa-map-marker-alt mr-1"></i><?php echo htmlspecialchars($registration['venue']); ?></span>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <div class="text-right">
                                <div class="bg-white/20 backdrop-blur-sm rounded-lg px-4 py-2">
                                    <div class="text-sm opacity-90">Registration Code</div>
                                    <div class="text-xl font-bold"><?php echo htmlspecialchars($registration['registration_code']); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Registration Details -->
                    <div class="p-6">
                        <div class="grid md:grid-cols-2 gap-8">
                            <!-- Personal Information -->
                            <div>
                                <h3 class="text-lg font-semibold text-slate-800 mb-4">Personal Information</h3>
                                <div class="space-y-3">
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Name:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['first_name'] . ' ' . $registration['last_name']); ?></span>
                                    </div>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Email:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['email']); ?></span>
                                    </div>
                                    <?php if ($registration['phone']): ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Phone:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['phone']); ?></span>
                                    </div>
                                    <?php endif; ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Registration Type:</span>
                                        <span class="font-medium capitalize"><?php echo $registration['registration_type'] === 'member' ? 'Member' : 'Non-Member'; ?></span>
                                    </div>
                                </div>
                            </div>

                            <!-- Event Information -->
                            <div>
                                <h3 class="text-lg font-semibold text-slate-800 mb-4">Event Information</h3>
                                <div class="space-y-3">
                                    <?php if ($registration['area_name']): ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Area:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['area_name']); ?></span>
                                    </div>
                                    <?php endif; ?>
                                    <?php if ($registration['district_name']): ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">District:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['district_name']); ?></span>
                                    </div>
                                    <?php endif; ?>
                                    <?php if ($registration['assembly_name']): ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Assembly:</span>
                                        <span class="font-medium"><?php echo htmlspecialchars($registration['assembly_name']); ?></span>
                                    </div>
                                    <?php endif; ?>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Registration Fee:</span>
                                        <span class="font-medium"><?php echo $registration['registration_fee'] > 0 ? formatCurrency($registration['registration_fee']) : 'Free'; ?></span>
                                    </div>
                                    <div class="flex justify-between">
                                        <span class="text-slate-600">Amount Paid:</span>
                                        <span class="font-medium"><?php echo formatCurrency($registration['amount_paid'] ?? 0); ?></span>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Event Description -->
                        <?php if ($registration['description']): ?>
                        <div class="mt-8 pt-6 border-t border-slate-200">
                            <h3 class="text-lg font-semibold text-slate-800 mb-3">Event Description</h3>
                            <p class="text-slate-600 leading-relaxed"><?php echo htmlspecialchars($registration['description']); ?></p>
                        </div>
                        <?php endif; ?>

                        <!-- Additional Form Data -->
                        <?php if (!empty($registration['form_data'])): ?>
                        <?php $formData = json_decode($registration['form_data'], true); ?>
                        <?php if (!empty($formData)): ?>
                        <div class="mt-8 pt-6 border-t border-slate-200">
                            <h3 class="text-lg font-semibold text-slate-800 mb-4">Additional Information</h3>
                            <div class="grid md:grid-cols-2 gap-4">
                                <?php foreach ($formData as $key => $value): ?>
                                <div class="flex justify-between">
                                    <span class="text-slate-600 capitalize"><?php echo htmlspecialchars(str_replace('_', ' ', $key)); ?>:</span>
                                    <span class="font-medium"><?php echo htmlspecialchars($value); ?></span>
                                </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                        <?php endif; ?>

                        <!-- Status and Actions -->
                        <div class="mt-8 pt-6 border-t border-slate-200">
                            <div class="flex items-center justify-between">
                                <div>
                                    <span class="text-slate-600">Event Status:</span>
                                    <span class="ml-2 px-3 py-1 rounded-full text-sm font-medium <?php echo $registration['event_status'] === 'active' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800'; ?>">
                                        <?php echo ucfirst($registration['event_status']); ?>
                                    </span>
                                </div>
                                <div class="space-x-4">
                                    <a href="<?php echo BASE_URL; ?>event.php?id=<?php echo $registration['event_id']; ?>" 
                                       class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors">
                                        <i class="fas fa-eye mr-2"></i>View Event
                                    </a>
                                    <?php if (isset($_SESSION['user_id'])): ?>
                                    <a href="<?php echo BASE_URL; ?>dashboard.php" 
                                       class="bg-slate-600 text-white px-4 py-2 rounded-lg hover:bg-slate-700 transition-colors">
                                        <i class="fas fa-tachometer-alt mr-2"></i>Dashboard
                                    </a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
            </div>
        </main>
    </div>

    <script>
        const { createApp } = Vue;
        
        createApp({
            data() {
                return {
                    // Vue data properties
                }
            }
        }).mount('#app');
    </script>
</body>
</html>

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