Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/install_administration.php

<?php
require_once 'config/config.php';
checkLogin();

if (!isSuperuser()) {
    header('Location: ' . BASE_URL . 'dashboard.php');
    exit();
}

$pageTitle = "Install Administration Module - " . APP_NAME;
$db = Database::getInstance()->getConnection();

$success = false;
$errors = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    try {
        // Read and execute SQL file
        $sqlFile = __DIR__ . '/sql/admin_location_assignments.sql';
        
        if (!file_exists($sqlFile)) {
            throw new Exception('SQL file not found: ' . $sqlFile);
        }
        
        $sql = file_get_contents($sqlFile);
        
        // Split by semicolons and execute each statement
        $statements = array_filter(array_map('trim', explode(';', $sql)));
        
        foreach ($statements as $statement) {
            if (!empty($statement)) {
                $db->exec($statement);
            }
        }
        
        $success = true;
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
}

include 'includes/header.php';
?>

<?php include 'includes/sidebar.php'; ?>

<main class="flex-1 md:ml-64 mt-16 min-h-screen bg-gray-50">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <div class="gradient-bg rounded-2xl shadow-2xl p-8 mb-8 text-white">
            <h1 class="text-4xl font-bold mb-2">
                <i class="fas fa-cogs mr-3"></i>Administration Module Installation
            </h1>
            <p class="text-white/90 text-lg">Install the administration module and admin assignment system</p>
        </div>

        <?php if ($success): ?>
            <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-6 rounded-lg mb-6 animate-fadeIn">
                <div class="flex items-center">
                    <i class="fas fa-check-circle text-3xl mr-4"></i>
                    <div>
                        <p class="font-bold text-lg">Installation Successful!</p>
                        <p class="mt-2">The Administration module has been installed successfully.</p>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-2xl font-bold text-gray-800 mb-4">
                    <i class="fas fa-info-circle mr-2 text-blue-600"></i>Next Steps
                </h2>
                
                <div class="space-y-4">
                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center font-bold text-white mr-3" style="background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);">1</div>
                        <div>
                            <p class="font-semibold mb-1">Access the Administration Module</p>
                            <p class="text-sm text-gray-600">Go to Dashboard → Administration (or check the sidebar menu)</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center font-bold text-white mr-3" style="background: linear-gradient(135deg, #F97316 0%, #FBBF24 100%);">2</div>
                        <div>
                            <p class="font-semibold mb-1">Manage Church Locations</p>
                            <p class="text-sm text-gray-600">Create and manage areas, districts, and assemblies</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center font-bold text-white mr-3" style="background: linear-gradient(135deg, #9333EA 0%, #F97316 100%);">3</div>
                        <div>
                            <p class="font-semibold mb-1">Assign Administrators</p>
                            <p class="text-sm text-gray-600">Assign multiple admins to areas, districts, and assemblies</p>
                        </div>
                    </div>
                </div>
                
                <div class="mt-8 flex gap-4">
                    <a href="<?php echo BASE_URL; ?>modules/administration/index.php" class="btn-gradient text-white px-8 py-3 rounded-full font-bold inline-flex items-center shadow-lg hover:shadow-xl transition">
                        <i class="fas fa-cogs mr-2"></i>Go to Administration
                    </a>
                    <a href="<?php echo BASE_URL; ?>dashboard.php" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-8 py-3 rounded-full font-bold inline-flex items-center transition">
                        <i class="fas fa-arrow-left mr-2"></i>Back to Dashboard
                    </a>
                </div>
            </div>

        <?php elseif (!empty($errors)): ?>
            <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-6 rounded-lg mb-6">
                <div class="flex items-center">
                    <i class="fas fa-exclamation-circle text-3xl mr-4"></i>
                    <div>
                        <p class="font-bold text-lg">Installation Failed</p>
                        <ul class="mt-2 list-disc list-inside">
                            <?php foreach ($errors as $error): ?>
                                <li><?php echo htmlspecialchars($error); ?></li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                </div>
            </div>

        <?php else: ?>
            <div class="bg-white rounded-2xl shadow-lg p-8">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">
                    <i class="fas fa-info-circle mr-2 text-blue-600"></i>Installation Information
                </h2>
                
                <div class="bg-blue-50 border-l-4 border-blue-500 p-6 rounded mb-6">
                    <p class="font-semibold text-blue-800 mb-3">This installation will:</p>
                    <ul class="space-y-2 text-blue-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1"></i>
                            <span>Create the <code class="bg-blue-100 px-2 py-1 rounded">admin_location_assignments</code> table for managing admin assignments</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1"></i>
                            <span>Register the Administration module in the system</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1"></i>
                            <span>Enable multiple admin assignment to areas, districts, and assemblies</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle mr-2 mt-1"></i>
                            <span>Add the Administration link to your sidebar menu</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-yellow-50 border-l-4 border-yellow-500 p-6 rounded mb-6">
                    <p class="font-semibold text-yellow-800 mb-2"><i class="fas fa-exclamation-triangle mr-2"></i>Important:</p>
                    <ul class="space-y-1 text-yellow-700 text-sm">
                        <li>• This module is only accessible to superusers</li>
                        <li>• Existing data in areas, districts, and assemblies tables will not be affected</li>
                        <li>• You can assign multiple admins to manage different locations</li>
                    </ul>
                </div>
                
                <form method="POST" class="mt-8">
                    <button type="submit" class="btn-gradient text-white px-8 py-4 rounded-full font-bold text-lg shadow-xl hover:shadow-2xl transition">
                        <i class="fas fa-download mr-2"></i>Install Administration Module
                    </button>
                </form>
            </div>
        <?php endif; ?>
    </div>
</main>

<?php include 'includes/footer.php'; ?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists