Sindbad~EG File Manager
<?php
require_once '../../config/config.php';
checkLogin();
$pageTitle = "View Member - " . APP_NAME;
$db = Database::getInstance()->getConnection();
// Get member ID
if (!isset($_GET['id']) || empty($_GET['id'])) {
redirect('index.php');
}
$memberId = (int)$_GET['id'];
// Get member details
try {
// Check if membershipcard_id column exists
$columnExists = false;
try {
$checkStmt = $db->query("SHOW COLUMNS FROM members LIKE 'membershipcard_id'");
$columnExists = $checkStmt->fetch() !== false;
} catch (PDOException $e) {
// Column doesn't exist
}
$memberIdField = $columnExists ? 'm.membershipcard_id' : 'CONCAT("MC", YEAR(CURDATE()), LPAD(m.id, 6, "0")) as membershipcard_id';
$stmt = $db->prepare("
SELECT m.*, {$memberIdField},
a.area_name, d.district_name, asm.assembly_name,
u.full_name as created_by_name
FROM members m
JOIN areas a ON m.area_id = a.id
JOIN districts d ON m.district_id = d.id
JOIN assemblies asm ON m.assembly_id = asm.id
LEFT JOIN users u ON m.created_by = u.id
WHERE m.id = :id
");
$stmt->execute(['id' => $memberId]);
$member = $stmt->fetch();
if (!$member) {
redirect('index.php');
}
// Get membership card details if exists
$membershipCard = null;
try {
$cardStmt = $db->prepare("SELECT * FROM membership_cards WHERE member_id = :member_id AND is_active = 1");
$cardStmt->execute(['member_id' => $memberId]);
$membershipCard = $cardStmt->fetch();
} catch (PDOException $e) {
// Membership cards table might not exist
}
} catch (PDOException $e) {
$error = "Error loading member: " . $e->getMessage();
redirect('index.php');
}
include '../../includes/header.php';
?>
<?php include '../../includes/sidebar.php'; ?>
<!-- Main Content -->
<main class="flex-1 md:ml-64 mt-16">
<div class="container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<!-- Header -->
<div class="flex justify-between items-center mb-6">
<div>
<h1 class="text-3xl font-bold text-gray-800">
<i class="fas fa-user mr-2 text-blue-500"></i>Member Profile
</h1>
<p class="text-gray-600 mt-2">View member details and information</p>
</div>
<div class="flex space-x-3">
<a href="edit.php?id=<?php echo $member['id']; ?>"
class="bg-yellow-500 text-white px-4 py-2 rounded-lg hover:bg-yellow-600 transition">
<i class="fas fa-edit mr-2"></i>Edit Member
</a>
<a href="index.php"
class="bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition">
<i class="fas fa-arrow-left mr-2"></i>Back to List
</a>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Main Profile Card -->
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Profile Header -->
<div class="bg-gradient-to-r from-blue-500 to-blue-600 p-6 text-white">
<div class="flex items-center space-x-4">
<img src="<?php echo !empty($member['profile_photo']) ? BASE_URL . 'uploads/members/' . $member['profile_photo'] : BASE_URL . 'assets/images/default-avatar.png'; ?>"
alt="<?php echo htmlspecialchars($member['first_name']); ?>"
class="w-20 h-20 rounded-full object-cover border-4 border-white shadow-lg">
<div>
<h2 class="text-2xl font-bold">
<?php echo htmlspecialchars(($member['title'] ?? '') . ' ' . $member['first_name'] . ' ' . ($member['middle_name'] ?? '') . ' ' . $member['last_name']); ?>
</h2>
<p class="text-blue-100 text-lg"><?php echo htmlspecialchars($member['member_type'] ?? 'Member'); ?></p>
<p class="text-blue-200 text-sm">
<i class="fas fa-id-card mr-1"></i>
ID: <?php echo htmlspecialchars($member['membershipcard_id'] ?? 'N/A'); ?>
</p>
</div>
</div>
</div>
<!-- Basic Information -->
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-4 border-b pb-2">
<i class="fas fa-info-circle mr-2 text-blue-500"></i>Basic Information
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-600">Gender</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['gender'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Date of Birth</label>
<p class="text-gray-800"><?php echo $member['date_of_birth'] ? date('F j, Y', strtotime($member['date_of_birth'])) : 'N/A'; ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Place of Birth</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['place_of_birth'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Marital Status</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['marital_status'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Phone</label>
<p class="text-gray-800">
<?php if (!empty($member['phone'])): ?>
<a href="tel:<?php echo $member['phone']; ?>" class="text-blue-600 hover:underline">
<i class="fas fa-phone mr-1"></i><?php echo htmlspecialchars($member['phone']); ?>
</a>
<?php else: ?>
N/A
<?php endif; ?>
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Email</label>
<p class="text-gray-800">
<?php if (!empty($member['email'])): ?>
<a href="mailto:<?php echo $member['email']; ?>" class="text-blue-600 hover:underline">
<i class="fas fa-envelope mr-1"></i><?php echo htmlspecialchars($member['email']); ?>
</a>
<?php else: ?>
N/A
<?php endif; ?>
</p>
</div>
</div>
</div>
<!-- Address Information -->
<div class="p-6 border-t">
<h3 class="text-lg font-semibold text-gray-800 mb-4">
<i class="fas fa-map-marker-alt mr-2 text-blue-500"></i>Address Information
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-600">Address</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['address_line1'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">GPS Address</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['gps_address'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Street Name</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['street_name'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">City</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['city'] ?? 'N/A'); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Hometown</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['hometown'] ?? 'N/A'); ?></p>
</div>
</div>
</div>
<!-- Spiritual Information -->
<div class="p-6 border-t">
<h3 class="text-lg font-semibold text-gray-800 mb-4">
<i class="fas fa-cross mr-2 text-blue-500"></i>Spiritual Information
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-600">Water Baptism</label>
<p class="text-gray-800">
<?php if ($member['water_baptism'] ?? 0): ?>
<span class="text-green-600"><i class="fas fa-check mr-1"></i>Yes</span>
<?php if ($member['date_of_baptism']): ?>
<br><small class="text-gray-500">Date: <?php echo date('F j, Y', strtotime($member['date_of_baptism'])); ?></small>
<?php endif; ?>
<?php else: ?>
<span class="text-red-600"><i class="fas fa-times mr-1"></i>No</span>
<?php endif; ?>
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Holy Ghost Baptism</label>
<p class="text-gray-800">
<?php if ($member['holyghost_baptism'] ?? 0): ?>
<span class="text-green-600"><i class="fas fa-check mr-1"></i>Yes</span>
<?php if ($member['date_of_holyspirit_baptism']): ?>
<br><small class="text-gray-500">Date: <?php echo date('F j, Y', strtotime($member['date_of_holyspirit_baptism'])); ?></small>
<?php endif; ?>
<?php else: ?>
<span class="text-red-600"><i class="fas fa-times mr-1"></i>No</span>
<?php endif; ?>
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Communicant</label>
<p class="text-gray-800">
<?php if ($member['communicant'] ?? 0): ?>
<span class="text-green-600"><i class="fas fa-check mr-1"></i>Yes</span>
<?php else: ?>
<span class="text-red-600"><i class="fas fa-times mr-1"></i>No</span>
<?php endif; ?>
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Date of Conversion</label>
<p class="text-gray-800"><?php echo $member['date_of_conversion'] ? date('F j, Y', strtotime($member['date_of_conversion'])) : 'N/A'; ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Date of Joining</label>
<p class="text-gray-800"><?php echo $member['date_of_joining'] ? date('F j, Y', strtotime($member['date_of_joining'])) : 'N/A'; ?></p>
</div>
</div>
</div>
</div>
</div>
<!-- Sidebar Information -->
<div class="space-y-6">
<!-- Church Information -->
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-4">
<i class="fas fa-church mr-2 text-blue-500"></i>Church Information
</h3>
<div class="space-y-3">
<div>
<label class="block text-sm font-medium text-gray-600">Assembly</label>
<p class="text-gray-800 font-medium"><?php echo htmlspecialchars($member['assembly_name']); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">District</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['district_name']); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Area</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['area_name']); ?></p>
</div>
</div>
</div>
<!-- Status Information -->
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-4">
<i class="fas fa-info-circle mr-2 text-blue-500"></i>Status
</h3>
<div class="space-y-3">
<div>
<label class="block text-sm font-medium text-gray-600">Member Status</label>
<?php if ($member['is_active'] ?? 1): ?>
<span class="inline-flex px-3 py-1 text-sm font-semibold rounded-full bg-green-100 text-green-800">
<i class="fas fa-check-circle mr-1"></i>Active
</span>
<?php else: ?>
<span class="inline-flex px-3 py-1 text-sm font-semibold rounded-full bg-red-100 text-red-800">
<i class="fas fa-times-circle mr-1"></i>Inactive
</span>
<?php endif; ?>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Member Since</label>
<p class="text-gray-800"><?php echo date('F j, Y', strtotime($member['created_at'])); ?></p>
</div>
<?php if (!empty($member['created_by_name'])): ?>
<div>
<label class="block text-sm font-medium text-gray-600">Added By</label>
<p class="text-gray-800"><?php echo htmlspecialchars($member['created_by_name']); ?></p>
</div>
<?php endif; ?>
</div>
</div>
<!-- Membership Card -->
<?php if ($membershipCard): ?>
<div class="bg-white rounded-xl shadow-lg p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-4">
<i class="fas fa-id-card mr-2 text-blue-500"></i>Membership Card
</h3>
<div class="space-y-3">
<div>
<label class="block text-sm font-medium text-gray-600">Card Number</label>
<p class="text-gray-800 font-mono"><?php echo htmlspecialchars($membershipCard['card_number']); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Issue Date</label>
<p class="text-gray-800"><?php echo date('F j, Y', strtotime($membershipCard['issue_date'])); ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Expiry Date</label>
<p class="text-gray-800"><?php echo $membershipCard['expiry_date'] ? date('F j, Y', strtotime($membershipCard['expiry_date'])) : 'N/A'; ?></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600">Print Status</label>
<?php if ($membershipCard['printed']): ?>
<span class="text-green-600"><i class="fas fa-check mr-1"></i>Printed (<?php echo $membershipCard['print_count']; ?> times)</span>
<?php else: ?>
<span class="text-orange-600"><i class="fas fa-clock mr-1"></i>Not Printed</span>
<?php endif; ?>
</div>
<div class="pt-2">
<a href="../membership/cards.php?member_id=<?php echo $member['id']; ?>"
class="inline-flex items-center px-4 py-2 bg-blue-500 text-white text-sm rounded-lg hover:bg-blue-600 transition">
<i class="fas fa-print mr-2"></i>Print Card
</a>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
<?php include '../../includes/footer.php'; ?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists