<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "Test 1: PHP is working<br>";

session_start();
echo "Test 2: Session started<br>";

require '../../config.php';
echo "Test 3: Config loaded<br>";

require '../admin_config.php';
echo "Test 4: Admin config loaded<br>";

require '../functions.php';
echo "Test 5: Functions loaded<br>";

if (isset($_SESSION['user_email'])){
    echo "Test 6: User is logged in<br>";
    
    $connect = connect();
    if($connect){
        echo "Test 7: Database connected<br>";
        
        $check_access = check_access($connect);
        echo "Test 8: Access checked - Role: " . $check_access['user_role'] . "<br>";
        
        if ($check_access['user_role'] == 1){
            echo "Test 9: User is admin<br>";
            
            $settings = get_settings($connect);
            echo "Test 10: Settings loaded<br>";
            
            echo "<br><strong>All tests passed! The issue is likely in the view file.</strong>";
        } else {
            echo "Test 9 FAILED: User is not admin";
        }
    } else {
        echo "Test 7 FAILED: Database connection failed";
    }
} else {
    echo "Test 6 FAILED: User not logged in";
}
?>
