<?php
// Error reporting ko on karein taaki koi bhi galti chhupe nahi
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Timezone ko India ke liye set karein
date_default_timezone_set('Asia/Kolkata');

// config.php ko shaamil karein, jo session aur database connection ko sambhalega.
if (file_exists('config.php')) {
    require_once 'config.php';
} else {
    die("Configuration file not found. Please ensure config.php is in the correct directory.");
}

// Yeh function jaanch karega ki user ke paas zaroori role hai ya nahi.
if (!function_exists('userHasRole')) {
    function userHasRole($required_roles) {
        if (!isset($_SESSION['user_roles'])) return false;
        if (!is_array($required_roles)) {
            $required_roles = [$required_roles];
        }
        return count(array_intersect($required_roles, $_SESSION['user_roles'])) > 0;
    }
}

// Alag-alag roles ke liye variables set karein
$is_admin = userHasRole(['Admin']);
$is_manager = userHasRole(['Manager']);
$is_smm = userHasRole(['SMM']);
$is_sales = userHasRole(['Sales']);
// ===== NAYA ROLE VARIABLE YAHAN ADD KIYA GAYA HAI =====
$is_video_editor = userHasRole(['Video Editor']);

// Maujooda page ka naam prapt karein
$current_page = basename($_SERVER['PHP_SELF']);
?>
