Sindbad~EG File Manager
<?php
require_once '../includes/functions.php';
// Check if user is logged in and has admin privileges
if (!isLoggedIn()) {
header('Location: ' . BASE_URL . 'login.php');
exit();
}
$user = getCurrentUser();
if (!in_array($user['role'], ['superuser', 'area_admin', 'district_admin', 'assembly_admin'])) {
header('Location: ' . BASE_URL . 'dashboard.php');
exit();
}
$db = new CopMadinaDB();
$conn = $db->getConnection();
// Get report data based on user role
$reportData = [];
if ($user['role'] === 'superuser') {
// Superuser can see all reports
$reportData['total_events'] = executeQuery("SELECT COUNT(*) as count FROM events")->fetch()['count'];
$reportData['active_events'] = executeQuery("SELECT COUNT(*) as count FROM events WHERE status = 'active'")->fetch()['count'];
$reportData['total_registrations'] = executeQuery("SELECT COUNT(*) as count FROM event_registrations")->fetch()['count'];
$reportData['total_revenue'] = executeQuery("SELECT SUM(amount_paid) as total FROM event_registrations WHERE payment_status = 'paid'")->fetch()['total'] ?: 0;
$reportData['total_users'] = executeQuery("SELECT COUNT(*) as count FROM users WHERE status = 'active'")->fetch()['count'];
$reportData['total_areas'] = executeQuery("SELECT COUNT(*) as count FROM areas WHERE status = 'active'")->fetch()['count'];
$reportData['total_districts'] = executeQuery("SELECT COUNT(*) as count FROM districts WHERE status = 'active'")->fetch()['count'];
$reportData['total_assemblies'] = executeQuery("SELECT COUNT(*) as count FROM assemblies WHERE status = 'active'")->fetch()['count'];
} elseif ($user['role'] === 'area_admin') {
$areaId = $user['area_id'];
$reportData['area_events'] = executeQuery("SELECT COUNT(*) as count FROM events WHERE area_id = ?", [$areaId])->fetch()['count'];
$reportData['area_registrations'] = executeQuery("SELECT COUNT(*) as count FROM event_registrations er JOIN events e ON er.event_id = e.id WHERE e.area_id = ?", [$areaId])->fetch()['count'];
$reportData['area_revenue'] = executeQuery("SELECT SUM(er.amount_paid) as total FROM event_registrations er JOIN events e ON er.event_id = e.id WHERE e.area_id = ? AND er.payment_status = 'paid'", [$areaId])->fetch()['total'] ?: 0;
$reportData['area_users'] = executeQuery("SELECT COUNT(*) as count FROM users WHERE area_id = ? AND status = 'active'", [$areaId])->fetch()['count'];
}
$settings = getSettings();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reports - COP Madina Conference Management</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.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>
</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">Reports & Analytics</h1>
<p class="text-xs text-gray-500">System Reports</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; ?>admin/" class="text-gray-600 hover:text-gray-900 transition-colors">
<i class="fas fa-arrow-left mr-1"></i>Admin
</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">Reports & Analytics</h1>
<p class="mt-2 text-gray-600">System performance and statistics overview</p>
</div>
<!-- Key Metrics -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<?php if (isset($reportData['total_events'])): ?>
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex items-center">
<div class="p-3 bg-blue-100 rounded-full">
<i class="fas fa-calendar-alt text-blue-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-gray-600 text-sm">Total Events</p>
<p class="text-2xl font-bold text-gray-900"><?php echo $reportData['total_events']; ?></p>
<p class="text-xs text-green-600"><?php echo $reportData['active_events']; ?> active</p>
</div>
</div>
</div>
<?php endif; ?>
<?php if (isset($reportData['total_registrations']) || isset($reportData['area_registrations'])): ?>
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex items-center">
<div class="p-3 bg-green-100 rounded-full">
<i class="fas fa-ticket-alt text-green-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-gray-600 text-sm">Registrations</p>
<p class="text-2xl font-bold text-gray-900">
<?php echo $reportData['total_registrations'] ?? $reportData['area_registrations']; ?>
</p>
</div>
</div>
</div>
<?php endif; ?>
<?php if (isset($reportData['total_revenue']) || isset($reportData['area_revenue'])): ?>
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex items-center">
<div class="p-3 bg-yellow-100 rounded-full">
<i class="fas fa-dollar-sign text-yellow-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-gray-600 text-sm">Revenue</p>
<p class="text-2xl font-bold text-gray-900">
GH₵<?php echo number_format($reportData['total_revenue'] ?? $reportData['area_revenue'], 2); ?>
</p>
</div>
</div>
</div>
<?php endif; ?>
<?php if (isset($reportData['total_users']) || isset($reportData['area_users'])): ?>
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex items-center">
<div class="p-3 bg-purple-100 rounded-full">
<i class="fas fa-users text-purple-600 text-xl"></i>
</div>
<div class="ml-4">
<p class="text-gray-600 text-sm">Active Users</p>
<p class="text-2xl font-bold text-gray-900">
<?php echo $reportData['total_users'] ?? $reportData['area_users']; ?>
</p>
</div>
</div>
</div>
<?php endif; ?>
</div>
<!-- Organization Structure (Superuser only) -->
<?php if ($user['role'] === 'superuser'): ?>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
<i class="fas fa-globe text-blue-600 mr-2"></i>Areas
</h3>
<div class="text-3xl font-bold text-blue-600"><?php echo $reportData['total_areas']; ?></div>
<p class="text-sm text-gray-500 mt-2">Active church areas</p>
</div>
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
<i class="fas fa-map text-green-600 mr-2"></i>Districts
</h3>
<div class="text-3xl font-bold text-green-600"><?php echo $reportData['total_districts']; ?></div>
<p class="text-sm text-gray-500 mt-2">Active districts</p>
</div>
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
<i class="fas fa-church text-purple-600 mr-2"></i>Assemblies
</h3>
<div class="text-3xl font-bold text-purple-600"><?php echo $reportData['total_assemblies']; ?></div>
<p class="text-sm text-gray-500 mt-2">Active assemblies</p>
</div>
</div>
<?php endif; ?>
<!-- Report Actions -->
<div class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-xl font-bold text-gray-900 mb-6">Generate Reports</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<button class="bg-blue-50 hover:bg-blue-100 border border-blue-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-calendar-alt text-blue-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Event Report</h3>
<p class="text-sm text-gray-600">Detailed event statistics</p>
</div>
</div>
</button>
<button class="bg-green-50 hover:bg-green-100 border border-green-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-ticket-alt text-green-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Registration Report</h3>
<p class="text-sm text-gray-600">Registration analytics</p>
</div>
</div>
</button>
<button class="bg-yellow-50 hover:bg-yellow-100 border border-yellow-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-dollar-sign text-yellow-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Financial Report</h3>
<p class="text-sm text-gray-600">Revenue and payments</p>
</div>
</div>
</button>
<button class="bg-purple-50 hover:bg-purple-100 border border-purple-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-users text-purple-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Member Report</h3>
<p class="text-sm text-gray-600">Membership statistics</p>
</div>
</div>
</button>
<button class="bg-red-50 hover:bg-red-100 border border-red-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-chart-line text-red-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Growth Report</h3>
<p class="text-sm text-gray-600">Trends and growth</p>
</div>
</div>
</button>
<button class="bg-gray-50 hover:bg-gray-100 border border-gray-200 rounded-lg p-4 text-left transition-colors">
<div class="flex items-center">
<i class="fas fa-download text-gray-600 text-xl mr-3"></i>
<div>
<h3 class="font-semibold text-gray-900">Export Data</h3>
<p class="text-sm text-gray-600">Download CSV/PDF reports</p>
</div>
</div>
</button>
</div>
</div>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists