Sindbad~EG File Manager
<?php
require_once '../includes/functions.php';
// Check if user is logged in
if (!isLoggedIn()) {
header('Location: ' . BASE_URL . 'login.php');
exit();
}
$user = getCurrentUser();
$db = new CopMadinaDB();
$conn = $db->getConnection();
// Get areas based on user role and permissions
$whereClause = "WHERE a.status = 'active'";
$params = [];
if ($user['role'] === 'area_admin') {
$whereClause .= " AND a.id = ?";
$params[] = $user['area_id'];
}
$sql = "SELECT a.*,
(SELECT COUNT(*) FROM districts d WHERE d.area_id = a.id AND d.status = 'active') as district_count,
(SELECT COUNT(*) FROM assemblies ass WHERE ass.district_id IN (SELECT id FROM districts WHERE area_id = a.id) AND ass.status = 'active') as assembly_count,
(SELECT COUNT(*) FROM users u WHERE u.area_id = a.id AND u.status = 'active') as member_count,
(SELECT COUNT(*) FROM events e WHERE e.area_id = a.id AND e.status = 'active') as event_count
FROM areas a
$whereClause
ORDER BY a.name";
$areas = executeQuery($sql, $params)->fetchAll();
$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Areas - COP Madina Conference Management</title>
<script src="https://cdn.tailwindcss.com"></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%);
}
.sidebar-active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
</style>
</head>
<body class="bg-gray-100">
<div id="app" class="flex h-screen">
<?php include '../includes/public_sidebar.php'; ?>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden">
<div class="flex-1 overflow-y-auto">
<!-- Header -->
<header class="bg-white shadow-sm border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16">
<div class="flex items-center">
<a href="<?php echo BASE_URL; ?>" class="flex items-center">
<img src="<?php echo BASE_URL; ?>assets/images/logo.png" alt="COP Madina" class="h-10 w-10 rounded-full mr-3">
<div>
<h1 class="text-xl font-bold text-gray-900">Areas</h1>
<p class="text-xs text-gray-500">Church Areas</p>
</div>
</a>
</div>
<nav class="flex items-center space-x-4">
<a href="<?php echo BASE_URL; ?>" class="text-gray-600 hover:text-gray-900 transition-colors">
<i class="fas fa-home mr-1"></i>Home
</a>
<a href="<?php echo BASE_URL; ?>dashboard.php" class="text-gray-600 hover:text-gray-900 transition-colors">
<i class="fas fa-tachometer-alt mr-1"></i>Dashboard
</a>
<div class="relative">
<span class="text-gray-700 font-medium">
<?php echo htmlspecialchars($user['first_name'] . ' ' . $user['last_name']); ?>
</span>
</div>
<a href="<?php echo BASE_URL; ?>logout.php" class="text-red-600 hover:text-red-800 transition-colors">
<i class="fas fa-sign-out-alt"></i>
</a>
</nav>
</div>
</div>
</header>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Page Header -->
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Church Areas</h1>
<p class="mt-2 text-gray-600">Browse church areas and their organizational structure</p>
</div>
<!-- Areas Grid -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<?php foreach ($areas as $area): ?>
<div class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition-shadow">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
<i class="fas fa-globe text-blue-600 text-xl"></i>
</div>
<div>
<h3 class="text-xl font-bold text-gray-900">
<?php echo htmlspecialchars($area['name']); ?>
</h3>
<p class="text-sm text-gray-500">Church Area</p>
</div>
</div>
<?php if ($area['description']): ?>
<p class="text-gray-600 mb-4">
<?php echo htmlspecialchars($area['description']); ?>
</p>
<?php endif; ?>
<div class="space-y-2 mb-4">
<?php if (isset($area['address']) && $area['address']): ?>
<div class="flex items-center text-sm text-gray-500">
<i class="fas fa-map-marker-alt mr-2"></i>
<?php echo htmlspecialchars($area['address']); ?>
</div>
<?php endif; ?>
<?php if (isset($area['phone']) && $area['phone']): ?>
<div class="flex items-center text-sm text-gray-500">
<i class="fas fa-phone mr-2"></i>
<?php echo htmlspecialchars($area['phone']); ?>
</div>
<?php endif; ?>
<?php if (isset($area['email']) && $area['email']): ?>
<div class="flex items-center text-sm text-gray-500">
<i class="fas fa-envelope mr-2"></i>
<?php echo htmlspecialchars($area['email']); ?>
</div>
<?php endif; ?>
</div>
<div class="grid grid-cols-2 gap-4 pt-4 border-t border-gray-200">
<div class="text-center">
<div class="text-lg font-bold text-green-600"><?php echo $area['district_count']; ?></div>
<div class="text-xs text-gray-500">Districts</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-purple-600"><?php echo $area['assembly_count']; ?></div>
<div class="text-xs text-gray-500">Assemblies</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-primary-600"><?php echo $area['member_count']; ?></div>
<div class="text-xs text-gray-500">Members</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-yellow-600"><?php echo $area['event_count']; ?></div>
<div class="text-xs text-gray-500">Events</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if (empty($areas)): ?>
<div class="text-center py-12">
<i class="fas fa-globe text-gray-400 text-6xl mb-4"></i>
<h3 class="text-xl font-semibold text-gray-900 mb-2">No Areas Found</h3>
<p class="text-gray-600">There are currently no areas available to display.</p>
</div>
<?php endif; ?>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists