Sindbad~EG File Manager
<?php
require_once 'config/config.php';
$pageTitle = "Guest Lookup - " . APP_NAME;
$db = Database::getInstance()->getConnection();
$stmt = $db->query("SELECT * FROM general_settings ORDER BY id DESC LIMIT 1");
$settings = $stmt->fetch();
$settings = array_merge([
'site_title' => 'Church Membership System',
'theme_primary_color' => '#1E40AF',
'theme_secondary_color' => '#F97316',
], $settings ?: []);
$error = '';
$guestData = null;
$attendanceHistory = [];
// Check for code in URL or form submission
$visitorCode = $_GET['code'] ?? $_POST['visitor_code'] ?? '';
if (!empty($visitorCode)) {
$visitorCode = strtoupper(trim($visitorCode));
try {
// Look up guest by visitor code
$stmt = $db->prepare("
SELECT gv.*, ar.area_name, d.district_name, a.assembly_name, p.program_name
FROM guest_visitors gv
LEFT JOIN areas ar ON gv.area_id = ar.id
LEFT JOIN districts d ON gv.district_id = d.id
LEFT JOIN assemblies a ON gv.assembly_id = a.id
LEFT JOIN programs p ON gv.program_id = p.id
WHERE gv.visitor_code = :code
");
$stmt->execute(['code' => $visitorCode]);
$guestData = $stmt->fetch();
if (!$guestData) {
$error = "No record found for this visitor code. Please check and try again.";
} else {
// Get attendance history (all visits with this code)
$historyStmt = $db->prepare("
SELECT gv.*, ar.area_name, d.district_name, a.assembly_name, p.program_name
FROM guest_visitors gv
LEFT JOIN areas ar ON gv.area_id = ar.id
LEFT JOIN districts d ON gv.district_id = d.id
LEFT JOIN assemblies a ON gv.assembly_id = a.id
LEFT JOIN programs p ON gv.program_id = p.id
WHERE gv.visitor_code = :code
ORDER BY gv.check_in_time DESC
");
$historyStmt->execute(['code' => $visitorCode]);
$attendanceHistory = $historyStmt->fetchAll();
}
} catch (Exception $e) {
$error = "Error looking up your details. Please try again.";
}
}
?>
<!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, #F97316 0%, #FBBF24 50%, #F59E0B 100%); }
.text-gradient { background: linear-gradient(135deg, #F97316 0%, #FBBF24 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.btn-gradient { background: linear-gradient(135deg, #F97316 0%, #FBBF24 100%); }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.animate-fadeIn { animation: fadeInUp 0.5s ease-out; }
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- 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">
<div class="flex items-center space-x-3">
<div class="w-12 h-12 rounded-xl flex items-center justify-center hero-gradient">
<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>
<p class="text-xs text-gray-500">Guest Lookup</p>
</div>
</div>
<nav class="flex items-center space-x-4">
<a href="attendance.php" class="text-gray-700 hover:text-orange-600 font-medium transition">
<i class="fas fa-clipboard-check mr-1"></i><span class="hidden sm:inline">Attendance</span>
</a>
<a href="index.php" class="text-gray-700 hover:text-blue-700 font-medium transition">
<i class="fas fa-home mr-1"></i><span class="hidden sm:inline">Home</span>
</a>
</nav>
</div>
</div>
</header>
<!-- Hero Section -->
<section class="hero-gradient text-white py-8">
<div class="container mx-auto px-4 text-center">
<i class="fas fa-search text-5xl mb-3 opacity-90"></i>
<h1 class="text-3xl font-bold mb-2">Guest Details Lookup</h1>
<p class="text-white/90">Enter your visitor code to view your submitted details</p>
</div>
</section>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<div class="max-w-2xl mx-auto">
<?php if ($error): ?>
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded mb-6 animate-fadeIn">
<p class="font-bold"><i class="fas fa-exclamation-circle mr-2"></i>Not Found</p>
<p><?php echo htmlspecialchars($error); ?></p>
</div>
<?php endif; ?>
<?php if (!$guestData): ?>
<!-- Search Form -->
<div class="bg-white rounded-xl shadow-lg p-8 animate-fadeIn">
<div class="text-center mb-6">
<div class="w-20 h-20 mx-auto mb-4 rounded-full bg-orange-100 flex items-center justify-center">
<i class="fas fa-id-card text-3xl text-orange-500"></i>
</div>
<h2 class="text-2xl font-bold text-gray-800">Enter Your Visitor Code</h2>
<p class="text-gray-600">The code was sent to you via email or SMS when you registered</p>
</div>
<form method="POST" class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Visitor Code</label>
<input type="text" name="visitor_code" required autofocus
placeholder="e.g., VIS2026123456"
value="<?php echo htmlspecialchars($visitorCode); ?>"
class="w-full px-4 py-4 text-xl border border-gray-300 rounded-lg focus:ring-2 focus:ring-orange-500 focus:border-transparent text-center uppercase"
style="letter-spacing: 3px;">
</div>
<button type="submit" class="w-full py-4 btn-gradient text-white rounded-lg font-bold text-lg transition hover:shadow-lg">
<i class="fas fa-search mr-2"></i>Look Up My Details
</button>
</form>
<div class="mt-6 text-center">
<p class="text-gray-500 text-sm">Don't have a code?</p>
<a href="guest-checkin.php" class="text-orange-600 hover:text-orange-800 font-medium">
<i class="fas fa-user-plus mr-1"></i>Register as a Guest/Visitor
</a>
</div>
</div>
<?php else: ?>
<!-- Guest Details Display -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden animate-fadeIn">
<!-- Header -->
<div class="bg-gradient-to-r from-orange-500 to-yellow-500 text-white p-6">
<div class="flex items-center space-x-4">
<div class="w-16 h-16 rounded-full bg-white/20 flex items-center justify-center">
<i class="fas fa-user text-2xl"></i>
</div>
<div>
<h2 class="text-2xl font-bold"><?php echo htmlspecialchars($guestData['full_name']); ?></h2>
<p class="text-white/80">
<i class="fas fa-tag mr-1"></i><?php echo ucfirst($guestData['visitor_type']); ?>
</p>
</div>
</div>
</div>
<div class="p-6">
<!-- Visitor Code -->
<div class="bg-orange-50 border border-orange-200 rounded-lg p-4 text-center mb-6">
<p class="text-sm text-gray-600 mb-1">Your Visitor Code</p>
<p class="text-2xl font-bold text-orange-600 tracking-widest"><?php echo htmlspecialchars($guestData['visitor_code']); ?></p>
</div>
<!-- Details Grid -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
<?php if ($guestData['phone']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Phone</p>
<p class="font-medium text-gray-800">
<i class="fas fa-phone mr-2 text-green-500"></i><?php echo htmlspecialchars($guestData['phone']); ?>
</p>
</div>
<?php endif; ?>
<?php if ($guestData['email']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Email</p>
<p class="font-medium text-gray-800">
<i class="fas fa-envelope mr-2 text-blue-500"></i><?php echo htmlspecialchars($guestData['email']); ?>
</p>
</div>
<?php endif; ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">First Check-in</p>
<p class="font-medium text-gray-800">
<i class="fas fa-calendar mr-2 text-purple-500"></i><?php echo date('F j, Y', strtotime($guestData['check_in_time'])); ?>
</p>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Check-in Time</p>
<p class="font-medium text-gray-800">
<i class="fas fa-clock mr-2 text-orange-500"></i><?php echo date('g:i A', strtotime($guestData['check_in_time'])); ?>
</p>
</div>
<?php if ($guestData['area_name']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Area</p>
<p class="font-medium text-gray-800">
<i class="fas fa-map-marker-alt mr-2 text-red-500"></i><?php echo htmlspecialchars($guestData['area_name']); ?>
</p>
</div>
<?php endif; ?>
<?php if ($guestData['district_name']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">District</p>
<p class="font-medium text-gray-800">
<i class="fas fa-building mr-2 text-blue-600"></i><?php echo htmlspecialchars($guestData['district_name']); ?>
</p>
</div>
<?php endif; ?>
<?php if ($guestData['assembly_name']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Assembly</p>
<p class="font-medium text-gray-800">
<i class="fas fa-church mr-2 text-indigo-500"></i><?php echo htmlspecialchars($guestData['assembly_name']); ?>
</p>
</div>
<?php endif; ?>
<?php if ($guestData['program_name']): ?>
<div class="bg-gray-50 rounded-lg p-4">
<p class="text-xs text-gray-500 uppercase mb-1">Program</p>
<p class="font-medium text-gray-800">
<i class="fas fa-calendar-alt mr-2 text-teal-500"></i><?php echo htmlspecialchars($guestData['program_name']); ?>
</p>
</div>
<?php endif; ?>
</div>
<?php if ($guestData['purpose_of_visit']): ?>
<div class="bg-gray-50 rounded-lg p-4 mb-6">
<p class="text-xs text-gray-500 uppercase mb-1">Purpose of Visit</p>
<p class="text-gray-800"><?php echo nl2br(htmlspecialchars($guestData['purpose_of_visit'])); ?></p>
</div>
<?php endif; ?>
<!-- Notification Status -->
<div class="flex flex-wrap gap-2 mb-6">
<?php if ($guestData['email_sent']): ?>
<span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm">
<i class="fas fa-check-circle mr-1"></i>Email notification sent
</span>
<?php endif; ?>
<?php if ($guestData['sms_sent']): ?>
<span class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm">
<i class="fas fa-check-circle mr-1"></i>SMS notification sent
</span>
<?php endif; ?>
</div>
<!-- Actions -->
<div class="flex flex-col sm:flex-row gap-3">
<a href="guest-lookup.php" class="flex-1 text-center py-3 bg-gray-200 text-gray-700 rounded-lg font-semibold hover:bg-gray-300">
<i class="fas fa-search mr-2"></i>New Search
</a>
<a href="attendance.php" class="flex-1 text-center py-3 btn-gradient text-white rounded-lg font-semibold">
<i class="fas fa-clipboard-check mr-2"></i>Back to Attendance
</a>
</div>
</div>
</div>
<!-- Thank You Message -->
<div class="mt-6 bg-gradient-to-r from-green-50 to-emerald-50 border border-green-200 rounded-xl p-6 text-center">
<i class="fas fa-heart text-4xl text-red-400 mb-3"></i>
<h3 class="text-xl font-bold text-gray-800 mb-2">Thank You for Visiting!</h3>
<p class="text-gray-600">
We're glad you joined us. We hope to see you again soon!<br>
Keep your visitor code safe - you can use it to check in faster on your next visit.
</p>
</div>
<?php endif; ?>
</div>
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-6 mt-auto">
<div class="container mx-auto px-4 text-center">
<p class="text-gray-400 text-sm">
© <?php echo date('Y'); ?> <?php echo htmlspecialchars($settings['site_title']); ?>
</p>
</div>
</footer>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists