Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/membership-issue.php

<?php
require_once 'config/config.php';

$pageTitle = "Report Membership Issue - " . APP_NAME;

// Get settings for theme colors
$db = Database::getInstance()->getConnection();
$stmt = $db->query("SELECT * FROM general_settings ORDER BY id DESC LIMIT 1");
$settings = $stmt->fetch();

// Default settings if none exist
$settings = array_merge([
    'site_title' => 'Church Membership System',
    'theme_primary_color' => '#3B82F6',
    'theme_secondary_color' => '#10B981',
], $settings ?: []);

// Get issue type and parameters
$issueType = isset($_GET['type']) ? $_GET['type'] : 'not_found';
$searchQuery = isset($_GET['search']) ? $_GET['search'] : '';
$memberId = isset($_GET['member_id']) ? intval($_GET['member_id']) : null;

// Get member details if reporting incorrect details
$memberDetails = null;
if ($issueType == 'incorrect' && $memberId) {
    $stmt = $db->prepare("
        SELECT m.*, a.area_name, d.district_name, asm.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 asm ON m.assembly_id = asm.id
        WHERE m.id = :id
    ");
    $stmt->execute(['id' => $memberId]);
    $memberDetails = $stmt->fetch(PDO::FETCH_ASSOC);
}

// Handle form submission
$successMessage = '';
$errorMessage = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    try {
        $issueType = $_POST['issue_type'];
        $complainantName = trim($_POST['complainant_name']);
        $complainantEmail = trim($_POST['complainant_email']);
        $complainantPhone = trim($_POST['complainant_phone']);
        $complaintDetails = trim($_POST['complaint_details']);
        $memberId = isset($_POST['member_id']) ? intval($_POST['member_id']) : null;
        $searchQuery = isset($_POST['search_query']) ? trim($_POST['search_query']) : '';
        
        // Validation
        if (empty($complainantName) || empty($complaintDetails)) {
            throw new Exception("Please fill in all required fields.");
        }
        
        // Prepare proposed data for incorrect details
        $proposedData = null;
        if ($issueType == 'incorrect') {
            $proposedData = json_encode([
                'title' => $_POST['proposed_title'] ?? '',
                'first_name' => $_POST['proposed_first_name'] ?? '',
                'middle_name' => $_POST['proposed_middle_name'] ?? '',
                'last_name' => $_POST['proposed_last_name'] ?? '',
                'phone' => $_POST['proposed_phone'] ?? '',
                'email' => $_POST['proposed_email'] ?? '',
                'district' => $_POST['proposed_district'] ?? '',
                'assembly' => $_POST['proposed_assembly'] ?? '',
            ]);
        }
        
        // Prepare membership form data if provided (comprehensive form)
        $membershipFormData = null;
        $hasMembershipForm = 0;
        if ($issueType == 'not_found' && isset($_POST['fill_membership_form']) && $_POST['fill_membership_form'] == '1') {
            $membershipFormData = json_encode([
                // Personal Information
                'title' => $_POST['title'] ?? '',
                'first_name' => $_POST['first_name'] ?? '',
                'middle_name' => $_POST['middle_name'] ?? '',
                'last_name' => $_POST['last_name'] ?? '',
                'gender' => $_POST['gender'] ?? '',
                'date_of_birth' => $_POST['date_of_birth'] ?? '',
                'place_of_birth' => $_POST['place_of_birth'] ?? '',
                'marital_status' => $_POST['marital_status'] ?? '',
                'member_type' => $_POST['member_type'] ?? 'Full Member',
                // Contact Information
                'phone' => $_POST['phone'] ?? '',
                'email' => $_POST['email'] ?? '',
                'address_line1' => $_POST['address_line1'] ?? '',
                'gps_address' => $_POST['gps_address'] ?? '',
                'street_name' => $_POST['street_name'] ?? '',
                'city' => $_POST['city'] ?? '',
                'hometown' => $_POST['hometown'] ?? '',
                // Church Location
                'area_id' => $_POST['area_id'] ?? '',
                'district_id' => $_POST['district_id'] ?? '',
                'assembly_id' => $_POST['assembly_id'] ?? '',
                'family_id' => $_POST['family_id'] ?? '',
                // Spiritual Information
                'water_baptism' => isset($_POST['water_baptism']) ? 1 : 0,
                'holyghost_baptism' => isset($_POST['holyghost_baptism']) ? 1 : 0,
                'communicant' => isset($_POST['communicant']) ? 1 : 0,
                'dedicated' => isset($_POST['dedicated']) ? 1 : 0,
                'date_of_baptism' => $_POST['date_of_baptism'] ?? '',
                'date_of_holyspirit_baptism' => $_POST['date_of_holyspirit_baptism'] ?? '',
                'date_of_conversion' => $_POST['date_of_conversion'] ?? '',
                'date_of_joining' => $_POST['date_of_joining'] ?? '',
                'dedication_date' => $_POST['dedication_date'] ?? '',
                'place_of_baptism' => $_POST['place_of_baptism'] ?? '',
                'officiating_minister_baptism' => $_POST['officiating_minister_baptism'] ?? '',
                'officiating_ministers_district' => $_POST['officiating_ministers_district'] ?? '',
                'name_of_officiating_minister' => $_POST['name_of_officiating_minister'] ?? '',
                'church_where_dedication_done' => $_POST['church_where_dedication_done'] ?? '',
                // Other Information
                'occupation' => $_POST['occupation'] ?? '',
                'level_of_education' => $_POST['level_of_education'] ?? '',
                'parent_name' => $_POST['parent_name'] ?? '',
                'parent_relationship' => $_POST['parent_relationship'] ?? '',
            ]);
            $hasMembershipForm = 1;
        }
        
        // Insert into database
        $sql = "INSERT INTO membership_issues (
                    issue_type, member_id, complainant_name, complainant_email, 
                    complainant_phone, complaint_details, search_query, 
                    proposed_data, membership_form_data, has_membership_form,
                    status, priority, created_at
                ) VALUES (
                    :issue_type, :member_id, :complainant_name, :complainant_email,
                    :complainant_phone, :complaint_details, :search_query,
                    :proposed_data, :membership_form_data, :has_membership_form,
                    'pending', 'medium', NOW()
                )";
        
        $stmt = $db->prepare($sql);
        $stmt->execute([
            'issue_type' => $issueType,
            'member_id' => $memberId,
            'complainant_name' => $complainantName,
            'complainant_email' => $complainantEmail,
            'complainant_phone' => $complainantPhone,
            'complaint_details' => $complaintDetails,
            'search_query' => $searchQuery,
            'proposed_data' => $proposedData,
            'membership_form_data' => $membershipFormData,
            'has_membership_form' => $hasMembershipForm
        ]);
        
        $successMessage = "Your issue has been submitted successfully! Our admin team will review it shortly.";
        
        // Clear form
        $_POST = [];
        
    } catch (Exception $e) {
        $errorMessage = "Error: " . $e->getMessage();
    }
}

