Sindbad~EG File Manager
<?php
require_once '../config/config.php';
require_once '../classes/MemberAuth.php';
// Check if member is logged in
if (!MemberAuth::isMemberLoggedIn()) {
redirect('../login.php');
}
$pageTitle = 'Request Transfer - ' . APP_NAME;
$db = Database::getInstance()->getConnection();
$success = '';
$error = '';
$currentMember = MemberAuth::getCurrentMember();
if (!$currentMember) {
redirect('../login.php');
}
// Load member details and current location
$stmt = $db->prepare("SELECT m.*, a.area_name, d.district_name, ass.assembly_name
FROM members m
LEFT JOIN areas a ON m.area_id = a.id
LEFT JOIN districts d ON m.district_id = d.id
LEFT JOIN assemblies ass ON m.assembly_id = ass.id
WHERE m.id = :member_id");
$stmt->execute(['member_id' => $currentMember['member_id']]);
$memberDetails = $stmt->fetch(PDO::FETCH_ASSOC);
// Handle request submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_request'])) {
$toAreaId = (int)($_POST['to_area_id'] ?? 0);
$toDistrictId = (int)$_POST['to_district_id'] ?? 0;
$toAssemblyId = (int)$_POST['to_assembly_id'] ?? 0;
$reason = trim($_POST['reason'] ?? '');
if ($toAreaId <= 0 || $toDistrictId <= 0 || $toAssemblyId <= 0) {
$error = 'Please select the Area, District and Assembly you want to move to.';
} elseif ($memberDetails && $toAreaId == $memberDetails['area_id'] && $toDistrictId == $memberDetails['district_id'] && $toAssemblyId == $memberDetails['assembly_id']) {
$error = 'You are already in this location.';
} else {
try {
// Insert request (assumes member_transfer_requests table exists)
$stmt = $db->prepare('INSERT INTO member_transfer_requests (
member_id,
from_area_id, from_district_id, from_assembly_id,
to_area_id, to_district_id, to_assembly_id,
reason, status, created_at
) VALUES (
:member_id,
:from_area_id, :from_district_id, :from_assembly_id,
:to_area_id, :to_district_id, :to_assembly_id,
:reason, "pending", NOW()
)');
$stmt->execute([
'member_id' => $currentMember['member_id'],
'from_area_id' => $memberDetails['area_id'],
'from_district_id' => $memberDetails['district_id'],
'from_assembly_id' => $memberDetails['assembly_id'],
'to_area_id' => $toAreaId,
'to_district_id' => $toDistrictId,
'to_assembly_id' => $toAssemblyId,
'reason' => $reason !== '' ? $reason : null
]);
$success = 'Your transfer request has been submitted and is pending approval.';
} catch (PDOException $e) {
$error = 'Failed to submit request: ' . $e->getMessage();
}
}
}
// Load locations for selects
$areas = [];
$districts = [];
$assemblies = [];
try {
$areasStmt = $db->query('SELECT id, area_name FROM areas WHERE is_active = 1 ORDER BY area_name');
$areas = $areasStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {}
try {
$districtsStmt = $db->query('SELECT id, district_name, area_id FROM districts WHERE is_active = 1 ORDER BY district_name');
$districts = $districtsStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {}
try {
$assembliesStmt = $db->query('SELECT id, assembly_name, district_id FROM assemblies WHERE is_active = 1 ORDER BY assembly_name');
$assemblies = $assembliesStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {}
// Get settings for theme colors
$stmt = $db->query("SELECT * FROM general_settings ORDER BY id DESC LIMIT 1");
$settings = $stmt->fetch();
$settings = array_merge([
'site_title' => APP_NAME,
'theme_primary_color' => '#3B82F6',
'theme_secondary_color' => '#10B981'
], $settings ?: []);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $pageTitle; ?></title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
.gradient-bg { background: linear-gradient(135deg, #1E40AF 0%, #9333EA 50%, #F97316 100%); }
.card-hover { transition: all 0.3s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 12px 20px -5px rgba(0,0,0,0.1); }
</style>
</head>
<body class="bg-gray-50">
<!-- Member Portal Header -->
<header class="bg-white shadow-lg sticky top-0 z-50">
<div class="container mx-auto px-4">
<div class="flex items-center justify-between h-16">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-xl flex items-center justify-center gradient-bg">
<i class="fas fa-church text-white"></i>
</div>
<div>
<h1 class="text-lg font-bold text-gray-800"><?php echo htmlspecialchars($settings['site_title']); ?></h1>
<p class="text-xs text-gray-500">Member Portal</p>
</div>
</div>
<nav class="hidden md:flex items-center space-x-6">
<a href="dashboard.php" class="text-gray-700 hover:text-blue-600 transition">
<i class="fas fa-home mr-1"></i>Dashboard
</a>
<a href="profile.php" class="text-gray-700 hover:text-blue-600 transition">
<i class="fas fa-user mr-1"></i>Profile
</a>
<a href="messages.php" class="text-gray-700 hover:text-blue-600 transition">
<i class="fas fa-comments mr-1"></i>Messages
</a>
<a href="event-checkin.php" class="text-gray-700 hover:text-green-600 transition">
<i class="fas fa-qrcode mr-1"></i>Event Check-in
</a>
<a href="transfer_request.php" class="text-blue-600 font-medium border-b-2 border-blue-600 pb-1">
<i class="fas fa-exchange-alt mr-1"></i>Transfer
</a>
</nav>
<div class="flex items-center space-x-3">
<span class="text-sm text-gray-600 hidden md:block">Welcome, <?php echo htmlspecialchars($memberDetails['first_name'] ?? 'Member'); ?></span>
<a href="../logout.php?member=1" class="text-gray-600 hover:text-red-600 transition">
<i class="fas fa-sign-out-alt mr-1"></i>Logout
</a>
</div>
</div>
</div>
</header>
<div class="min-h-screen bg-gray-50 py-8">
<div class="max-w-3xl mx-auto px-4">
<!-- Page Header -->
<div class="mb-6">
<a href="dashboard.php" class="text-sm text-blue-600 hover:text-blue-800 mb-2 inline-block">
<i class="fas fa-arrow-left mr-1"></i>Back to Dashboard
</a>
<h1 class="text-3xl font-bold text-gray-800">
<i class="fas fa-exchange-alt mr-2 text-blue-500"></i>Request Transfer
</h1>
<p class="text-gray-600 mt-2">Request to move your membership to another assembly</p>
</div>
<div class="bg-white rounded-xl shadow-lg p-8 card-hover">
<?php if ($success): ?>
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-3 rounded mb-4">
<i class="fas fa-check-circle mr-2"></i><?php echo $success; ?>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-3 rounded mb-4">
<i class="fas fa-exclamation-circle mr-2"></i><?php echo $error; ?>
</div>
<?php endif; ?>
<!-- Current Location -->
<div class="mb-6 p-6 bg-gradient-to-r from-blue-50 to-purple-50 rounded-xl border-l-4 border-blue-500">
<h2 class="font-bold text-gray-800 mb-3 flex items-center">
<i class="fas fa-map-marker-alt mr-2 text-blue-500"></i>Your Current Location
</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
<div>
<p class="text-gray-600 text-xs mb-1">Area</p>
<p class="font-semibold text-gray-800"><?php echo htmlspecialchars($memberDetails['area_name'] ?? 'N/A'); ?></p>
</div>
<div>
<p class="text-gray-600 text-xs mb-1">District</p>
<p class="font-semibold text-gray-800"><?php echo htmlspecialchars($memberDetails['district_name'] ?? 'N/A'); ?></p>
</div>
<div>
<p class="text-gray-600 text-xs mb-1">Assembly</p>
<p class="font-semibold text-gray-800"><?php echo htmlspecialchars($memberDetails['assembly_name'] ?? 'N/A'); ?></p>
</div>
</div>
</div>
<!-- Request Form -->
<form method="POST" class="space-y-6">
<div>
<h3 class="font-bold text-gray-800 mb-4 flex items-center">
<i class="fas fa-map-marked-alt mr-2 text-purple-500"></i>New Location
</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">New Area</label>
<select name="to_area_id" id="toAreaSelect" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm" required>
<option value="">Select Area</option>
<?php foreach ($areas as $area): ?>
<option value="<?php echo $area['id']; ?>"><?php echo htmlspecialchars($area['area_name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">New District</label>
<select name="to_district_id" id="toDistrictSelect" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm" required>
<option value="">Select District</option>
<?php foreach ($districts as $dist): ?>
<option value="<?php echo $dist['id']; ?>" data-area-id="<?php echo $dist['area_id']; ?>"><?php echo htmlspecialchars($dist['district_name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">New Assembly</label>
<select name="to_assembly_id" id="toAssemblySelect" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm" required>
<option value="">Select Assembly</option>
<?php foreach ($assemblies as $asm): ?>
<option value="<?php echo $asm['id']; ?>" data-district-id="<?php echo $asm['district_id']; ?>"><?php echo htmlspecialchars($asm['assembly_name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<div>
<label class="block text-sm font-semibold text-gray-700 mb-2">
<i class="fas fa-comment-alt mr-1 text-orange-500"></i>Reason for Transfer (optional)
</label>
<textarea name="reason" rows="4" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" placeholder="Explain briefly why you are requesting this transfer..."></textarea>
</div>
<div class="flex justify-end mt-6 pt-4 border-t border-gray-200">
<button type="submit" name="submit_request" class="px-8 py-3 rounded-lg text-white font-semibold shadow-lg hover:shadow-xl transition" style="background: linear-gradient(135deg, #1E40AF 0%, #F97316 100%);">
<i class="fas fa-paper-plane mr-2"></i>Submit Transfer Request
</button>
</div>
</form>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var areaSelect = document.getElementById('toAreaSelect');
var districtSelect = document.getElementById('toDistrictSelect');
var assemblySelect = document.getElementById('toAssemblySelect');
function filterDistricts() {
var areaId = areaSelect.value;
districtSelect.querySelectorAll('option').forEach(function(opt) {
if (!opt.dataset.areaId) { opt.style.display = ''; return; }
opt.style.display = (!areaId || opt.dataset.areaId === areaId) ? '' : 'none';
});
}
function filterAssemblies() {
var districtId = districtSelect.value;
assemblySelect.querySelectorAll('option').forEach(function(opt) {
if (!opt.dataset.districtId) { opt.style.display = ''; return; }
opt.style.display = (!districtId || opt.dataset.districtId === districtId) ? '' : 'none';
});
}
if (areaSelect && districtSelect && assemblySelect) {
filterDistricts();
filterAssemblies();
areaSelect.addEventListener('change', function() {
districtSelect.value = '';
assemblySelect.value = '';
filterDistricts();
filterAssemblies();
});
districtSelect.addEventListener('change', function() {
assemblySelect.value = '';
filterAssemblies();
});
}
});
</script>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-6 mt-12">
<div class="container mx-auto px-4 text-center">
<p class="text-sm text-gray-400">
© <?php echo date('Y'); ?> <?php echo htmlspecialchars($settings['site_title']); ?>. All rights reserved.
</p>
</div>
</footer>
<?php
// Include Chat Hub Widget (Admin Chat + AI Chatbot)
if (file_exists(__DIR__ . '/../includes/chat-hub-widget.php')) {
include '../includes/chat-hub-widget.php';
}
?>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists