Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/conference/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/conference/attendance-status.php

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

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

$attendanceInfo = null;
$message = '';
$messageType = '';

// Handle check-out form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'checkout') {
    $registrationCode = trim($_POST['registration_code']);
    
    
    if (empty($registrationCode)) {
        $message = 'Registration code is required for check-out.';
        $messageType = 'error';
    } else {
        // Check member registrations first
        $stmt = $conn->prepare("
            SELECT er.*, e.title as event_title, u.first_name, u.last_name
            FROM event_registrations er
            JOIN events e ON er.event_id = e.id
            JOIN users u ON er.user_id = u.id
            WHERE er.registration_code = ? AND e.status = 'published' AND er.checked_in_at IS NOT NULL AND er.checked_out_at IS NULL
        ");
        $stmt->execute([$registrationCode]);
        $memberRegistration = $stmt->fetch();
        
        if ($memberRegistration) {
            // Update check-out time
            $updateStmt = $conn->prepare("UPDATE event_registrations SET checked_out_at = NOW(), updated_at = NOW() WHERE registration_code = ?");
            $result = $updateStmt->execute([$registrationCode]);
            
            if ($result) {
                // Calculate duration
                $durationStmt = $conn->prepare("SELECT TIMESTAMPDIFF(MINUTE, checked_in_at, NOW()) as duration_minutes FROM event_registrations WHERE registration_code = ?");
                $durationStmt->execute([$registrationCode]);
                $duration = $durationStmt->fetch()['duration_minutes'];
                
                // Log attendance
                $logStmt = $conn->prepare("INSERT INTO attendance_logs (event_id, user_id, registration_code, registration_type, action, action_time, duration_minutes, ip_address, user_agent) VALUES (?, ?, ?, 'member', 'check_out', NOW(), ?, ?, ?)");
                $logStmt->execute([
                    $memberRegistration['event_id'],
                    $memberRegistration['user_id'],
                    $registrationCode,
                    $duration,
                    $_SERVER['REMOTE_ADDR'] ?? null,
                    $_SERVER['HTTP_USER_AGENT'] ?? null
                ]);
                
                $hours = floor($duration / 60);
                $minutes = $duration % 60;
                $durationText = ($hours > 0 ? $hours . 'h ' : '') . $minutes . 'm';
                
                $message = "Thank you {$memberRegistration['first_name']}! You have been checked out of '{$memberRegistration['event_title']}'. Duration: {$durationText}";
                $messageType = 'success';
                
                // Log the check-out activity
                logActivity($memberRegistration['user_id'], 'self_check_out', "Self checked out of event: {$memberRegistration['event_title']} (Duration: {$durationText})");
                
                // Re-fetch updated attendance info to show check-out status
                $stmt = $conn->prepare("
                    SELECT er.*, e.title as event_title, e.start_date, e.end_date, e.venue,
                           u.first_name, u.last_name, u.email,
                           CASE 
                               WHEN er.checked_out_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, er.checked_in_at, er.checked_out_at)
                               WHEN er.checked_in_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, er.checked_in_at, NOW())
                               ELSE NULL
                           END as duration_minutes
                    FROM event_registrations er
                    JOIN events e ON er.event_id = e.id
                    JOIN users u ON er.user_id = u.id
                    WHERE er.registration_code = ? AND e.status = 'published'
                ");
                $stmt->execute([$registrationCode]);
                $updatedInfo = $stmt->fetch();
                if ($updatedInfo) {
                    $attendanceInfo = array_merge($updatedInfo, ['type' => 'member']);
                }
            } else {
                $message = 'Failed to check out. Please try again or contact support.';
                $messageType = 'error';
            }
        } else {
            // Check non-member registrations
            $stmt = $conn->prepare("
                SELECT nr.*, e.title as event_title
                FROM nonmember_registrations nr
                JOIN events e ON nr.event_id = e.id
                WHERE nr.registration_code = ? AND e.status = 'published' AND nr.status = 'attended' AND nr.checked_in_at IS NOT NULL AND nr.checked_out_at IS NULL
            ");
            $stmt->execute([$registrationCode]);
            $nonMemberRegistration = $stmt->fetch();
            
            if ($nonMemberRegistration) {
                // Update check-out time
                $updateStmt = $conn->prepare("UPDATE nonmember_registrations SET checked_out_at = NOW(), updated_at = NOW() WHERE registration_code = ?");
                $result = $updateStmt->execute([$registrationCode]);
                
                if ($result) {
                    // Calculate duration
                    $durationStmt = $conn->prepare("SELECT TIMESTAMPDIFF(MINUTE, checked_in_at, NOW()) as duration_minutes FROM nonmember_registrations WHERE registration_code = ?");
                    $durationStmt->execute([$registrationCode]);
                    $duration = $durationStmt->fetch()['duration_minutes'];
                    
                    // Log attendance
                    $logStmt = $conn->prepare("INSERT INTO attendance_logs (event_id, user_id, registration_code, registration_type, action, action_time, duration_minutes, ip_address, user_agent) VALUES (?, NULL, ?, 'nonmember', 'check_out', NOW(), ?, ?, ?)");
                    $logStmt->execute([
                        $nonMemberRegistration['event_id'],
                        $registrationCode,
                        $duration,
                        $_SERVER['REMOTE_ADDR'] ?? null,
                        $_SERVER['HTTP_USER_AGENT'] ?? null
                    ]);
                    
                    $formData = json_decode($nonMemberRegistration['form_data'], true);
                    $guestName = ($formData['first_name'] ?? '') . ' ' . ($formData['last_name'] ?? '');
                    $guestName = trim($guestName) ?: 'Guest';
                    
                    $hours = floor($duration / 60);
                    $minutes = $duration % 60;
                    $durationText = ($hours > 0 ? $hours . 'h ' : '') . $minutes . 'm';
                    
                    $message = "Thank you {$guestName}! You have been checked out of '{$nonMemberRegistration['event_title']}'. Duration: {$durationText}";
                    $messageType = 'success';
                    
                    // Re-fetch updated attendance info to show check-out status
                    $stmt = $conn->prepare("
                        SELECT nr.*, e.title as event_title, e.start_date, e.end_date, e.venue,
                               CASE 
                                   WHEN nr.checked_out_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, nr.checked_in_at, nr.checked_out_at)
                                   WHEN nr.checked_in_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, nr.checked_in_at, NOW())
                                   ELSE NULL
                               END as duration_minutes
                        FROM nonmember_registrations nr
                        JOIN events e ON nr.event_id = e.id
                        WHERE nr.registration_code = ? AND e.status = 'published'
                    ");
                    $stmt->execute([$registrationCode]);
                    $updatedInfo = $stmt->fetch();
                    if ($updatedInfo) {
                        $attendanceInfo = array_merge($updatedInfo, ['type' => 'nonmember']);
                    }
                } else {
                    $message = 'Failed to check out. Please try again or contact support.';
                    $messageType = 'error';
                }
            } else {
                $message = 'Registration code not found or you are not currently checked in to any event.';
                $messageType = 'error';
            }
        }
    }
}

