Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/event-status.php

<?php
require_once 'config/config.php';

$pageTitle = "Event Status - " . APP_NAME;
$db = Database::getInstance()->getConnection();

$eventId = $_GET['event_id'] ?? null;
$eventCode = $_GET['event_code'] ?? null;
$selectedEvent = null;

// Get specific event if ID or code provided
if ($eventId) {
    $stmt = $db->prepare("SELECT * FROM events WHERE id = :id");
    $stmt->execute(['id' => $eventId]);
    $selectedEvent = $stmt->fetch();
} elseif ($eventCode) {
    // Try to find event by name or description containing the code
    $searchTerm = '%' . $eventCode . '%';
    $stmt = $db->prepare("SELECT * FROM events WHERE name LIKE :code1 OR description LIKE :code2 LIMIT 1");
    $stmt->execute(['code1' => $searchTerm, 'code2' => $searchTerm]);
    $selectedEvent = $stmt->fetch();
}

// Get all active events
$stmt = $db->query("
    SELECT e.*, 
           COUNT(DISTINCT er.id) as registration_count,
           COUNT(DISTINCT ea.id) as attendance_count
    FROM events e
    LEFT JOIN event_registrations er ON e.id = er.event_id
    LEFT JOIN event_attendance ea ON e.id = ea.event_id
    WHERE e.is_active = 1
    GROUP BY e.id
    ORDER BY e.start_date DESC
");
$allEvents = $stmt->fetchAll();

// 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 ?: []);
?>
<!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>
        :root {
            --primary-color: <?php echo $settings['theme_primary_color']; ?>;
            --secondary-color: <?php echo $settings['theme_secondary_color']; ?>;
        }
        .bg-primary { background-color: var(--primary-color); }
        .bg-secondary { background-color: var(--secondary-color); }
        .text-primary { color: var(--primary-color); }
        .text-secondary { color: var(--secondary-color); }
        .border-primary { border-color: var(--primary-color); }
        
        .gradient-bg {
            background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Header -->
    <header class="gradient-bg shadow-lg">
        <div class="container mx-auto px-4">
            <div class="flex items-center justify-between h-16">
                <div class="flex items-center space-x-3">
                    <a href="<?php echo BASE_URL; ?>" class="flex items-center space-x-2">
                        <i class="fas fa-church text-2xl text-white"></i>
                        <span class="text-white font-bold text-lg"><?php echo htmlspecialchars($settings['site_title']); ?></span>
                    </a>
                </div>
                
                <div class="flex items-center space-x-4">
                    <a href="conference.php" class="text-white hover:text-gray-200 transition">
                        <i class="fas fa-calendar mr-1"></i>Events
                    </a>
                    <a href="check-status.php" class="text-white hover:text-gray-200 transition">
                        <i class="fas fa-search mr-1"></i>Check Status
                    </a>
                    <a href="login.php" class="text-white hover:text-gray-200 transition">
                        <i class="fas fa-sign-in-alt mr-1"></i>Login
                    </a>
                </div>
            </div>
        </div>
    </header>

    <div class="container mx-auto px-4 py-8">
        <div class="max-w-6xl mx-auto">
            <!-- Page Header -->
            <div class="text-center mb-8">
                <h1 class="text-4xl font-bold text-gray-800 mb-4">
                    <i class="fas fa-calendar-check mr-3" style="background: linear-gradient(135deg, #F97316 0%, #FBBF24 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent;"></i>Event Status
                </h1>
                <p class="text-gray-600 text-lg">View details and status of all church events</p>
            </div>

            <?php if ($selectedEvent): ?>
                <!-- Selected Event Details -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
                    <div class="gradient-bg text-white p-6">
                        <div class="flex items-center justify-between flex-wrap gap-4">
                            <div>
                                <h2 class="text-2xl font-bold mb-2"><?php echo htmlspecialchars($selectedEvent['name']); ?></h2>
                                <p class="text-white/90">Event ID: #<?php echo $selectedEvent['id']; ?></p>
                            </div>
                            <div class="text-right">
                                <?php
                                $statusColors = [
                                    'open' => 'bg-green-500',
                                    'closed' => 'bg-red-500',
                                    'pending' => 'bg-yellow-500'
                                ];
                                $statusIcons = [
                                    'open' => 'check-circle',
                                    'closed' => 'times-circle',
                                    'pending' => 'clock'
                                ];
                                ?>
                                <div class="<?php echo $statusColors[$selectedEvent['registration_status']] ?? 'bg-gray-500'; ?> px-4 py-2 rounded-full inline-block">
                                    <i class="fas fa-<?php echo $statusIcons[$selectedEvent['registration_status']] ?? 'question'; ?> mr-2"></i>
                                    <?php echo ucfirst($selectedEvent['registration_status']); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="p-6">
                        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-6">
                            <!-- Event Details -->
                            <div>
                                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                                    <i class="fas fa-info-circle mr-2 text-blue-500"></i>Event Details
                                </h3>
                                <div class="space-y-2 text-sm">
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Start Date:</span>
                                        <span class="font-medium"><?php echo date('M j, Y', strtotime($selectedEvent['start_date'])); ?></span>
                                    </div>
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Start Time:</span>
                                        <span class="font-medium"><?php echo date('g:i A', strtotime($selectedEvent['start_date'])); ?></span>
                                    </div>
                                    <?php if ($selectedEvent['end_date']): ?>
                                        <div class="flex justify-between">
                                            <span class="text-gray-600">End Date:</span>
                                            <span class="font-medium"><?php echo date('M j, Y', strtotime($selectedEvent['end_date'])); ?></span>
                                        </div>
                                    <?php endif; ?>
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Location:</span>
                                        <span class="font-medium"><?php echo ucfirst($selectedEvent['location_type']); ?></span>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Registration Info -->
                            <div>
                                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                                    <i class="fas fa-users mr-2 text-green-500"></i>Registration
                                </h3>
                                <div class="space-y-2 text-sm">
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Status:</span>
                                        <span class="font-medium"><?php echo ucfirst($selectedEvent['registration_status']); ?></span>
                                    </div>
                                    <?php if ($selectedEvent['registration_open_date']): ?>
                                        <div class="flex justify-between">
                                            <span class="text-gray-600">Opens:</span>
                                            <span class="font-medium"><?php echo date('M j, Y', strtotime($selectedEvent['registration_open_date'])); ?></span>
                                        </div>
                                    <?php endif; ?>
                                    <?php if ($selectedEvent['registration_close_date']): ?>
                                        <div class="flex justify-between">
                                            <span class="text-gray-600">Closes:</span>
                                            <span class="font-medium"><?php echo date('M j, Y', strtotime($selectedEvent['registration_close_date'])); ?></span>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                            
                            <!-- Statistics -->
                            <div>
                                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                                    <i class="fas fa-chart-bar mr-2 text-purple-500"></i>Statistics
                                </h3>
                                <div class="space-y-2 text-sm">
                                    <?php
                                    $stmt = $db->prepare("SELECT COUNT(*) as count FROM event_registrations WHERE event_id = :id");
                                    $stmt->execute(['id' => $selectedEvent['id']]);
                                    $regCount = $stmt->fetch()['count'];
                                    
                                    $stmt = $db->prepare("SELECT COUNT(*) as count FROM event_attendance WHERE event_id = :id");
                                    $stmt->execute(['id' => $selectedEvent['id']]);
                                    $attendCount = $stmt->fetch()['count'];
                                    ?>
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Registrations:</span>
                                        <span class="font-bold text-green-600"><?php echo $regCount; ?></span>
                                    </div>
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Attendance:</span>
                                        <span class="font-bold text-blue-600"><?php echo $attendCount; ?></span>
                                    </div>
                                    <div class="flex justify-between">
                                        <span class="text-gray-600">Status:</span>
                                        <span class="font-medium"><?php echo $selectedEvent['is_active'] ? 'Active' : 'Inactive'; ?></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <?php if ($selectedEvent['description']): ?>
                            <div class="border-t pt-6">
                                <h3 class="font-bold text-gray-800 mb-2">
                                    <i class="fas fa-align-left mr-2 text-orange-500"></i>Description
                                </h3>
                                <p class="text-gray-600"><?php echo nl2br(htmlspecialchars($selectedEvent['description'])); ?></p>
                            </div>
                        <?php endif; ?>
                        
                        <?php if ($selectedEvent['registration_message']): ?>
                            <div class="border-t pt-6 mt-6">
                                <h3 class="font-bold text-gray-800 mb-2">
                                    <i class="fas fa-bullhorn mr-2 text-yellow-500"></i>Registration Message
                                </h3>
                                <div class="bg-yellow-50 border-l-4 border-yellow-500 p-4 rounded">
                                    <p class="text-gray-700"><?php echo nl2br(htmlspecialchars($selectedEvent['registration_message'])); ?></p>
                                </div>
                            </div>
                        <?php endif; ?>
                        
                        <!-- Actions -->
                        <div class="border-t pt-6 mt-6">
                            <div class="flex flex-wrap gap-4 justify-center">
                                <?php if ($selectedEvent['registration_status'] === 'open'): ?>
                                    <a href="event-registration.php?event_id=<?php echo $selectedEvent['id']; ?>" 
                                       class="px-6 py-3 bg-green-500 text-white rounded-lg hover:bg-green-600 transition">
                                        <i class="fas fa-user-plus mr-2"></i>Register for Event
                                    </a>
                                <?php endif; ?>
                                <a href="conference.php" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition">
                                    <i class="fas fa-calendar mr-2"></i>View All Events
                                </a>
                                <button onclick="window.print()" class="px-6 py-3 bg-gray-500 text-white rounded-lg hover:bg-gray-600 transition">
                                    <i class="fas fa-print mr-2"></i>Print Details
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <!-- All Events List -->
            <div class="mb-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">
                    <i class="fas fa-list mr-2 text-orange-500"></i>All Events
                </h2>
                
                <?php if (empty($allEvents)): ?>
                    <div class="bg-white rounded-xl shadow-lg p-8 text-center">
                        <i class="fas fa-calendar-times text-6xl text-gray-300 mb-4"></i>
                        <p class="text-gray-600">No events found</p>
                    </div>
                <?php else: ?>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <?php foreach ($allEvents as $event): ?>
                            <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                                <div class="p-6">
                                    <div class="flex items-start justify-between mb-3">
                                        <div class="flex-1">
                                            <h3 class="font-bold text-lg text-gray-800 mb-1">
                                                <?php echo htmlspecialchars($event['name']); ?>
                                            </h3>
                                            <p class="text-xs text-gray-500">Event #<?php echo $event['id']; ?></p>
                                        </div>
                                        <?php
                                        $statusColors = [
                                            'open' => 'bg-green-100 text-green-700',
                                            'closed' => 'bg-red-100 text-red-700',
                                            'pending' => 'bg-yellow-100 text-yellow-700'
                                        ];
                                        ?>
                                        <span class="px-2 py-1 text-xs font-bold rounded-full <?php echo $statusColors[$event['registration_status']] ?? 'bg-gray-100 text-gray-700'; ?>">
                                            <?php echo ucfirst($event['registration_status']); ?>
                                        </span>
                                    </div>
                                    
                                    <div class="space-y-2 text-sm mb-4">
                                        <div class="flex items-center text-gray-600">
                                            <i class="fas fa-calendar w-5 mr-2 text-blue-500"></i>
                                            <span><?php echo date('M j, Y', strtotime($event['start_date'])); ?></span>
                                        </div>
                                        <div class="flex items-center text-gray-600">
                                            <i class="fas fa-clock w-5 mr-2 text-green-500"></i>
                                            <span><?php echo date('g:i A', strtotime($event['start_date'])); ?></span>
                                        </div>
                                        <div class="flex items-center text-gray-600">
                                            <i class="fas fa-map-marker-alt w-5 mr-2 text-red-500"></i>
                                            <span><?php echo ucfirst($event['location_type']); ?></span>
                                        </div>
                                    </div>
                                    
                                    <div class="flex items-center justify-between text-xs text-gray-600 mb-4 pb-4 border-b">
                                        <div class="flex items-center">
                                            <i class="fas fa-users mr-1 text-green-500"></i>
                                            <span><?php echo $event['registration_count']; ?> registered</span>
                                        </div>
                                        <div class="flex items-center">
                                            <i class="fas fa-user-check mr-1 text-blue-500"></i>
                                            <span><?php echo $event['attendance_count']; ?> attended</span>
                                        </div>
                                    </div>
                                    
                                    <a href="?event_id=<?php echo $event['id']; ?>" 
                                       class="block w-full text-center px-4 py-2 bg-gradient-to-r from-orange-500 to-yellow-500 text-white rounded-lg hover:shadow-lg transition">
                                        <i class="fas fa-eye mr-2"></i>View Details
                                    </a>
                                </div>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
            </div>
            
            <!-- Back Link -->
            <div class="text-center mt-8">
                <a href="check-status.php" class="inline-block px-6 py-3 bg-gray-500 text-white rounded-lg hover:bg-gray-600 transition">
                    <i class="fas fa-arrow-left mr-2"></i>Back to Status Checker
                </a>
            </div>
        </div>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-800 text-white py-6 mt-12">
        <div class="container mx-auto px-4 text-center">
            <p>&copy; <?php echo date('Y'); ?> <?php echo APP_NAME; ?>. All rights reserved.</p>
        </div>
    </footer>
</body>
</html>

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