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();
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
if ($action === 'update_status') {
$id = $_POST['id'];
$status = $_POST['status'];
$stmt = executeQuery("UPDATE nonmember_registrations SET status = ? WHERE id = ?", [$status, $id]);
if ($stmt) {
logAudit('update', 'nonmember_registrations', $id);
addNotification($_SESSION['user_id'], 'Non-Member Status Updated', "Non-member status changed to {$status}", 'success');
}
} elseif ($action === 'delete') {
$id = $_POST['id'];
$stmt = executeQuery("DELETE FROM nonmember_registrations WHERE id = ?", [$id]);
if ($stmt) {
logAudit('delete', 'nonmember_registrations', $id);
addNotification($_SESSION['user_id'], 'Non-Member Deleted', 'Non-member has been removed from the system', 'info');
}
}
header('Location: non-members.php');
exit();
}
// Get non-members based on role
$nonmembers_query = "SELECT nr.*, e.title as event_title, a.name as area_name, d.name as district_name, ass.name as assembly_name
FROM nonmember_registrations nr
LEFT JOIN events e ON nr.event_id = e.id
LEFT JOIN areas a ON e.area_id = a.id
LEFT JOIN districts d ON e.district_id = d.id
LEFT JOIN assemblies ass ON e.assembly_id = ass.id";
$params = [];
if ($user['role'] === 'area_admin') {
$nonmembers_query .= " WHERE e.area_id = ?";
$params = [$user['area_id']];
} elseif ($user['role'] === 'district_admin') {
$nonmembers_query .= " WHERE e.district_id = ?";
$params = [$user['district_id']];
} elseif ($user['role'] === 'assembly_admin') {
$nonmembers_query .= " WHERE e.assembly_id = ?";
$params = [$user['assembly_id']];
}
$nonmembers_query .= " ORDER BY nr.created_at DESC";
$stmt = executeQuery($nonmembers_query, $params);
$nonmembers = $stmt ? $stmt->fetchAll() : [];
// Get statistics
$stats = [
'total' => count($nonmembers),
'active' => count(array_filter($nonmembers, fn($nm) => $nm['status'] === 'confirmed')),
'new_this_month' => count(array_filter($nonmembers, fn($nm) => date('Y-m', strtotime($nm['created_at'])) === date('Y-m'))),
'total_revenue' => array_sum(array_column($nonmembers, 'amount_paid'))
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Non-Members Management - COP Madina Conference</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 src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body class="bg-gradient-to-br from-slate-50 to-blue-50 min-h-screen">
<div id="app" class="flex h-screen">
<!-- Sidebar -->
<?php include 'includes/admin_sidebar.php'; ?>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden ml-72">
<!-- Header -->
<?php include 'includes/admin_header.php'; ?>
<!-- Content -->
<main class="flex-1 overflow-y-auto p-8">
<!-- Statistics Cards -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
<div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-lg border border-slate-200/50 p-6">
<div class="flex items-center">
<div class="p-3 rounded-xl bg-gradient-to-br from-orange-500 to-orange-600 mr-4">
<i class="fas fa-user-friends text-white text-xl"></i>
</div>
<div>
<p class="text-sm font-medium text-slate-600">Total Non-Members</p>
<p class="text-2xl font-bold text-slate-800"><?php echo $stats['total']; ?></p>
</div>
</div>
</div>
<div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-lg border border-slate-200/50 p-6">
<div class="flex items-center">
<div class="p-3 rounded-xl bg-gradient-to-br from-green-500 to-green-600 mr-4">
<i class="fas fa-check-circle text-white text-xl"></i>
</div>
<div>
<p class="text-sm font-medium text-slate-600">Confirmed</p>
<p class="text-2xl font-bold text-slate-800"><?php echo $stats['active']; ?></p>
</div>
</div>
</div>
<div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-lg border border-slate-200/50 p-6">
<div class="flex items-center">
<div class="p-3 rounded-xl bg-gradient-to-br from-purple-500 to-purple-600 mr-4">
<i class="fas fa-calendar-plus text-white text-xl"></i>
</div>
<div>
<p class="text-sm font-medium text-slate-600">New This Month</p>
<p class="text-2xl font-bold text-slate-800"><?php echo $stats['new_this_month']; ?></p>
</div>
</div>
</div>
<div class="bg-white/70 backdrop-blur-sm rounded-2xl shadow-lg border border-slate-200/50 p-6">
<div class="flex items-center">
<div class="p-3 rounded-xl bg-gradient-to-br from-blue-500 to-blue-600 mr-4">
<i class="fas fa-dollar-sign text-white text-xl"></i>
</div>
<div>
<p class="text-sm font-medium text-slate-600">Total Revenue</p>
<p class="text-2xl font-bold text-slate-800">₵<?php echo number_format($stats['total_revenue'], 2); ?></p>
</div>
</div>
</div>
</div>
<!-- Non-Members Table -->
<div class="bg-white/80 backdrop-blur-sm rounded-2xl shadow-xl border border-slate-200/50 overflow-hidden">
<div class="px-6 py-4 border-b border-slate-200/50">
<h2 class="text-xl font-bold text-slate-800 flex items-center">
<i class="fas fa-user-friends text-orange-600 mr-2"></i>
Non-Members Registration Records
</h2>
</div>
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-slate-50/50">
<tr>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Registration Code</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Contact</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Event</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Location</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Amount</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Date</th>
<th class="px-6 py-4 text-left text-xs font-medium text-slate-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-200/50">
<?php foreach ($nonmembers as $nonmember): ?>
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm font-medium text-slate-900"><?php echo htmlspecialchars($nonmember['registration_code'] ?? 'N/A'); ?></span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="w-8 h-8 rounded-full bg-gradient-to-br from-orange-500 to-red-500 flex items-center justify-center mr-3">
<span class="text-white font-semibold text-xs">
<?php echo strtoupper(substr($nonmember['first_name'], 0, 1) . substr($nonmember['last_name'], 0, 1)); ?>
</span>
</div>
<div>
<div class="text-sm font-medium text-slate-900">
<?php echo htmlspecialchars($nonmember['first_name'] . ' ' . $nonmember['last_name']); ?>
</div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-slate-900"><?php echo htmlspecialchars($nonmember['email']); ?></div>
<div class="text-sm text-slate-500"><?php echo htmlspecialchars($nonmember['phone']); ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-slate-900"><?php echo htmlspecialchars($nonmember['event_title'] ?? 'N/A'); ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-slate-900"><?php echo htmlspecialchars($nonmember['area_name'] ?? 'N/A'); ?></div>
<div class="text-sm text-slate-500"><?php echo htmlspecialchars($nonmember['district_name'] ?? 'N/A'); ?></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm font-medium text-slate-900">₵<?php echo number_format($nonmember['amount_paid'] ?? 0, 2); ?></span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full
<?php
switch($nonmember['status']) {
case 'confirmed':
echo 'bg-green-100 text-green-800';
break;
case 'pending':
echo 'bg-yellow-100 text-yellow-800';
break;
case 'cancelled':
echo 'bg-red-100 text-red-800';
break;
default:
echo 'bg-gray-100 text-gray-800';
}
?>">
<?php echo ucfirst($nonmember['status'] ?? 'pending'); ?>
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-slate-500">
<?php echo date('M j, Y', strtotime($nonmember['created_at'])); ?>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="flex space-x-2">
<button @click="editNonMember(<?php echo htmlspecialchars(json_encode($nonmember)); ?>)"
class="text-blue-600 hover:text-blue-900 transition-colors">
<i class="fas fa-edit"></i>
</button>
<button @click="deleteNonMember(<?php echo $nonmember['id']; ?>)"
class="text-red-600 hover:text-red-900 transition-colors">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- Edit Modal -->
<div v-if="showEditModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md mx-4">
<div class="px-6 py-4 border-b border-slate-200">
<h3 class="text-lg font-semibold text-slate-800">Edit Non-Member Status</h3>
</div>
<form @submit.prevent="updateStatus" class="p-6">
<div class="mb-4">
<label class="block text-sm font-medium text-slate-700 mb-2">Status</label>
<select v-model="newStatus" required
class="w-full px-3 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="pending">Pending</option>
<option value="confirmed">Confirmed</option>
<option value="cancelled">Cancelled</option>
</select>
</div>
<div class="flex justify-end space-x-3">
<button type="button" @click="showEditModal = false"
class="px-4 py-2 text-slate-600 hover:text-slate-800 transition-colors">
Cancel
</button>
<button type="submit"
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">
Update Status
</button>
</div>
</form>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div v-if="showDeleteModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md mx-4">
<div class="px-6 py-4 border-b border-slate-200">
<h3 class="text-lg font-semibold text-slate-800">Confirm Delete</h3>
</div>
<div class="p-6">
<p class="text-slate-600 mb-6">Are you sure you want to delete this non-member record? This action cannot be undone.</p>
<div class="flex justify-end space-x-3">
<button @click="showDeleteModal = false"
class="px-4 py-2 text-slate-600 hover:text-slate-800 transition-colors">
Cancel
</button>
<button @click="confirmDelete"
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors">
Delete
</button>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
showEditModal: false,
showDeleteModal: false,
selectedNonMember: null,
newStatus: '',
deleteId: null
}
},
methods: {
editNonMember(nonmember) {
this.selectedNonMember = nonmember;
this.newStatus = nonmember.status;
this.showEditModal = true;
},
deleteNonMember(id) {
this.deleteId = id;
this.showDeleteModal = true;
},
updateStatus() {
const form = document.createElement('form');
form.method = 'POST';
form.innerHTML = `
<input type="hidden" name="action" value="update_status">
<input type="hidden" name="id" value="${this.selectedNonMember.id}">
<input type="hidden" name="status" value="${this.newStatus}">
`;
document.body.appendChild(form);
form.submit();
},
confirmDelete() {
const form = document.createElement('form');
form.method = 'POST';
form.innerHTML = `
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="${this.deleteId}">
`;
document.body.appendChild(form);
form.submit();
}
}
}).mount('#app');
</script>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists