Sindbad~EG File Manager

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

<?php
require_once 'config/config.php';
require_once 'classes/EventManager.php';
require_once 'classes/MemberAuth.php';

$pageTitle = "Conference & Events - " . APP_NAME;
$db = Database::getInstance()->getConnection();
$eventManager = new EventManager();
$success = '';
$error = '';

// Handle event registration
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['register_event'])) {
    try {
        $eventId = $_POST['event_id'];
        $registrationData = [
            'first_name' => $_POST['first_name'],
            'last_name' => $_POST['last_name'],
            'email' => $_POST['email'],
            'phone' => $_POST['phone'] ?? ''
        ];
        
        $result = $eventManager->registerForEvent($eventId, $registrationData);
        
        if ($result['success']) {
            $success = "Registration successful! Your tracking code is: <strong>" . $result['tracking_code'] . "</strong>";
            
            // Send confirmation email
            $event = $eventManager->getEventById($eventId);
            $registrationData['tracking_code'] = $result['tracking_code'];
            $registrationData['registration_type'] = 'guest';
            $eventManager->sendRegistrationEmail($registrationData, $event);
        } else {
            $error = $result['message'];
        }
        
    } catch (Exception $e) {
        $error = "Registration failed: " . $e->getMessage();
    }
}

// Debug: Check if events table exists and has data
$featuredEvent = null;
$upcomingEvents = [];
$debugInfo = [];

try {
    // Check if events table exists
    $tableExists = false;
    try {
        $db->query("SELECT 1 FROM events LIMIT 1");
        $tableExists = true;
    } catch (Exception $e) {
        $debugInfo[] = "Events table does not exist: " . $e->getMessage();
    }
    
    if ($tableExists) {
        $debugQuery = $db->query("SHOW COLUMNS FROM events");
        $columns = $debugQuery->fetchAll();
        $hasPublicRegistration = false;
        $hasFeatured = false;
        
        foreach ($columns as $column) {
            if ($column['Field'] === 'public_registration') $hasPublicRegistration = true;
            if ($column['Field'] === 'featured') $hasFeatured = true;
        }
        
        $debugInfo[] = "Events table exists with " . count($columns) . " columns";
        $debugInfo[] = "Has public_registration: " . ($hasPublicRegistration ? 'Yes' : 'No');
        $debugInfo[] = "Has featured: " . ($hasFeatured ? 'Yes' : 'No');
        
        // Count total events
        $totalEvents = $db->query("SELECT COUNT(*) as count FROM events")->fetch()['count'];
        $debugInfo[] = "Total events: " . $totalEvents;
        
        if ($totalEvents > 0) {
            // Get featured event (with fallback for missing columns)
            $featuredQuery = "SELECT * FROM events WHERE 1=1";
            $params = [];
            
            // Add conditions based on available columns
            $conditions = [];
            if (in_array('is_active', array_column($columns, 'Field'))) {
                $conditions[] = "is_active = 1";
            }
            if (in_array('start_date', array_column($columns, 'Field'))) {
                $conditions[] = "start_date >= NOW()";
            }
            if ($hasPublicRegistration) {
                $conditions[] = "public_registration = 1";
            }
            
            if (!empty($conditions)) {
                $featuredQuery .= " AND " . implode(" AND ", $conditions);
            }
            
            $featuredQuery .= " ORDER BY ";
            if ($hasFeatured) {
                $featuredQuery .= "CASE WHEN featured = 1 THEN 0 ELSE 1 END, ";
            }
            if (in_array('start_date', array_column($columns, 'Field'))) {
                $featuredQuery .= "start_date ASC ";
            } else {
                $featuredQuery .= "id ASC ";
            }
            $featuredQuery .= "LIMIT 1";
            
            $debugInfo[] = "Featured query: " . $featuredQuery;
            $featuredEvent = $db->query($featuredQuery)->fetch();
            
            if ($featuredEvent) {
                $debugInfo[] = "Featured event found: " . $featuredEvent['name'];
                
                // Get other upcoming events
                $upcomingQuery = "SELECT * FROM events WHERE 1=1";
                if (!empty($conditions)) {
                    $upcomingQuery .= " AND " . implode(" AND ", $conditions);
                }
                $upcomingQuery .= " AND id != " . $featuredEvent['id'];
                $upcomingQuery .= " ORDER BY ";
                if (in_array('start_date', array_column($columns, 'Field'))) {
                    $upcomingQuery .= "start_date ASC ";
                } else {
                    $upcomingQuery .= "id ASC ";
                }
                $upcomingQuery .= "LIMIT 8";
                
                $upcomingEvents = $db->query($upcomingQuery)->fetchAll();
                $debugInfo[] = "Found " . count($upcomingEvents) . " other events";
            } else {
                $debugInfo[] = "No featured event found with current criteria";
                
                // Try simpler query
                $simpleQuery = "SELECT * FROM events ORDER BY id ASC LIMIT 1";
                $featuredEvent = $db->query($simpleQuery)->fetch();
                if ($featuredEvent) {
                    $debugInfo[] = "Found event with simple query: " . $featuredEvent['name'];
                }
            }
        } else {
            $debugInfo[] = "No events in database";
        }
    }
    
} catch (Exception $e) {
    $debugInfo[] = "Error: " . $e->getMessage();
    // Last resort: create a dummy event for testing
    $featuredEvent = [
        'id' => 1,
        'name' => 'Sample Event',
        'description' => 'This is a sample event for testing purposes.',
        'start_date' => date('Y-m-d H:i:s', strtotime('+7 days')),
        'end_date' => date('Y-m-d H:i:s', strtotime('+7 days')),
        'location_type' => 'assembly',
        'event_type' => 'conference',
        'registration_fee' => 0,
        'featured' => 1
    ];
    $debugInfo[] = "Using dummy event data";
}

// Get settings for theme colors
$stmt = $db->query("SELECT * FROM general_settings ORDER BY id DESC LIMIT 1");
$settings = $stmt->fetch();
$settings = array_merge([
    'site_title' => APP_NAME,
    'theme_primary_color' => '#3B82F6',
    'theme_secondary_color' => '#10B981'
], $settings ?: []);

// Check if user is logged in (admin or member)
$isLoggedIn = isLoggedIn() || MemberAuth::isMemberLoggedIn();
$currentUser = null;
if (MemberAuth::isMemberLoggedIn()) {
    $currentUser = MemberAuth::getCurrentMember();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $pageTitle; ?></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">
    <style>
        .hero-gradient {
            background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);
        }
        .text-gradient {
            background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        .event-card {
            transition: all 0.3s ease;
        }
        .event-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.15);
        }
        
        .line-clamp-2 {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .events-slider {
            width: 100%;
        }
        
        #eventsSlider {
            width: calc(100% * <?php echo count($upcomingEvents); ?> / 4);
        }
        
        @media (max-width: 1279px) {
            #eventsSlider {
                width: calc(100% * <?php echo count($upcomingEvents); ?> / 3);
            }
        }
        
        @media (max-width: 1023px) {
            #eventsSlider {
                width: calc(100% * <?php echo count($upcomingEvents); ?> / 2);
            }
        }
        
        @media (max-width: 767px) {
            #eventsSlider {
                width: calc(100% * <?php echo count($upcomingEvents); ?>);
            }
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Header -->
    <header class="bg-white shadow-lg sticky top-0 z-50">
        <div class="container mx-auto px-4">
            <div class="flex items-center justify-between h-16">
                <!-- Logo and Title -->
                <div class="flex items-center space-x-3">
                    <div class="w-12 h-12 rounded-xl flex items-center justify-center" style="background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);">
                        <i class="fas fa-church text-white text-xl"></i>
                    </div>
                    <div>
                        <h1 class="text-xl font-bold text-gradient"><?php echo htmlspecialchars($settings['site_title']); ?></h1>
                    </div>
                </div>
                
                <!-- Navigation -->
                <nav class="hidden md:flex items-center space-x-6">
                    <a href="<?php echo BASE_URL; ?>index.php" class="text-gray-700 hover:text-blue-700 font-medium transition">
                        <i class="fas fa-home mr-1"></i>Home
                    </a>
                    <a href="<?php echo BASE_URL; ?>public-search.php" class="text-gray-700 hover:text-orange-600 font-medium transition">
                        <i class="fas fa-search mr-1"></i>Search
                    </a>
                    <a href="<?php echo BASE_URL; ?>event-checkin.php" class="text-gray-700 hover:text-green-600 font-medium transition">
                        <i class="fas fa-qrcode mr-1"></i>Event Check-in
                    </a>
                    <a href="check-status.php" class="text-gray-700 hover:text-purple-600 font-medium transition">
                        <i class="fas fa-check-circle mr-1"></i>Check Status
                    </a>
                    
                    <?php if ($isLoggedIn): ?>
                        <?php if (MemberAuth::isMemberLoggedIn()): ?>
                            <a href="members/dashboard.php" class="px-6 py-2 rounded-full text-white font-semibold transition hover:shadow-lg" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);">
                                <i class="fas fa-user mr-1"></i>My Portal
                            </a>
                        <?php else: ?>
                            <a href="dashboard.php" class="px-6 py-2 rounded-full text-white font-semibold transition hover:shadow-lg" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);">
                                <i class="fas fa-tachometer-alt mr-1"></i>Dashboard
                            </a>
                        <?php endif; ?>
                        <a href="logout.php<?php echo MemberAuth::isMemberLoggedIn() ? '?member=1' : ''; ?>" class="text-gray-700 hover:text-red-600 font-medium transition">
                            <i class="fas fa-sign-out-alt mr-1"></i>Logout
                        </a>
                    <?php else: ?>
                        <a href="login.php" class="px-6 py-2 rounded-full text-white font-semibold transition hover:shadow-lg" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);">
                            <i class="fas fa-sign-in-alt mr-1"></i>Login
                        </a>
                    <?php endif; ?>
                </nav>
                
                <!-- Mobile Menu Button -->
                <button class="md:hidden text-gray-600" onclick="toggleMobileMenu()">
                    <i class="fas fa-bars text-xl"></i>
                </button>
            </div>
            
            <!-- Mobile Menu -->
            <div id="mobileMenu" class="md:hidden hidden border-t border-gray-200 py-4">
                <div class="flex flex-col space-y-3">
                    <a href="<?php echo BASE_URL; ?>index.php" class="text-gray-700 hover:text-blue-700 font-medium">
                        <i class="fas fa-home mr-1"></i>Home
                    </a>
                    <a href="<?php echo BASE_URL; ?>public-search.php" class="text-gray-700 hover:text-orange-600 font-medium">
                        <i class="fas fa-search mr-1"></i>Search
                    </a>
                    <a href="<?php echo BASE_URL; ?>event-checkin.php" class="text-gray-700 hover:text-green-600 font-medium">
                        <i class="fas fa-qrcode mr-1"></i>Event Check-in
                    </a>
                    <a href="check-status.php" class="text-gray-700 hover:text-purple-600 font-medium">
                        <i class="fas fa-check-circle mr-1"></i>Check Status
                    </a>
                    <hr class="border-gray-200">
                    <?php if ($isLoggedIn): ?>
                        <?php if (MemberAuth::isMemberLoggedIn()): ?>
                            <a href="members/dashboard.php" class="text-blue-700 font-medium">
                                <i class="fas fa-tachometer-alt mr-1"></i>My Portal
                            </a>
                        <?php else: ?>
                            <a href="dashboard.php" class="text-blue-700 font-medium">
                                <i class="fas fa-tachometer-alt mr-1"></i>Dashboard
                            </a>
                        <?php endif; ?>
                        <a href="logout.php<?php echo MemberAuth::isMemberLoggedIn() ? '?member=1' : ''; ?>" class="text-red-600 font-medium">
                            <i class="fas fa-sign-out-alt mr-1"></i>Logout
                        </a>
                    <?php else: ?>
                        <a href="login.php" class="text-blue-700 font-medium">
                            <i class="fas fa-sign-in-alt mr-1"></i>Login
                        </a>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </header>

    <!-- Messages -->
    <?php if ($success): ?>
        <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 mx-4 mt-4 rounded-lg">
            <i class="fas fa-check-circle mr-2"></i><?php echo $success; ?>
        </div>
    <?php endif; ?>
    
    <?php if ($error): ?>
        <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 mx-4 mt-4 rounded-lg">
            <i class="fas fa-exclamation-circle mr-2"></i><?php echo $error; ?>
        </div>
    <?php endif; ?>

    <!-- Featured Event Section -->
    <?php if ($featuredEvent): ?>
        <section class="hero-gradient text-white py-20">
            <div class="container mx-auto px-4">
                <div class="max-w-4xl mx-auto text-center">
                    <h1 class="text-5xl font-bold mb-6">Featured Event</h1>
                    <div class="bg-white bg-opacity-10 backdrop-blur-sm rounded-2xl p-8">
                        <?php if ($featuredEvent['image_url']): ?>
                            <img src="<?php echo htmlspecialchars($featuredEvent['image_url']); ?>" 
                                 alt="<?php echo htmlspecialchars($featuredEvent['name']); ?>"
                                 class="w-full h-64 object-cover rounded-lg mb-6">
                        <?php endif; ?>
                        
                        <h2 class="text-3xl font-bold mb-4"><?php echo htmlspecialchars($featuredEvent['name']); ?></h2>
                        <p class="text-xl mb-6 opacity-90"><?php echo htmlspecialchars($featuredEvent['description']); ?></p>
                        
                        <div class="flex flex-wrap justify-center items-center gap-6 mb-8 text-lg">
                            <div class="flex items-center">
                                <i class="fas fa-calendar mr-2"></i>
                                <?php echo date('F j, Y', strtotime($featuredEvent['start_date'])); ?>
                            </div>
                            <div class="flex items-center">
                                <i class="fas fa-clock mr-2"></i>
                                <?php echo date('g:i A', strtotime($featuredEvent['start_date'])); ?>
                            </div>
                            <div class="flex items-center">
                                <i class="fas fa-map-marker-alt mr-2"></i>
                                <?php echo ucfirst($featuredEvent['location_type']); ?>
                            </div>
                        </div>
                        
                        <button onclick="openRegistrationModal(<?php echo $featuredEvent['id']; ?>, '<?php echo htmlspecialchars($featuredEvent['name']); ?>')" 
                                class="bg-white text-primary px-8 py-4 rounded-full text-lg font-semibold hover:bg-gray-100 transition transform hover:scale-105">
                            <i class="fas fa-user-plus mr-2"></i>Register Now
                        </button>
                    </div>
                </div>
            </div>
        </section>
    <?php else: ?>
        <!-- No Events Available -->
        <section class="hero-gradient text-white py-20">
            <div class="container mx-auto px-4">
                <div class="max-w-4xl mx-auto text-center">
                    <div class="bg-white bg-opacity-10 backdrop-blur-sm rounded-2xl p-8">
                        <i class="fas fa-calendar-times text-6xl mb-6 opacity-70"></i>
                        <h1 class="text-4xl font-bold mb-4">No Events Available</h1>
                        <p class="text-xl mb-6 opacity-90">We don't have any upcoming events at the moment. Please check back later for exciting new events!</p>
                        
                        <!-- Debug Information -->
                        <div class="bg-red-500 bg-opacity-20 rounded-lg p-4 mb-4 text-left text-sm">
                            <h4 class="font-bold mb-2">Debug Information:</h4>
                            <?php foreach ($debugInfo as $info): ?>
                                <p>• <?php echo htmlspecialchars($info); ?></p>
                            <?php endforeach; ?>
                            
                            <?php if ($featuredEvent): ?>
                                <hr class="my-2 border-white border-opacity-30">
                                <p><strong>Featured Event Data:</strong></p>
                                <p>ID: <?php echo $featuredEvent['id'] ?? 'N/A'; ?></p>
                                <p>Name: <?php echo htmlspecialchars($featuredEvent['name'] ?? 'N/A'); ?></p>
                                <p>Start Date: <?php echo $featuredEvent['start_date'] ?? 'N/A'; ?></p>
                                <p>Event Type: <?php echo $featuredEvent['event_type'] ?? 'N/A'; ?></p>
                            <?php endif; ?>
                        </div>
                        
                        <a href="<?php echo BASE_URL; ?>" class="bg-white text-primary px-8 py-4 rounded-full text-lg font-semibold hover:bg-gray-100 transition">
                            <i class="fas fa-home mr-2"></i>Back to Home
                        </a>
                    </div>
                </div>
            </div>
        </section>
    <?php endif; ?>

    <!-- Other Events Section -->
    <?php if (!empty($upcomingEvents)): ?>
        <section class="py-16 bg-gray-50">
            <div class="container mx-auto px-4">
                <div class="text-center mb-12">
                    <h2 class="text-3xl font-bold text-gray-800 mb-4">More Upcoming Events</h2>
                    <p class="text-gray-600">Don't miss these other exciting events</p>
                </div>
                
                <!-- Events Slider -->
                <div class="relative">
                    <div class="events-slider overflow-hidden">
                        <div class="flex transition-transform duration-300 ease-in-out" id="eventsSlider">
                            <?php foreach ($upcomingEvents as $index => $event): ?>
                                <div class="flex-none w-full md:w-1/2 lg:w-1/3 xl:w-1/4 px-3">
                                    <div class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition transform hover:scale-105">
                                        <?php if ($event['image_url']): ?>
                                            <img src="<?php echo htmlspecialchars($event['image_url']); ?>" 
                                                 alt="<?php echo htmlspecialchars($event['name']); ?>"
                                                 class="w-full h-40 object-cover">
                                        <?php else: ?>
                                            <div class="w-full h-40 bg-gradient-to-r from-blue-400 to-purple-500 flex items-center justify-center">
                                                <i class="fas fa-calendar-alt text-3xl text-white"></i>
                                            </div>
                                        <?php endif; ?>
                                        
                                        <div class="p-4">
                                            <div class="flex items-center justify-between mb-2">
                                                <span class="px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800">
                                                    <?php echo ucfirst($event['event_type']); ?>
                                                </span>
                                                <?php if ($event['registration_fee'] > 0): ?>
                                                    <span class="text-green-600 font-semibold text-sm">
                                                        $<?php echo number_format($event['registration_fee'], 2); ?>
                                                    </span>
                                                <?php else: ?>
                                                    <span class="text-green-600 font-semibold text-sm">Free</span>
                                                <?php endif; ?>
                                            </div>
                                            
                                            <h3 class="text-lg font-bold text-gray-800 mb-2 line-clamp-2"><?php echo htmlspecialchars($event['name']); ?></h3>
                                            <p class="text-gray-600 mb-3 text-sm line-clamp-2"><?php echo htmlspecialchars(substr($event['description'], 0, 80)) . '...'; ?></p>
                                            
                                            <div class="space-y-1 mb-3 text-xs text-gray-500">
                                                <div class="flex items-center">
                                                    <i class="fas fa-calendar mr-2"></i>
                                                    <?php echo date('M j, Y', strtotime($event['start_date'])); ?>
                                                </div>
                                                <div class="flex items-center">
                                                    <i class="fas fa-clock mr-2"></i>
                                                    <?php echo date('g:i A', strtotime($event['start_date'])); ?>
                                                </div>
                                            </div>
                                            
                                            <button onclick="openRegistrationModal(<?php echo $event['id']; ?>, '<?php echo htmlspecialchars($event['name']); ?>')" 
                                                    class="w-full bg-primary text-white py-2 rounded-lg hover:opacity-90 transition text-sm">
                                                <i class="fas fa-user-plus mr-2"></i>Register
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    </div>
                    
                    <!-- Slider Navigation -->
                    <?php if (count($upcomingEvents) > 4): ?>
                        <button onclick="slideEvents('prev')" class="absolute left-0 top-1/2 transform -translate-y-1/2 bg-white shadow-lg rounded-full p-3 hover:bg-gray-50 transition">
                            <i class="fas fa-chevron-left text-gray-600"></i>
                        </button>
                        <button onclick="slideEvents('next')" class="absolute right-0 top-1/2 transform -translate-y-1/2 bg-white shadow-lg rounded-full p-3 hover:bg-gray-50 transition">
                            <i class="fas fa-chevron-right text-gray-600"></i>
                        </button>
                    <?php endif; ?>
                </div>
                
                <!-- Slider Dots -->
                <?php if (count($upcomingEvents) > 4): ?>
                    <div class="flex justify-center mt-8 space-x-2">
                        <?php 
                        $totalSlides = ceil(count($upcomingEvents) / 4);
                        for ($i = 0; $i < $totalSlides; $i++): 
                        ?>
                            <button onclick="goToSlide(<?php echo $i; ?>)" class="slider-dot w-3 h-3 rounded-full bg-gray-300 hover:bg-primary transition <?php echo $i === 0 ? 'bg-primary' : ''; ?>"></button>
                        <?php endfor; ?>
                    </div>
                <?php endif; ?>
            </div>
        </section>
    <?php endif; ?>


    <!-- Footer -->
    <footer class="bg-gray-800 text-white py-12">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4"><?php echo htmlspecialchars($settings['site_title']); ?></h3>
                    <p class="text-gray-300">Join us for inspiring events and meaningful connections in our community.</p>
                </div>
                
                <div>
                    <h4 class="text-lg font-semibold mb-4">Quick Links</h4>
                    <ul class="space-y-2">
                        <li><a href="<?php echo BASE_URL; ?>" class="text-gray-300 hover:text-white transition">Home</a></li>
                        <li><a href="check-status.php" class="text-gray-300 hover:text-white transition">Check Status</a></li>
                        <?php if ($isLoggedIn): ?>
                            <li><a href="<?php echo MemberAuth::isMemberLoggedIn() ? 'members/dashboard.php' : 'dashboard.php'; ?>" class="text-gray-300 hover:text-white transition">My Account</a></li>
                        <?php else: ?>
                            <li><a href="login.php" class="text-gray-300 hover:text-white transition">Login</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
                
                <div>
                    <h4 class="text-lg font-semibold mb-4">Contact Info</h4>
                    <div class="space-y-2 text-gray-300">
                        <p><i class="fas fa-envelope mr-2"></i>events@church.com</p>
                        <p><i class="fas fa-phone mr-2"></i>(555) 123-4567</p>
                    </div>
                </div>
            </div>
            
            <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-300">
                <p>&copy; <?php echo date('Y'); ?> <?php echo htmlspecialchars($settings['site_title']); ?>. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <!-- Registration Modal -->
    <div id="registrationModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50">
        <div class="flex items-center justify-center min-h-screen p-4">
            <div class="bg-white rounded-lg max-w-md w-full p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold" id="modalTitle">Event Registration</h3>
                    <button onclick="closeRegistrationModal()" class="text-gray-400 hover:text-gray-600">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <form method="POST" id="registrationForm">
                    <input type="hidden" name="event_id" id="modalEventId">
                    
                    <div class="space-y-4">
                        <div class="grid grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">First Name</label>
                                <input type="text" name="first_name" required 
                                       value="<?php echo $currentUser ? htmlspecialchars(explode(' ', $currentUser['full_name'])[0]) : ''; ?>"
                                       class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">Last Name</label>
                                <input type="text" name="last_name" required 
                                       value="<?php echo $currentUser ? htmlspecialchars(explode(' ', $currentUser['full_name'], 2)[1] ?? '') : ''; ?>"
                                       class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
                            <input type="email" name="email" required 
                                   value="<?php echo $currentUser ? htmlspecialchars($currentUser['email']) : ''; ?>"
                                   class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Phone (Optional)</label>
                            <input type="tel" name="phone" 
                                   value="<?php echo $currentUser ? htmlspecialchars($currentUser['phone'] ?? '') : ''; ?>"
                                   class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                        </div>
                    </div>
                    
                    <div class="flex justify-end space-x-3 mt-6">
                        <button type="button" onclick="closeRegistrationModal()" class="px-4 py-2 text-gray-600 hover:text-gray-800">
                            Cancel
                        </button>
                        <button type="submit" name="register_event" class="bg-primary text-white px-6 py-2 rounded-lg hover:opacity-90">
                            Register
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script>
        let currentSlide = 0;
        const eventsPerSlide = 4;
        const totalEvents = <?php echo count($upcomingEvents); ?>;
        const totalSlides = Math.ceil(totalEvents / eventsPerSlide);
        
        function openRegistrationModal(eventId, eventName) {
            document.getElementById('modalEventId').value = eventId;
            document.getElementById('modalTitle').textContent = 'Register for ' + eventName;
            document.getElementById('registrationModal').classList.remove('hidden');
        }
        
        function closeRegistrationModal() {
            document.getElementById('registrationModal').classList.add('hidden');
        }
        
        function slideEvents(direction) {
            const slider = document.getElementById('eventsSlider');
            if (!slider) return;
            
            if (direction === 'next' && currentSlide < totalSlides - 1) {
                currentSlide++;
            } else if (direction === 'prev' && currentSlide > 0) {
                currentSlide--;
            }
            
            const translateX = -currentSlide * (100 / totalSlides);
            slider.style.transform = `translateX(${translateX}%)`;
            
            updateSliderDots();
        }
        
        function goToSlide(slideIndex) {
            currentSlide = slideIndex;
            const slider = document.getElementById('eventsSlider');
            if (!slider) return;
            
            const translateX = -currentSlide * (100 / totalSlides);
            slider.style.transform = `translateX(${translateX}%)`;
            
            updateSliderDots();
        }
        
        function updateSliderDots() {
            const dots = document.querySelectorAll('.slider-dot');
            dots.forEach((dot, index) => {
                if (index === currentSlide) {
                    dot.classList.remove('bg-gray-300');
                    dot.classList.add('bg-primary');
                } else {
                    dot.classList.remove('bg-primary');
                    dot.classList.add('bg-gray-300');
                }
            });
        }
        
        // Auto-slide functionality (optional)
        function autoSlide() {
            if (totalSlides > 1) {
                setInterval(() => {
                    if (currentSlide < totalSlides - 1) {
                        slideEvents('next');
                    } else {
                        goToSlide(0);
                    }
                }, 5000); // Change slide every 5 seconds
            }
        }
        
        // Close modal when clicking outside
        document.getElementById('registrationModal').addEventListener('click', function(e) {
            if (e.target === this) {
                closeRegistrationModal();
            }
        });
        
        // Initialize auto-slide when page loads
        document.addEventListener('DOMContentLoaded', function() {
            // Uncomment the line below to enable auto-sliding
            // autoSlide();
        });
        
        // Mobile menu toggle function
        function toggleMobileMenu() {
            const menu = document.getElementById('mobileMenu');
            if (menu) {
                menu.classList.toggle('hidden');
            }
        }
    </script>

    <?php 
    // Include Chat Hub Widget (Admin Chat + AI Chatbot)
    if (file_exists(__DIR__ . '/includes/chat-hub-widget.php')) {
        include 'includes/chat-hub-widget.php';
    }
    ?>
</body>
</html>

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