// Handle status check form submission
elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $registrationCode = trim($_POST['registration_code']);
    
    if (empty($registrationCode)) {
        $message = 'Please enter your registration code.';
        $messageType = 'error';
    } else {
        // Check member registrations first
        $stmt = $conn->prepare("
            SELECT er.*, e.title as event_title, e.start_date, e.end_date, e.venue,
                   u.first_name, u.last_name, u.email,
                   CASE 
                       WHEN er.checked_out_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, er.checked_in_at, er.checked_out_at)
                       WHEN er.checked_in_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, er.checked_in_at, NOW())
                       ELSE NULL
                   END as duration_minutes
            FROM event_registrations er
            JOIN events e ON er.event_id = e.id
            JOIN users u ON er.user_id = u.id
            WHERE er.registration_code = ? AND e.status = 'published'
        ");
        $stmt->execute([$registrationCode]);
        $memberRegistration = $stmt->fetch();
        
        if ($memberRegistration) {
            $attendanceInfo = array_merge($memberRegistration, ['type' => 'member']);
        } else {
            // Check non-member registrations
            $stmt = $conn->prepare("
                SELECT nr.*, e.title as event_title, e.start_date, e.end_date, e.venue,
                       CASE 
                           WHEN nr.checked_out_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, nr.checked_in_at, nr.checked_out_at)
                           WHEN nr.checked_in_at IS NOT NULL THEN TIMESTAMPDIFF(MINUTE, nr.checked_in_at, NOW())
                           ELSE NULL
                       END as duration_minutes
                FROM nonmember_registrations nr
                JOIN events e ON nr.event_id = e.id
                WHERE nr.registration_code = ? AND e.status = 'published'
            ");
            $stmt->execute([$registrationCode]);
            $nonMemberRegistration = $stmt->fetch();
            
            if ($nonMemberRegistration) {
                $attendanceInfo = array_merge($nonMemberRegistration, ['type' => 'nonmember']);
            } else {
                $message = 'Registration code not found. Please check your code and try again.';
                $messageType = 'error';
            }
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Attendance Status - COP Madina Conference</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    animation: {
                        'fade-in': 'fadeIn 0.5s ease-out',
                        'slide-up': 'slideUp 0.6s ease-out',
                        'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite'
                    },
                    keyframes: {
                        fadeIn: {
                            '0%': { opacity: '0' },
                            '100%': { opacity: '1' }
                        },
                        slideUp: {
                            '0%': { opacity: '0', transform: 'translateY(20px)' },
                            '100%': { opacity: '1', transform: 'translateY(0)' }
                        }
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gradient-to-br from-purple-50 via-white to-indigo-100 min-h-screen">
    <!-- Header -->
    <header class="bg-white/80 backdrop-blur-sm 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 py-4">
                <div class="flex items-center space-x-4">
                    <a href="index.php" class="flex items-center space-x-3">
                        <div class="w-10 h-10 bg-gradient-to-br from-purple-600 to-indigo-600 rounded-xl flex items-center justify-center">
                            <i class="fas fa-church text-white text-lg"></i>
                        </div>
                        <div>
                            <h1 class="text-xl font-bold bg-gradient-to-r from-purple-600 to-indigo-600 bg-clip-text text-transparent">
                                COP Madina Conference
                            </h1>
                            <p class="text-sm text-slate-600">Attendance Status</p>
                        </div>
                    </a>
                </div>
                
                <nav class="hidden md:flex items-center space-x-6">
                    <a href="index.php" class="text-slate-600 hover:text-purple-600 transition-colors">
                        <i class="fas fa-home mr-2"></i>Home
                    </a>
                    <a href="check-in.php" class="text-slate-600 hover:text-blue-600 transition-colors">
                        <i class="fas fa-sign-in-alt mr-2"></i>Check-In
                    </a>
                    <a href="check-out.php" class="text-slate-600 hover:text-red-600 transition-colors">
                        <i class="fas fa-sign-out-alt mr-2"></i>Check-Out
                    </a>
                    <a href="login.php" class="bg-gradient-to-r from-purple-600 to-indigo-600 text-white px-4 py-2 rounded-lg hover:from-purple-700 hover:to-indigo-700 transition-all duration-200">
                        <i class="fas fa-sign-in-alt mr-2"></i>Login
                    </a>
                </nav>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- Hero Section -->
        <div class="text-center mb-12 animate-fade-in">
            <div class="inline-flex items-center justify-center w-20 h-20 bg-gradient-to-br from-purple-500 to-indigo-600 rounded-2xl mb-6 shadow-lg">
                <i class="fas fa-clock text-white text-3xl"></i>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold text-slate-800 mb-4">
                Attendance Status
            </h1>
            <p class="text-xl text-slate-600 max-w-2xl mx-auto">
                Check your current attendance status and duration for any registered event.
            </p>
        </div>

        <!-- Message Display -->
        <?php if ($message): ?>
        <div class="mb-8 animate-slide-up">
            <div class="p-6 rounded-2xl border-l-4 <?php echo $messageType === 'success' ? 'bg-emerald-50 border-emerald-500' : ($messageType === 'info' ? 'bg-blue-50 border-blue-500' : 'bg-red-50 border-red-500'); ?>">
                <div class="flex items-center">
                    <i class="fas <?php echo $messageType === 'success' ? 'fa-check-circle text-emerald-600' : ($messageType === 'info' ? 'fa-info-circle text-blue-600' : 'fa-exclamation-circle text-red-600'); ?> text-xl mr-4"></i>
                    <div>
                        <p class="font-semibold <?php echo $messageType === 'success' ? 'text-emerald-800' : ($messageType === 'info' ? 'text-blue-800' : 'text-red-800'); ?>">
                            <?php echo htmlspecialchars($message); ?>
                        </p>
                    </div>
                </div>
            </div>
        </div>
        <?php endif; ?>

        <!-- Status Check Form -->
        <?php if (!$attendanceInfo): ?>
        <div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-xl p-8 mb-12 border border-slate-200/50 animate-slide-up">
            <form method="POST" class="space-y-6">
                <div>
                    <label for="registration_code" class="block text-lg font-semibold text-slate-700 mb-3">
                        <i class="fas fa-ticket-alt mr-2 text-purple-600"></i>
                        Registration Code
                    </label>
                    <input 
                        type="text" 
                        id="registration_code" 
                        name="registration_code" 
                        required 
                        class="w-full px-6 py-4 text-lg border-2 border-slate-300 rounded-xl focus:ring-4 focus:ring-purple-500/20 focus:border-purple-500 transition-all duration-200 bg-white/50 backdrop-blur-sm"
                        placeholder="Enter your registration code (e.g., REG-12345)"
                        value="<?php echo htmlspecialchars($_POST['registration_code'] ?? ''); ?>"
                    >
                    <p class="mt-2 text-sm text-slate-600">
                        <i class="fas fa-info-circle mr-1"></i>
                        Enter your registration code to view your attendance status and duration.
                    </p>
                </div>
                
                <button 
                    type="submit" 
                    class="w-full bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-semibold py-4 px-8 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-1 text-lg"
                >
                    <i class="fas fa-search mr-3"></i>
                    Check Attendance Status
                </button>
            </form>
        </div>
        <?php endif; ?>

        <!-- Attendance Information Display -->
        <?php if ($attendanceInfo): ?>
        <div class="space-y-8 animate-slide-up">
            <!-- Event Information -->
            <div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-xl p-8 border border-slate-200/50">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-gradient-to-br from-purple-500 to-indigo-600 rounded-xl flex items-center justify-center mr-4">
                        <i class="fas fa-calendar-alt text-white text-xl"></i>
                    </div>
                    <div>
                        <h2 class="text-2xl font-bold text-slate-800"><?php echo htmlspecialchars($attendanceInfo['event_title']); ?></h2>
                        <p class="text-slate-600">Event Details</p>
                    </div>
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div class="space-y-4">
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Registration Code</label>
                            <p class="text-lg font-mono bg-slate-100 px-3 py-2 rounded-lg"><?php echo htmlspecialchars($attendanceInfo['registration_code']); ?></p>
                        </div>
                        
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Attendee Type</label>
                            <p class="text-lg">
                                <span class="px-3 py-1 rounded-full text-sm font-semibold <?php echo $attendanceInfo['type'] === 'member' ? 'bg-blue-100 text-blue-800' : 'bg-purple-100 text-purple-800'; ?>">
                                    <?php echo ucfirst($attendanceInfo['type']); ?>
                                </span>
                            </p>
                        </div>
                        
                        <?php if ($attendanceInfo['type'] === 'member'): ?>
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Name</label>
                            <p class="text-lg font-semibold text-slate-800"><?php echo htmlspecialchars($attendanceInfo['first_name'] . ' ' . $attendanceInfo['last_name']); ?></p>
                        </div>
                        <?php else: ?>
                        <?php 
                            $formData = json_decode($attendanceInfo['form_data'], true);
                            $guestName = ($formData['first_name'] ?? '') . ' ' . ($formData['last_name'] ?? '');
                        ?>
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Name</label>
                            <p class="text-lg font-semibold text-slate-800"><?php echo htmlspecialchars(trim($guestName) ?: 'Guest'); ?></p>
                        </div>
                        <?php endif; ?>
                    </div>
                    
                    <div class="space-y-4">
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Event Date</label>
                            <p class="text-lg"><?php echo date('M j, Y g:i A', strtotime($attendanceInfo['start_date'])); ?></p>
                        </div>
                        
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Venue</label>
                            <p class="text-lg"><?php echo htmlspecialchars($attendanceInfo['venue'] ?: 'TBA'); ?></p>
                        </div>
                        
                        <div>
                            <label class="text-sm font-semibold text-slate-600 uppercase tracking-wide">Registration Status</label>
                            <p class="text-lg">
                                <span class="px-3 py-1 rounded-full text-sm font-semibold <?php echo $attendanceInfo['status'] === 'attended' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'; ?>">
                                    <?php echo ucfirst($attendanceInfo['status']); ?>
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Attendance Status -->
            <div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-xl p-8 border border-slate-200/50">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-gradient-to-br from-emerald-500 to-green-600 rounded-xl flex items-center justify-center mr-4">
                        <i class="fas fa-user-check text-white text-xl"></i>
                    </div>
                    <div>
                        <h3 class="text-2xl font-bold text-slate-800">Attendance Status</h3>
                        <p class="text-slate-600">Check-in and duration information</p>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <!-- Check-in Status -->
                    <div class="text-center p-6 rounded-xl <?php echo $attendanceInfo['checked_in_at'] ? 'bg-green-50 border-2 border-green-200' : 'bg-slate-50 border-2 border-slate-200'; ?>">
                        <div class="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center <?php echo $attendanceInfo['checked_in_at'] ? 'bg-green-500' : 'bg-slate-400'; ?>">
                            <i class="fas fa-sign-in-alt text-white text-xl"></i>
                        </div>
                        <h4 class="text-lg font-bold <?php echo $attendanceInfo['checked_in_at'] ? 'text-green-800' : 'text-slate-600'; ?>">Check-In</h4>
                        <?php if ($attendanceInfo['checked_in_at']): ?>
                            <p class="text-sm text-green-600 font-semibold">✓ Checked In</p>
                            <p class="text-xs text-slate-600 mt-1"><?php echo date('M j, g:i A', strtotime($attendanceInfo['checked_in_at'])); ?></p>
                        <?php else: ?>
                            <p class="text-sm text-slate-500">Not Checked In</p>
                        <?php endif; ?>
                    </div>

                    <!-- Duration -->
                    <div class="text-center p-6 rounded-xl <?php echo $attendanceInfo['duration_minutes'] ? 'bg-blue-50 border-2 border-blue-200' : 'bg-slate-50 border-2 border-slate-200'; ?>">
                        <div class="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center <?php echo $attendanceInfo['duration_minutes'] ? 'bg-blue-500' : 'bg-slate-400'; ?>">
                            <i class="fas fa-clock text-white text-xl"></i>
                        </div>
                        <h4 class="text-lg font-bold <?php echo $attendanceInfo['duration_minutes'] ? 'text-blue-800' : 'text-slate-600'; ?>">Duration</h4>
                        <?php if ($attendanceInfo['duration_minutes']): ?>
                            <?php 
                                $hours = floor($attendanceInfo['duration_minutes'] / 60);
                                $minutes = $attendanceInfo['duration_minutes'] % 60;
                                $durationText = ($hours > 0 ? $hours . 'h ' : '') . $minutes . 'm';
                            ?>
                            <p class="text-sm text-blue-600 font-semibold"><?php echo $durationText; ?></p>
                            <p class="text-xs text-slate-600 mt-1"><?php echo $attendanceInfo['checked_out_at'] ? 'Final Duration' : 'Current Duration'; ?></p>
                        <?php else: ?>
                            <p class="text-sm text-slate-500">No Duration</p>
                        <?php endif; ?>
                    </div>

                    <!-- Check-out Status -->
                    <div class="text-center p-6 rounded-xl <?php echo $attendanceInfo['checked_out_at'] ? 'bg-red-50 border-2 border-red-200' : 'bg-slate-50 border-2 border-slate-200'; ?>">
                        <div class="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center <?php echo $attendanceInfo['checked_out_at'] ? 'bg-red-500' : 'bg-slate-400'; ?>">
                            <i class="fas fa-sign-out-alt text-white text-xl"></i>
                        </div>
                        <h4 class="text-lg font-bold <?php echo $attendanceInfo['checked_out_at'] ? 'text-red-800' : 'text-slate-600'; ?>">Check-Out</h4>
                        <?php if ($attendanceInfo['checked_out_at']): ?>
                            <p class="text-sm text-red-600 font-semibold">✓ Checked Out</p>
                            <p class="text-xs text-slate-600 mt-1"><?php echo date('M j, g:i A', strtotime($attendanceInfo['checked_out_at'])); ?></p>
                        <?php else: ?>
                            <p class="text-sm text-slate-500"><?php echo $attendanceInfo['checked_in_at'] ? 'Still Checked In' : 'Not Checked Out'; ?></p>
                        <?php endif; ?>
                    </div>
                </div>

                <!-- Action Buttons -->
                <div class="mt-8 flex flex-col sm:flex-row gap-4 justify-center">
                    <?php if ($attendanceInfo['checked_in_at'] && !$attendanceInfo['checked_out_at']): ?>
                        <form method="POST" class="inline-block" onsubmit="return confirm('Are you sure you want to check out? This action cannot be undone.');">
                            <input type="hidden" name="action" value="checkout">
                            <input type="hidden" name="registration_code" value="<?php echo htmlspecialchars($attendanceInfo['registration_code']); ?>">
                            <button type="submit" class="bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-700 hover:to-orange-700 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
                                <i class="fas fa-sign-out-alt mr-2"></i>Check Out Now
                            </button>
                        </form>
                        
                    <?php elseif (!$attendanceInfo['checked_in_at']): ?>
                        <a href="check-in.php" class="bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-1 text-center">
                            <i class="fas fa-sign-in-alt mr-2"></i>Check In Now
                        </a>
                    <?php endif; ?>
                    
                    <a href="attendance-status.php" class="bg-gradient-to-r from-slate-600 to-slate-700 hover:from-slate-700 hover:to-slate-800 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-1 text-center">
                        <i class="fas fa-search mr-2"></i>Check Another Code
                    </a>
                </div>
            </div>
        </div>
        <?php endif; ?>
    </main>

    <!-- Footer -->
    <footer class="bg-slate-800 text-white py-8 mt-16">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
            <p class="text-slate-300">
                © <?php echo date('Y'); ?> The Church of Pentecost - Madina Area. All rights reserved.
            </p>
        </div>
    </footer>
</body>
</html>

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