Sindbad~EG File Manager
<?php
require_once '../../config/config.php';
require_once '../../classes/DirectoryManager.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header('Location: ../../login.php');
exit;
}
$page_title = "Members Directory";
$directoryManager = new DirectoryManager();
// Handle search
$search = $_GET['search'] ?? '';
$members = [];
if (!empty($search)) {
$members = $directoryManager->searchMembers($search);
}
include '../../includes/header.php';
include '../../includes/sidebar.php';
?>
<!-- Main Content -->
<main class="main-content md:ml-64 pt-16">
<div class="min-h-screen bg-gray-50 py-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<!-- Header Section -->
<div class="mb-8">
<div class="gradient-bg rounded-xl shadow-lg p-8 text-white">
<div class="flex flex-col md:flex-row md:items-center md:justify-between">
<div>
<h1 class="text-3xl font-bold mb-2">Members Directory</h1>
<p class="text-blue-100">Search and view member information</p>
</div>
<div class="mt-4 md:mt-0 flex gap-3">
<a href="members-list.php" class="bg-white text-primary px-6 py-3 rounded-lg font-semibold hover:bg-blue-50 transition-all duration-300 shadow-md hover:shadow-lg inline-flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
</svg>
View All Members
</a>
<a href="standalone.php" class="bg-gradient-secondary text-white px-6 py-3 rounded-lg font-semibold hover:shadow-lg transition-all duration-300 inline-flex items-center">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
</svg>
Standalone Directory
</a>
</div>
</div>
</div>
</div>
<!-- Search Section -->
<div class="bg-white rounded-xl shadow-md p-6 mb-8">
<form method="GET" action="" class="space-y-4">
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">
<svg class="w-5 h-5 inline-block mr-2 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
Search Members
</label>
<div class="flex gap-3">
<input type="text"
name="search"
value="<?= htmlspecialchars($search) ?>"
placeholder="Enter name, phone, email, or member ID..."
class="flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
<button type="submit" class="btn-gradient px-8 py-3 rounded-lg font-semibold hover:shadow-lg transition-all duration-300">
<svg class="w-5 h-5 inline-block mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
Search
</button>
</div>
</div>
<?php if (!empty($search)): ?>
<div class="flex items-center justify-between bg-blue-50 border border-blue-200 rounded-lg p-3">
<span class="text-sm text-blue-800">
<strong><?= count($members) ?></strong> result(s) found for "<strong><?= htmlspecialchars($search) ?></strong>"
</span>
<a href="index.php" class="text-blue-600 hover:text-blue-800 text-sm font-semibold">Clear Search</a>
</div>
<?php endif; ?>
</form>
</div>
<!-- Search Results -->
<?php if (!empty($search)): ?>
<?php if (count($members) > 0): ?>
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="px-6 py-4 bg-gradient-primary text-white">
<h2 class="text-xl font-bold">Search Results</h2>
</div>
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50 border-b-2 border-gray-200">
<tr>
<th class="px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">Member ID</th>
<th class="px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">Full Name</th>
<th class="px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">Phone</th>
<th class="px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">Email</th>
<th class="px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider">Location</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<?php foreach ($members as $member): ?>
<tr class="hover:bg-gray-50 transition-colors duration-200">
<td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm font-mono font-semibold text-primary"><?= htmlspecialchars($member['membershipcard_id'] ?? 'N/A') ?></span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-semibold text-gray-900">
<?= htmlspecialchars(trim(($member['title'] ?? '') . ' ' . $member['first_name'] . ' ' . ($member['middle_name'] ?? '') . ' ' . $member['last_name'])) ?>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">
<?php if (!empty($member['phone'])): ?>
<a href="tel:<?= htmlspecialchars($member['phone']) ?>" class="text-primary hover:text-blue-800 inline-flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
</svg>
<?= htmlspecialchars($member['phone']) ?>
</a>
<?php else: ?>
<span class="text-gray-400">N/A</span>
<?php endif; ?>
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-900">
<?php if (!empty($member['email'])): ?>
<a href="mailto:<?= htmlspecialchars($member['email']) ?>" class="text-primary hover:text-blue-800 inline-flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
<?= htmlspecialchars($member['email']) ?>
</a>
<?php else: ?>
<span class="text-gray-400">N/A</span>
<?php endif; ?>
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-700">
<?php
$location = array_filter([
$member['assembly_name'] ?? null,
$member['district_name'] ?? null,
$member['area_name'] ?? null
]);
echo !empty($location) ? htmlspecialchars(implode(', ', $location)) : '<span class="text-gray-400">N/A</span>';
?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php else: ?>
<div class="bg-white rounded-xl shadow-md p-12 text-center">
<svg class="w-20 h-20 mx-auto text-gray-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
<h3 class="text-xl font-semibold text-gray-700 mb-2">No Results Found</h3>
<p class="text-gray-500">Try different search terms or check the full members list.</p>
<a href="members-list.php" class="mt-4 inline-block btn-gradient px-6 py-3 rounded-lg font-semibold hover:shadow-lg transition-all duration-300">
View All Members
</a>
</div>
<?php endif; ?>
<?php else: ?>
<!-- Instructions when no search -->
<div class="bg-white rounded-xl shadow-md p-12 text-center">
<div class="max-w-md mx-auto">
<svg class="w-24 h-24 mx-auto text-primary mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg>
<h3 class="text-2xl font-bold text-gray-800 mb-3">Search for Members</h3>
<p class="text-gray-600 mb-6">Use the search bar above to find members by name, phone, email, or member ID. You can also view the complete members list.</p>
<div class="flex gap-3 justify-center">
<a href="members-list.php" class="btn-gradient px-6 py-3 rounded-lg font-semibold hover:shadow-lg transition-all duration-300">
View All Members
</a>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</main>
<?php include '../../includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists