Sindbad~EG File Manager

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

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

$eventId = $_GET['id'] ?? null;

if (!$eventId) {
    header('Location: ' . BASE_URL);
    exit();
}

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

// Get event details with related information
$stmt = $conn->prepare("SELECT e.*, 
                               a.name as area_name, 
                               d.name as district_name, 
                               ass.name as assembly_name,
                               u.first_name, u.last_name
                        FROM events e
                        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
                        LEFT JOIN users u ON e.created_by = u.id
                        WHERE e.id = ? AND e.status = 'published'");
$stmt->execute([$eventId]);
$event = $stmt->fetch();

// Get settings for site branding
$settings = getSettings();

if (!$event) {
    header('Location: ' . BASE_URL);
    exit();
}

// Get ticket types
$stmt = $conn->prepare("SELECT * FROM ticket_types WHERE event_id = ? AND status = 'active' ORDER BY price ASC");
$stmt->execute([$eventId]);
$ticketTypes = $stmt->fetchAll();

// Get event products
$stmt = $conn->prepare("SELECT * FROM products WHERE event_id = ? AND status = 'active' ORDER BY name ASC");
$stmt->execute([$eventId]);
$products = $stmt->fetchAll();

// Get registration count
$registrationCount = getEventRegistrationCount($eventId);

// Check if user is already registered
$userRegistered = false;
$userRegistration = null;
if (isLoggedIn()) {
    $stmt = $conn->prepare("SELECT * FROM event_registrations WHERE user_id = ? AND event_id = ? AND status != 'cancelled'");
    $stmt->execute([$_SESSION['user_id'], $eventId]);
    $userRegistration = $stmt->fetch();
    $userRegistered = (bool)$userRegistration;
}

$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($event['title'] ?? 'Event Details'); ?> - <?php echo htmlspecialchars($settings['site_name'] ?? 'COP Madina Conference Management'); ?></title>
    <meta name="description" content="<?php echo htmlspecialchars($event['seo_description'] ?? substr($event['description'], 0, 160)); ?>">
    <meta name="keywords" content="<?php echo htmlspecialchars($event['seo_keywords'] ?? 'church, conference, event, COP, Madina'); ?>">
    
    <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>
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
    </style>
</head>
<body class="bg-gray-50">
    <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">Event Details</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 (isLoggedIn()): ?>
                            <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>
                            <div class="relative" @click="showUserMenu = !showUserMenu">
                                <button class="flex items-center space-x-2 text-white/90 hover:text-white font-medium">
                                    <i class="fas fa-user-circle text-xl"></i>
                                    <span><?php echo $_SESSION['user_name'] ?? 'User'; ?></span>
                                    <i class="fas fa-chevron-down text-sm"></i>
                                </button>
                                <div v-show="showUserMenu" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-50">
                                    <a href="<?php echo BASE_URL; ?>profile.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
                                        <i class="fas fa-user mr-2"></i>Profile
                                    </a>
                                    <a href="<?php echo BASE_URL; ?>logout.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
                                        <i class="fas fa-sign-out-alt mr-2"></i>Logout
                                    </a>
                                </div>
                            </div>
                        <?php else: ?>
                            <a href="<?php echo BASE_URL; ?>login.php" class="text-white/90 hover:text-white font-medium transition-colors">
                                <i class="fas fa-sign-in-alt mr-2"></i>Login
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </nav>

        <!-- Event Hero Section -->
        <section class="relative">
            <?php if ($event['banner_image']): ?>
            <div class="h-96 bg-cover bg-center relative" style="background-image: url('<?php echo BASE_URL . $event['banner_image']; ?>')">
                <div class="absolute inset-0 bg-black bg-opacity-50"></div>
            </div>
            <?php else: ?>
            <div class="h-96 gradient-bg relative"></div>
            <?php endif; ?>
            
            <div class="absolute inset-0 flex items-center justify-center">
                <div class="text-center text-white max-w-4xl mx-auto px-4">
                    <div class="mb-4">
                        <span class="bg-white/20 backdrop-blur-sm px-4 py-2 rounded-full text-sm font-medium">
                            <?php echo ucfirst($event['event_type']); ?> Event
                        </span>
                    </div>
                    <h1 class="text-4xl md:text-6xl font-bold mb-4"><?php echo htmlspecialchars($event['title']); ?></h1>
                    <p class="text-xl mb-6 opacity-90"><?php echo htmlspecialchars(substr($event['description'], 0, 150)) . '...'; ?></p>
                    
                    <div class="flex flex-wrap justify-center gap-6 text-sm mb-8">
                        <div class="flex items-center bg-white/10 backdrop-blur-sm rounded-lg px-4 py-2">
                            <i class="fas fa-calendar-alt mr-2"></i>
                            <span><?php echo formatDate($event['start_date'], 'M d, Y'); ?></span>
                        </div>
                        <div class="flex items-center bg-white/10 backdrop-blur-sm rounded-lg px-4 py-2">
                            <i class="fas fa-clock mr-2"></i>
                            <span><?php echo formatDate($event['start_date'], 'g:i A'); ?></span>
                        </div>
                        <div class="flex items-center bg-white/10 backdrop-blur-sm rounded-lg px-4 py-2">
                            <i class="fas fa-map-marker-alt mr-2"></i>
                            <span><?php echo htmlspecialchars($event['venue'] ?? 'Venue TBA'); ?></span>
                        </div>
                    </div>
                    
                    <?php if ($userRegistered): ?>
                    <div class="bg-green-500/20 backdrop-blur-sm border border-green-300 rounded-lg p-4 mb-6 max-w-md mx-auto">
                        <i class="fas fa-check-circle text-green-300 text-2xl mb-2"></i>
                        <p class="font-semibold">You're registered!</p>
                        <p class="text-sm opacity-90">Registration Code: <?php echo $userRegistration['registration_code']; ?></p>
                    </div>
                    <?php else: ?>
                    <div class="flex flex-col sm:flex-row gap-4 justify-center">
                        <a href="<?php echo BASE_URL; ?>register.php?event=<?php echo $eventId; ?>" 
                           class="bg-green-500 text-white px-8 py-3 rounded-lg font-semibold hover:bg-green-600 transition-colors inline-block">
                            <i class="fas fa-user-plus mr-2"></i>Register Now
                        </a>
                        <button @click="shareEvent" class="bg-white/20 backdrop-blur-sm text-white px-8 py-3 rounded-lg font-semibold hover:bg-white/30 transition-colors">
                            <i class="fas fa-share mr-2"></i>Share Event
                        </button>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </section>

        <!-- Event Details -->
        <section class="py-12">
            <div class="container mx-auto px-4">
                <div class="grid lg:grid-cols-3 gap-8">
                    <!-- Main Content -->
                    <div class="lg:col-span-2">
                        <!-- Event Description -->
                        <div class="bg-white rounded-lg shadow-lg p-6 mb-8">
                            <h2 class="text-2xl font-bold mb-4">About This Event</h2>
                            <div class="prose max-w-none text-gray-700">
                                <?php echo nl2br(htmlspecialchars($event['description'])); ?>
                            </div>
                        </div>

                        <!-- Event Schedule -->
                        <div class="bg-white rounded-lg shadow-lg p-6 mb-8">
                            <h2 class="text-2xl font-bold mb-4">Event Schedule</h2>
                            <div class="space-y-4">
                                <div class="flex items-center p-4 bg-gray-50 rounded-lg">
                                    <div class="flex-shrink-0 w-16 h-16 bg-primary-100 rounded-lg flex items-center justify-center">
                                        <i class="fas fa-play text-primary-600 text-xl"></i>
                                    </div>
                                    <div class="ml-4">
                                        <h3 class="font-semibold">Event Starts</h3>
                                        <p class="text-gray-600"><?php echo formatDate($event['start_date'], 'l, F d, Y \a\t g:i A'); ?></p>
                                    </div>
                                </div>
                                
                                <div class="flex items-center p-4 bg-gray-50 rounded-lg">
                                    <div class="flex-shrink-0 w-16 h-16 bg-red-100 rounded-lg flex items-center justify-center">
                                        <i class="fas fa-stop text-red-600 text-xl"></i>
                                    </div>
                                    <div class="ml-4">
                                        <h3 class="font-semibold">Event Ends</h3>
                                        <p class="text-gray-600"><?php echo formatDate($event['end_date'], 'l, F d, Y \a\t g:i A'); ?></p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Ticket Types -->
                        <?php if (!empty($ticketTypes)): ?>
                        <div class="bg-white rounded-lg shadow-lg p-6 mb-8">
                            <h2 class="text-2xl font-bold mb-4">Ticket Options</h2>
                            <div class="space-y-4">
                                <?php foreach ($ticketTypes as $ticket): ?>
                                <div class="border border-gray-200 rounded-lg p-4">
                                    <div class="flex justify-between items-start mb-2">
                                        <h3 class="font-semibold text-lg"><?php echo htmlspecialchars($ticket['name']); ?></h3>
                                        <span class="text-2xl font-bold text-primary-600">
                                            <?php echo $ticket['price'] > 0 ? formatCurrency($ticket['price']) : 'Free'; ?>
                                        </span>
                                    </div>
                                    <?php if ($ticket['description']): ?>
                                    <p class="text-gray-600 mb-3"><?php echo htmlspecialchars($ticket['description']); ?></p>
                                    <?php endif; ?>
                                    
                                    <div class="flex items-center justify-between text-sm text-gray-500">
                                        <?php if ($ticket['capacity'] > 0): ?>
                                        <span><i class="fas fa-users mr-1"></i>Capacity: <?php echo $ticket['capacity']; ?></span>
                                        <?php endif; ?>
                                        
                                        <?php if ($ticket['sales_end']): ?>
                                        <span><i class="fas fa-clock mr-1"></i>Sales end: <?php echo formatDate($ticket['sales_end'], 'M d, Y'); ?></span>
                                        <?php endif; ?>
                                    </div>
                                </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                        <?php endif; ?>

                        <!-- Event Products -->
                        <?php if (!empty($products)): ?>
                        <div class="bg-white rounded-lg shadow-lg p-6">
                            <h2 class="text-2xl font-bold mb-4">Event Merchandise</h2>
                            <div class="grid md:grid-cols-2 gap-6">
                                <?php foreach ($products as $product): ?>
                                <div class="border border-gray-200 rounded-lg p-4">
                                    <?php if ($product['image']): ?>
                                    <img src="<?php echo BASE_URL . $product['image']; ?>" 
                                         alt="<?php echo htmlspecialchars($product['name']); ?>" 
                                         class="w-full h-32 object-cover rounded-lg mb-3">
                                    <?php endif; ?>
                                    
                                    <h3 class="font-semibold mb-2"><?php echo htmlspecialchars($product['name']); ?></h3>
                                    <?php if ($product['description']): ?>
                                    <p class="text-gray-600 text-sm mb-3"><?php echo htmlspecialchars($product['description']); ?></p>
                                    <?php endif; ?>
                                    
                                    <div class="flex justify-between items-center">
                                        <span class="text-lg font-bold text-primary-600"><?php echo formatCurrency($product['price']); ?></span>
                                        <?php if ($product['stock_quantity'] > 0): ?>
                                        <span class="text-sm text-green-600">In Stock (<?php echo $product['stock_quantity']; ?>)</span>
                                        <?php else: ?>
                                        <span class="text-sm text-red-600">Out of Stock</span>
                                        <?php endif; ?>
                                    </div>
                                </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                        <?php endif; ?>
                    </div>

                    <!-- Sidebar -->
                    <div class="lg:col-span-1">
                        <!-- Event Info Card -->
                        <div class="bg-white rounded-lg shadow-lg p-6 mb-6 sticky top-24">
                            <h3 class="text-xl font-bold mb-4">Event Information</h3>
                            
                            <div class="space-y-4">
                                <div class="flex items-center">
                                    <i class="fas fa-calendar-alt text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Date</p>
                                        <p class="text-gray-600 text-sm"><?php echo formatDate($event['start_date'], 'l, F d, Y'); ?></p>
                                    </div>
                                </div>
                                
                                <div class="flex items-center">
                                    <i class="fas fa-clock text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Time</p>
                                        <p class="text-gray-600 text-sm">
                                            <?php echo formatDate($event['start_date'], 'g:i A'); ?> - 
                                            <?php echo formatDate($event['end_date'], 'g:i A'); ?>
                                        </p>
                                    </div>
                                </div>
                                
                                <div class="flex items-center">
                                    <i class="fas fa-map-marker-alt text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Venue</p>
                                        <p class="text-gray-600 text-sm"><?php echo htmlspecialchars($event['venue'] ?? 'To be announced'); ?></p>
                                        <?php if ($event['address']): ?>
                                        <p class="text-gray-500 text-xs"><?php echo htmlspecialchars($event['address']); ?></p>
                                        <?php endif; ?>
                                    </div>
                                </div>
                                
                                <div class="flex items-center">
                                    <i class="fas fa-money-bill text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Registration Fee</p>
                                        <p class="text-gray-600 text-sm">
                                            <?php echo $event['registration_fee'] > 0 ? formatCurrency($event['registration_fee']) : 'Free'; ?>
                                        </p>
                                    </div>
                                </div>
                                
                                <?php if ($event['capacity'] > 0): ?>
                                <div class="flex items-center">
                                    <i class="fas fa-users text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Capacity</p>
                                        <p class="text-gray-600 text-sm"><?php echo $registrationCount; ?> / <?php echo $event['capacity']; ?> registered</p>
                                        <div class="mt-1 bg-gray-200 rounded-full h-2">
                                            <div class="bg-primary-600 h-2 rounded-full" 
                                                 style="width: <?php echo min(($registrationCount / $event['capacity']) * 100, 100); ?>%"></div>
                                        </div>
                                    </div>
                                </div>
                                <?php endif; ?>
                                
                                <div class="flex items-center">
                                    <i class="fas fa-tag text-primary-500 w-5"></i>
                                    <div class="ml-3">
                                        <p class="font-medium">Event Type</p>
                                        <p class="text-gray-600 text-sm">
                                            <?php 
                                            echo ucfirst($event['event_type']) . ' Event';
                                            if ($event['area_name']) echo ' - ' . $event['area_name'];
                                            if ($event['district_name']) echo ' - ' . $event['district_name'];
                                            if ($event['assembly_name']) echo ' - ' . $event['assembly_name'];
                                            ?>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            
                            <?php if (!$userRegistered): ?>
                            <div class="mt-6 pt-6 border-t border-gray-200">
                                <a href="<?php echo BASE_URL; ?>register.php?event=<?php echo $eventId; ?>" 
                                   class="w-full bg-primary-600 text-white py-3 px-4 rounded-lg hover:bg-primary-700 transition-colors font-medium text-center block">
                                    <i class="fas fa-user-plus mr-2"></i>Register for Event
                                </a>
                            </div>
                            <?php endif; ?>
                        </div>

                        <!-- Share Event -->
                        <div class="bg-white rounded-lg shadow-lg p-6">
                            <h3 class="text-xl font-bold mb-4">Share This Event</h3>
                            <div class="flex space-x-3">
                                <button @click="shareOnFacebook" class="flex-1 bg-blue-600 text-white py-2 px-3 rounded-lg hover:bg-blue-700 transition-colors text-sm">
                                    <i class="fab fa-facebook mr-1"></i>Facebook
                                </button>
                                <button @click="shareOnTwitter" class="flex-1 bg-blue-400 text-white py-2 px-3 rounded-lg hover:bg-blue-500 transition-colors text-sm">
                                    <i class="fab fa-twitter mr-1"></i>Twitter
                                </button>
                                <button @click="shareOnWhatsApp" class="flex-1 bg-green-600 text-white py-2 px-3 rounded-lg hover:bg-green-700 transition-colors text-sm">
                                    <i class="fab fa-whatsapp mr-1"></i>WhatsApp
                                </button>
                            </div>
                            
                            <div class="mt-4">
                                <label class="block text-sm font-medium text-gray-700 mb-2">Event Link</label>
                                <div class="flex">
                                    <input type="text" readonly 
                                           value="<?php echo BASE_URL; ?>event.php?id=<?php echo $eventId; ?>"
                                           class="flex-1 px-3 py-2 border border-gray-300 rounded-l-lg bg-gray-50 text-sm">
                                    <button @click="copyEventLink" 
                                            class="bg-gray-500 text-white px-4 py-2 rounded-r-lg hover:bg-gray-600 transition-colors">
                                        <i class="fas fa-copy"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <script>
        const { createApp } = Vue;
        
        createApp({
            data() {
                return {
                    showUserMenu: false
                }
            },
            methods: {
                shareEvent() {
                    if (navigator.share) {
                        navigator.share({
                            title: '<?php echo addslashes($event['title']); ?>',
                            text: '<?php echo addslashes(substr($event['description'], 0, 100)); ?>',
                            url: window.location.href
                        });
                    } else {
                        this.copyEventLink();
                    }
                },
                shareOnFacebook() {
                    const url = encodeURIComponent(window.location.href);
                    window.open(`https://www.facebook.com/sharer/sharer.php?u=${url}`, '_blank');
                },
                shareOnTwitter() {
                    const url = encodeURIComponent(window.location.href);
                    const text = encodeURIComponent('<?php echo addslashes($event['title']); ?>');
                    window.open(`https://twitter.com/intent/tweet?url=${url}&text=${text}`, '_blank');
                },
                shareOnWhatsApp() {
                    const url = encodeURIComponent(window.location.href);
                    const text = encodeURIComponent('Check out this event: <?php echo addslashes($event['title']); ?>');
                    window.open(`https://wa.me/?text=${text} ${url}`, '_blank');
                },
                copyEventLink() {
                    const input = document.querySelector('input[readonly]');
                    input.select();
                    document.execCommand('copy');
                    
                    // Show feedback
                    const button = event.target;
                    const originalText = button.innerHTML;
                    button.innerHTML = '<i class="fas fa-check"></i>';
                    setTimeout(() => {
                        button.innerHTML = originalText;
                    }, 2000);
                }
            },
            mounted() {
                document.addEventListener('click', (e) => {
                    if (!e.target.closest('.relative')) {
                        this.showUserMenu = false;
                    }
                });
            }
        }).mount('#app');
    </script>
</body>
</html>

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