// Get areas, districts and assemblies for dropdown
$areasStmt = $db->query("SELECT id, area_name FROM areas WHERE is_active = 1 ORDER BY area_name");
$areas = $areasStmt->fetchAll(PDO::FETCH_ASSOC);

$districtsStmt = $db->query("SELECT id, district_name FROM districts ORDER BY district_name");
$districts = $districtsStmt->fetchAll(PDO::FETCH_ASSOC);

$assembliesStmt = $db->query("SELECT id, assembly_name, district_id FROM assemblies ORDER BY assembly_name");
$assemblies = $assembliesStmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!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>
        :root {
            --primary-color: <?php echo $settings['theme_primary_color']; ?>;
            --secondary-color: <?php echo $settings['theme_secondary_color']; ?>;
        }
        .bg-primary { background-color: var(--primary-color); }
        .bg-secondary { background-color: var(--secondary-color); }
        .text-primary { color: var(--primary-color); }
        .border-primary { border-color: var(--primary-color); }
        .hero-gradient {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Header -->
    <header class="bg-white shadow-lg">
        <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 bg-primary rounded-lg flex items-center justify-center">
                        <i class="fas fa-church text-white text-lg"></i>
                    </div>
                    <div>
                        <h1 class="text-xl font-bold text-gray-800"><?php echo htmlspecialchars($settings['site_title']); ?></h1>
                        <p class="text-xs text-gray-500">Report Issue</p>
                    </div>
                </div>
                <nav class="hidden md:flex items-center space-x-4">
                    <a href="index.php" class="text-gray-600 hover:text-primary transition">
                        <i class="fas fa-home mr-1"></i>Home
                    </a>
                    <a href="public-search.php" class="text-gray-600 hover:text-primary transition">
                        <i class="fas fa-search mr-1"></i>Search
                    </a>
                </nav>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <section class="py-12">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto">
                
                <?php if (!empty($successMessage)): ?>
                    <!-- Success Message -->
                    <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-6 rounded-lg mb-6">
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-2xl mr-4 mt-1"></i>
                            <div>
                                <p class="font-bold text-lg mb-2">Success!</p>
                                <p><?php echo htmlspecialchars($successMessage); ?></p>
                                <div class="mt-4 flex gap-3">
                                    <a href="public-search.php" class="bg-primary text-white px-6 py-2 rounded-lg hover:opacity-90 transition">
                                        <i class="fas fa-search mr-2"></i>Back to Search
                                    </a>
                                    <a href="index.php" class="bg-gray-600 text-white px-6 py-2 rounded-lg hover:opacity-90 transition">
                                        <i class="fas fa-home mr-2"></i>Go Home
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>

                <?php if (!empty($errorMessage)): ?>
                    <!-- Error Message -->
                    <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded-lg mb-6">
                        <p class="font-bold"><i class="fas fa-exclamation-circle mr-2"></i>Error</p>
                        <p><?php echo htmlspecialchars($errorMessage); ?></p>
                    </div>
                <?php endif; ?>

                <!-- Form Card -->
                <div class="bg-white rounded-lg shadow-md p-8">
                    <!-- Header -->
                    <div class="mb-6">
                        <?php if ($issueType == 'not_found'): ?>
                            <h2 class="text-3xl font-bold text-gray-800 mb-2">
                                <i class="fas fa-exclamation-circle text-red-600 mr-2"></i>
                                Report Missing Member
                            </h2>
                            <p class="text-gray-600">
                                Couldn't find "<?php echo htmlspecialchars($searchQuery); ?>" in our system? Let us know and optionally fill out a membership form.
                            </p>
                        <?php else: ?>
                            <h2 class="text-3xl font-bold text-gray-800 mb-2">
                                <i class="fas fa-exclamation-triangle text-yellow-600 mr-2"></i>
                                Report Incorrect Details
                            </h2>
                            <p class="text-gray-600">
                                Found incorrect information? Help us keep our records accurate by reporting the issue.
                            </p>
                        <?php endif; ?>
                    </div>

                    <!-- Current Member Details (for incorrect details) -->
                    <?php if ($issueType == 'incorrect' && $memberDetails): ?>
                        <div class="bg-blue-50 border-l-4 border-blue-500 p-6 rounded-lg mb-6">
                            <h3 class="font-bold text-lg text-gray-800 mb-3">Current Member Information:</h3>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
                                <div>
                                    <p class="text-gray-600">Name:</p>
                                    <p class="font-semibold"><?php echo htmlspecialchars($memberDetails['first_name'] . ' ' . $memberDetails['last_name']); ?></p>
                                </div>
                                <div>
                                    <p class="text-gray-600">Membership Card:</p>
                                    <p class="font-semibold"><?php echo htmlspecialchars($memberDetails['membershipcard_id']); ?></p>
                                </div>
                                <div>
                                    <p class="text-gray-600">District:</p>
                                    <p class="font-semibold"><?php echo htmlspecialchars($memberDetails['district_name']); ?></p>
                                </div>
                                <div>
                                    <p class="text-gray-600">Assembly:</p>
                                    <p class="font-semibold"><?php echo htmlspecialchars($memberDetails['assembly_name']); ?></p>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>

                    <!-- Issue Form -->
                    <form method="POST" action="" class="space-y-6" id="issueForm">
                        <input type="hidden" name="issue_type" value="<?php echo htmlspecialchars($issueType); ?>">
                        <input type="hidden" name="member_id" value="<?php echo htmlspecialchars($memberId); ?>">
                        <input type="hidden" name="search_query" value="<?php echo htmlspecialchars($searchQuery); ?>">

                        <!-- Complainant Information -->
                        <div>
                            <h3 class="text-xl font-bold text-gray-800 mb-4">Your Information</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">
                                        Your Name <span class="text-red-500">*</span>
                                    </label>
                                    <input type="text" name="complainant_name" required
                                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary"
                                           placeholder="Full name">
                                </div>
                                <div>
                                    <label class="block text-sm font-semibold text-gray-700 mb-2">
                                        Email
                                    </label>
                                    <input type="email" name="complainant_email"
                                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary"
                                           placeholder="email@example.com">
                                </div>
                                <div>
                                    <label class="block text-sm font-semibold text-gray-700 mb-2">
                                        Phone
                                    </label>
                                    <input type="tel" name="complainant_phone"
                                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary"
                                           placeholder="+1234567890">
                                </div>
                            </div>
                        </div>

                        <!-- Complaint Details -->
                        <div>
                            <label class="block text-sm font-semibold text-gray-700 mb-2">
                                Describe the Issue <span class="text-red-500">*</span>
                            </label>
                            <textarea name="complaint_details" required rows="4"
                                      class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary"
                                      placeholder="Please provide details about the issue..."></textarea>
                        </div>

                        <?php if ($issueType == 'incorrect'): ?>
                            <!-- Proposed Corrections -->
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-4">Correct Information (Optional)</h3>
                                <p class="text-sm text-gray-600 mb-4">Fill in the fields you believe are incorrect with the correct information:</p>
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Title</label>
                                        <select name="proposed_title" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                            <option value="">Select</option>
                                            <option value="Mr">Mr</option>
                                            <option value="Mrs">Mrs</option>
                                            <option value="Miss">Miss</option>
                                            <option value="Dr">Dr</option>
                                            <option value="Rev">Rev</option>
                                            <option value="Pastor">Pastor</option>
                                            <option value="Deacon">Deacon</option>
                                            <option value="Deaconess">Deaconess</option>
                                            <option value="Elder">Elder</option>
                                            <option value="Evangelist">Evangelist</option>
                                            <option value="Prophet">Prophet</option>
                                            <option value="Apostle">Apostle</option>
                                        </select>
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">First Name</label>
                                        <input type="text" name="proposed_first_name"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Middle Name</label>
                                        <input type="text" name="proposed_middle_name"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Last Name</label>
                                        <input type="text" name="proposed_last_name"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Phone</label>
                                        <input type="tel" name="proposed_phone"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Email</label>
                                        <input type="email" name="proposed_email"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">District</label>
                                        <input type="text" name="proposed_district"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                    <div class="md:col-span-2">
                                        <label class="block text-sm font-semibold text-gray-700 mb-2">Assembly</label>
                                        <input type="text" name="proposed_assembly"
                                               class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary">
                                    </div>
                                </div>
                            </div>
                        <?php endif; ?>

                        <?php if ($issueType == 'not_found'): ?>
                            <!-- Optional Membership Form -->
                            <div>
                                <div class="flex items-center mb-4">
                                    <input type="checkbox" id="fillMembershipForm" name="fill_membership_form" value="1"
                                           class="w-5 h-5 text-primary border-gray-300 rounded focus:ring-primary"
                                           onchange="toggleMembershipForm()">
                                    <label for="fillMembershipForm" class="ml-2 text-sm font-semibold text-gray-700">
                                        Fill out membership application form now (Optional)
                                    </label>
                                </div>

                                <div id="membershipFormFields" class="hidden space-y-6 p-6 bg-gray-50 rounded-lg">
                                    <h3 class="text-2xl font-bold text-gray-800 mb-4">
                                        <i class="fas fa-user-plus mr-2 text-blue-500"></i>Comprehensive Membership Application
                                    </h3>
                                    
                                    <!-- Personal Information -->
                                    <div class="bg-white p-6 rounded-lg border border-gray-200">
                                        <h4 class="text-lg font-bold text-gray-800 mb-4">
                                            <i class="fas fa-user mr-2 text-blue-500"></i>Personal Information
                                        </h4>
                                        <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Title</label>
                                                <select name="title" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="">Select</option>
                                                    <option value="Mr">Mr</option>
                                                    <option value="Mrs">Mrs</option>
                                                    <option value="Miss">Miss</option>
                                                    <option value="Dr">Dr</option>
                                                    <option value="Rev">Rev</option>
                                                    <option value="Pastor">Pastor</option>
                                                    <option value="Deacon">Deacon</option>
                                                    <option value="Deaconess">Deaconess</option>
                                                    <option value="Elder">Elder</option>
                                                    <option value="Evangelist">Evangelist</option>
                                                    <option value="Prophet">Prophet</option>
                                                    <option value="Apostle">Apostle</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">First Name *</label>
                                                <input type="text" name="first_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Middle Name</label>
                                                <input type="text" name="middle_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Last Name *</label>
                                                <input type="text" name="last_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                        </div>
                                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mt-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Gender *</label>
                                                <select name="gender" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="">Select</option>
                                                    <option value="Male">Male</option>
                                                    <option value="Female">Female</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Date of Birth</label>
                                                <input type="date" name="date_of_birth" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Place of Birth</label>
                                                <input type="text" name="place_of_birth" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                        </div>
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Marital Status</label>
                                                <select name="marital_status" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="">Select</option>
                                                    <option value="Single">Single</option>
                                                    <option value="Married">Married</option>
                                                    <option value="Divorced">Divorced</option>
                                                    <option value="Widowed">Widowed</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Member Type</label>
                                                <select name="member_type" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="Full Member" selected>Full Member</option>
                                                    <option value="Associate Member">Associate Member</option>
                                                    <option value="Youth">Youth</option>
                                                    <option value="Children">Children</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Contact Information -->
                                    <div class="bg-white p-6 rounded-lg border border-gray-200">
                                        <h4 class="text-lg font-bold text-gray-800 mb-4">
                                            <i class="fas fa-address-book mr-2 text-blue-500"></i>Contact Information
                                        </h4>
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Phone</label>
                                                <input type="tel" name="phone" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Email</label>
                                                <input type="email" name="email" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                        </div>
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
                                            <div class="md:col-span-2">
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Address Line 1</label>
                                                <textarea name="address_line1" rows="2" class="w-full px-4 py-2 border border-gray-300 rounded-lg"></textarea>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">GPS Address</label>
                                                <input type="text" name="gps_address" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Street Name</label>
                                                <input type="text" name="street_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">City</label>
                                                <input type="text" name="city" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Hometown</label>
                                                <input type="text" name="hometown" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Church Location -->
                                    <div class="bg-white p-6 rounded-lg border border-gray-200">
                                        <h4 class="text-lg font-bold text-gray-800 mb-4">
                                            <i class="fas fa-church mr-2 text-blue-500"></i>Church Location
                                        </h4>
                                        <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">Area *</label>
                                                <select name="area_id" id="areaSelect" class="w-full px-4 py-2 border border-gray-300 rounded-lg" onchange="loadDistricts(this.value)">
                                                    <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">District *</label>
                                                <select name="district_id" id="districtSelect" class="w-full px-4 py-2 border border-gray-300 rounded-lg" onchange="loadAssemblies(this.value)">
                                                    <option value="">Select District</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Assembly *</label>
                                                <select name="assembly_id" id="assemblySelect" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="">Select Assembly</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Family ID (Optional)</label>
                                                <input type="text" name="family_id" class="w-full px-4 py-2 border border-gray-300 rounded-lg" placeholder="Link to family">
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Spiritual Information -->
                                    <div class="bg-white p-6 rounded-lg border border-gray-200">
                                        <h4 class="text-lg font-bold text-gray-800 mb-4">
                                            <i class="fas fa-cross mr-2 text-blue-500"></i>Spiritual Information
                                        </h4>
                                        <div class="flex flex-wrap gap-6 mb-4">
                                            <label class="flex items-center">
                                                <input type="checkbox" name="water_baptism" class="mr-2 rounded">
                                                <span class="text-sm font-semibold text-gray-700">Water Baptism</span>
                                            </label>
                                            <label class="flex items-center">
                                                <input type="checkbox" name="holyghost_baptism" class="mr-2 rounded">
                                                <span class="text-sm font-semibold text-gray-700">Holy Ghost Baptism</span>
                                            </label>
                                            <label class="flex items-center">
                                                <input type="checkbox" name="communicant" class="mr-2 rounded">
                                                <span class="text-sm font-semibold text-gray-700">Communicant</span>
                                            </label>
                                            <label class="flex items-center">
                                                <input type="checkbox" name="dedicated" class="mr-2 rounded">
                                                <span class="text-sm font-semibold text-gray-700">Dedicated</span>
                                            </label>
                                        </div>
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Date of Baptism</label>
                                                <input type="date" name="date_of_baptism" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Date of Holy Spirit Baptism</label>
                                                <input type="date" name="date_of_holyspirit_baptism" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Date of Conversion</label>
                                                <input type="date" name="date_of_conversion" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Date of Joining</label>
                                                <input type="date" name="date_of_joining" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Dedication Date</label>
                                                <input type="date" name="dedication_date" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Place of Baptism</label>
                                                <input type="text" name="place_of_baptism" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Officiating Minister (Baptism)</label>
                                                <input type="text" name="officiating_minister_baptism" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Minister's District/Church</label>
                                                <input type="text" name="officiating_ministers_district" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Officiating Minister (Dedication)</label>
                                                <input type="text" name="name_of_officiating_minister" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Church Where Dedication Done</label>
                                                <input type="text" name="church_where_dedication_done" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Other Information -->
                                    <div class="bg-white p-6 rounded-lg border border-gray-200">
                                        <h4 class="text-lg font-bold text-gray-800 mb-4">
                                            <i class="fas fa-info-circle mr-2 text-blue-500"></i>Other Information
                                        </h4>
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Occupation</label>
                                                <input type="text" name="occupation" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Level of Education</label>
                                                <select name="level_of_education" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                                    <option value="">Select</option>
                                                    <option value="Primary">Primary</option>
                                                    <option value="JHS">JHS</option>
                                                    <option value="SHS">SHS</option>
                                                    <option value="Tertiary">Tertiary</option>
                                                    <option value="Postgraduate">Postgraduate</option>
                                                </select>
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Parent Name</label>
                                                <input type="text" name="parent_name" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
                                            </div>
                                            <div>
                                                <label class="block text-sm font-semibold text-gray-700 mb-2">Parent Relationship</label>
                                                <input type="text" name="parent_relationship" class="w-full px-4 py-2 border border-gray-300 rounded-lg" placeholder="e.g., Father, Mother, Guardian">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <?php endif; ?>

                        <!-- Submit Button -->
                        <div class="flex gap-4">
                            <button type="submit" class="bg-primary text-white px-8 py-3 rounded-lg font-semibold hover:opacity-90 transition">
                                <i class="fas fa-paper-plane mr-2"></i>Submit Issue
                            </button>
                            <a href="public-search.php" class="bg-gray-500 text-white px-8 py-3 rounded-lg font-semibold hover:opacity-90 transition">
                                <i class="fas fa-times mr-2"></i>Cancel
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>

    <script>
        function toggleMembershipForm() {
            const checkbox = document.getElementById('fillMembershipForm');
            const formFields = document.getElementById('membershipFormFields');
            if (checkbox.checked) {
                formFields.classList.remove('hidden');
            } else {
                formFields.classList.add('hidden');
            }
        }
        
        function loadDistricts(areaId) {
            if (!areaId) {
                document.getElementById('districtSelect').innerHTML = '<option value="">Select District</option>';
                document.getElementById('assemblySelect').innerHTML = '<option value="">Select Assembly</option>';
                return;
            }
            
            fetch('<?php echo BASE_URL; ?>api/get-districts.php?area_id=' + areaId)
                .then(response => response.json())
                .then(data => {
                    let html = '<option value="">Select District</option>';
                    data.forEach(district => {
                        html += `<option value="${district.id}">${district.district_name}</option>`;
                    });
                    document.getElementById('districtSelect').innerHTML = html;
                    document.getElementById('assemblySelect').innerHTML = '<option value="">Select Assembly</option>';
                })
                .catch(error => console.error('Error loading districts:', error));
        }
        
        function loadAssemblies(districtId) {
            if (!districtId) {
                document.getElementById('assemblySelect').innerHTML = '<option value="">Select Assembly</option>';
                return;
            }
            
            fetch('<?php echo BASE_URL; ?>api/get-assemblies.php?district_id=' + districtId)
                .then(response => response.json())
                .then(data => {
                    let html = '<option value="">Select Assembly</option>';
                    data.forEach(assembly => {
                        html += `<option value="${assembly.id}">${assembly.assembly_name}</option>`;
                    });
                    document.getElementById('assemblySelect').innerHTML = html;
                })
                .catch(error => console.error('Error loading assemblies:', error));
        }
    </script>

    <?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