<?php 
    include_once "load.php";
    $csrf_token    = $csrf_generator->create();
    $loggedIn      = !isset($session->data['logged_in']) || $session->data['logged_in'] == false ? false : true;
    $user_id       = isset($session->data['user_id']) ? $session->data['user_id'] : 0;
    
    $requested_url = trim(urldecode( $_SERVER["REQUEST_URI"]), "/");
    if(substr($requested_url, 0, 1 ) === "?"){
        $requested_url = '';
    }
    $requested_url = strtok($requested_url, '?');

    if($requested_url == "index.php"){
        $requested_url = "";
    }

    if(!$loggedIn && $requested_url != 'admin/login'){
        header("Location: /admin/login");
        exit();
    }
    $user_group         = isset($session->data['user_group']) ? $session->data['user_group'] : 0;
    $accessControl      = new AccessControl($db, $user_group);
    
    $menu_selector = 0;

    if(!$accessControl->get($requested_url)) {
        require 'views/access-denied.php';
    }else{
        switch($requested_url){
            case "admin/login":
                require 'views/login.php';
            break;
            case "admin/logout":
                require 'views/logout.php';
            break;
            case "admin":
                $menu_selector = 1;
                require 'views/index.php';
            break;
            case "admin/access-denied":
                require 'views/access-denied.php';
            break;
    
    
            case "admin/product/list":
                $menu_selector = 2;
                require 'views/product/list.php';
            break;
            case "admin/product/edit":
                $menu_selector = 2;
                require 'views/product/edit.php';
            break;
            case "admin/product/add":
                $menu_selector = 2;
                require 'views/product/add.php';
            break;
            case "admin/product/excel":
                $menu_selector = 2;
                require 'views/product/excel.php';
            break;
            case "admin/product/reviews":
                $menu_selector = 40;
                require 'views/product/reviews.php';
            break;
            case "admin/product/reviews/delete":
                require 'views/product/review-delete.php';
            break;
            case "admin/product/delete":
                require 'views/product/delete.php';
            break;
            case "admin/product/delete-product-section":
                require 'views/product/delete-product-section.php';
            break;
            case "admin/product/delete-product-content":
                require 'views/product/delete-product-content.php';
            break;
    
    
            case "admin/survey/list":
                $menu_selector = 30;
                require 'views/survey/list.php';
            break;
            case "admin/survey/edit":
                $menu_selector = 30;
                require 'views/survey/edit.php';
            break;
            case "admin/survey/add":
                $menu_selector = 30;
                require 'views/survey/add.php';
            break;
            case "admin/survey/excel":
                $menu_selector = 30;
                require 'views/survey/excel.php';
            break;
            case "admin/survey/delete":
                require 'views/survey/delete.php';
            break;
            case "admin/survey/delete-question":
                require 'views/survey/delete-question.php';
            break;
    
    
            case "admin/seo/list":
                $menu_selector = 33;
                require 'views/seo/list.php';
            break;
            case "admin/seo/edit":
                $menu_selector = 33;
                require 'views/seo/edit.php';
            break;
            case "admin/seo/add":
                $menu_selector = 33;
                require 'views/seo/add.php';
            break;
            case "admin/seo/delete":
                require 'views/seo/delete.php';
            break;
    
            case "admin/traffic/list":
                $menu_selector = 34;
                require 'views/traffic/list.php';
            break;
    
    
    
            case "admin/category/list":
                $menu_selector = 4;
                require 'views/category/list.php';
            break;
            case "admin/category/add":
                $menu_selector = 4;
                require 'views/category/add.php';
            break;
            case "admin/category/edit":
                $menu_selector = 4;
                require 'views/category/edit.php';
            break;
            case "admin/category/delete":
                $menu_selector = 4;
                require 'views/category/delete.php';
            break;
    
            case "admin/brands/list":
                $menu_selector = 3;
                require 'views/brand/list.php';
            break;
            case "admin/brands/add":
                $menu_selector = 3;
                require 'views/brand/add.php';
            break;
            case "admin/brands/edit":
                $menu_selector = 3;
                require 'views/brand/edit.php';
            break;
            case "admin/brands/delete":
                $menu_selector = 3;
                require 'views/brand/delete.php';
            break;

    
            case "admin/collections/list":
                $menu_selector = 96;
                require 'views/collections/list.php';
            break;
            case "admin/collections/add":
                $menu_selector = 96;
                require 'views/collections/add.php';
            break;
            case "admin/collections/edit":
                $menu_selector = 96;
                require 'views/collections/edit.php';
            break;
            case "admin/collections/delete":
                $menu_selector = 96;
                require 'views/collections/delete.php';
            break;
    
    
            case "admin/users/list":
                $menu_selector = 5;
                require 'views/users/list.php';
            break;
            case "admin/users/edit":
                $menu_selector = 6;
                require 'views/users/edit.php';
            break;
            case "admin/users/add":
                $menu_selector = 7;
                require 'views/users/add.php';
            break;
            case "admin/users/excel":
                $menu_selector = 8;
                require 'views/users/excel.php';
            break;
            case "admin/users/delete":
                require 'views/users/delete.php';
            break;
    
    
            case "admin/user-groups/list":
                $menu_selector = 9;
                require 'views/user-groups/list.php';
            break;
            case "admin/user-groups/edit":
                $menu_selector = 10;
                require 'views/user-groups/edit.php';
            break;
            case "admin/user-groups/add":
                $menu_selector = 11;
                require 'views/user-groups/add.php';
            break;
            case "admin/user-groups/delete":
                require 'views/user-groups/delete.php';
            break;
    
    
    
            case "admin/coupon-codes/list":
                $menu_selector = 12;
                require 'views/coupon-codes/list.php';
            break;
    
            case "admin/support-tickets/list":
                $menu_selector = 13;
                require 'views/support-tickets/list.php';
            break;
            case "admin/support-tickets/delete":
                $menu_selector = 14;
                require 'views/support-tickets/delete.php';
            break;
            case "admin/support-tickets/add":
                $menu_selector = 14;
                require 'views/support-tickets/add.php';
            break;
            case "admin/support-tickets/edit":
                $menu_selector = 14;
                require 'views/support-tickets/edit.php';
            break;
    
            case "admin/orders/list":
                $menu_selector = 15;
                require 'views/orders/list.php';
            break;
            case "admin/orders/edit":
                $menu_selector = 15;
                require 'views/orders/edit.php';
            break;
            case "admin/orders/excel":
                $menu_selector = 15;
                require 'views/orders/excel.php';
            break;
            case "admin/orders/gift-note":
                $menu_selector = 15;
                require 'views/orders/print-gift-note.php';
            break;
            case "admin/orders/shipping-label":
                $menu_selector = 15;
                require 'views/orders/print-shipping-label.php';
            break;
            case "admin/orders/receipt":
                $menu_selector = 15;
                require 'views/orders/print-order-details.php';
            break;
            case "admin/orders/receipt/print":
                $menu_selector = 15;
                require 'views/orders/print.php';
            break;
            case "admin/orders/shipping-label/print":
                $menu_selector = 15;
                require 'views/orders/shipping-label.php';
            break;
            case "admin/orders/abandoned":
                $menu_selector = 35;
                require 'views/orders/abandoned.php';
            break;
            case "admin/orders/new":
                $menu_selector = 16;
                require 'views/orders/new.php';
            break;
    
            case "admin/system-logs/list":
                $menu_selector = 19;
                require 'views/system-logs/list.php';
            break;
            case "admin/system-logs/delete":
                require 'views/system-logs/delete.php';
            break;
            case "admin/settings":
                $menu_selector = 20;
                require 'views/settings/index.php';
            break;
            case "admin/visual-settings":
                $menu_selector = 21;
                require 'views/settings/visual-settings.php';
            break;
            case "admin/homepage/list":
                $menu_selector = 21;
                require 'views/settings/homepage/list.php';
            break;
            case "admin/homepage/add":
                $menu_selector = 21;
                require 'views/settings/homepage/add.php';
            break;
            case "admin/homepage/edit":
                $menu_selector = 21;
                require 'views/settings/homepage/edit.php';
            break;
            case "admin/homepage/delete":
                require 'views/settings/homepage/delete.php';
            break;
            case "admin/sms/list":
                $menu_selector = 21;
                require 'views/settings/sms/list.php';
            break;
            case "admin/sms/add":
                $menu_selector = 21;
                require 'views/settings/sms/add.php';
            break;
            case "admin/sms/edit":
                $menu_selector = 21;
                require 'views/settings/sms/edit.php';
            break;
            case "admin/sms/delete":
                require 'views/settings/sms/delete.php';
            break;
    
    
            case "admin/admins/list":
                $menu_selector = 32;
                require 'views/settings/admins/list.php';
            break;
            case "admin/admins/edit":
                $menu_selector = 32;
                require 'views/settings/admins/edit.php';
            break;
            case "admin/admins/add":
                $menu_selector = 32;
                require 'views/settings/admins/add.php';
            break;
            case "admin/admins/delete":
                require 'views/settings/admins/delete.php';
            break;
    
            case "admin/admin-groups/list":
                $menu_selector = 37;
                require 'views/settings/admin-groups/list.php';
            break;
            case "admin/admin-groups/edit":
                $menu_selector = 37;
                require 'views/settings/admin-groups/edit.php';
            break;
            case "admin/admin-groups/add":
                $menu_selector = 37;
                require 'views/settings/admin-groups/add.php';
            break;
            case "admin/admin-groups/delete":
                require 'views/settings/admin-groups/delete.php';
            break;
    
    
            case "admin/cron":
                $menu_selector = 29;
                require 'views/cron/index.php';
            break;
            case "admin/cron/delete":
                $menu_selector = 29;
                require 'views/cron/delete.php';
            break;
    
            
            case "admin/slider/list":
                $menu_selector = 21;
                require 'views/settings/slider/list.php';
            break;
            case "admin/slider/edit":
                $menu_selector = 21;
                require 'views/settings/slider/edit.php';
            break;
            case "admin/slider/add":
                $menu_selector = 21;
                require 'views/settings/slider/add.php';
            break;
            case "admin/slider/delete":
                require 'views/settings/slider/delete.php';
            break;
            
    
            case "admin/topbar/list":
                $menu_selector = 21;
                require 'views/settings/topbar/list.php';
            break;
            case "admin/topbar/edit":
                $menu_selector = 21;
                require 'views/settings/topbar/edit.php';
            break;
            case "admin/topbar/add":
                $menu_selector = 21;
                require 'views/settings/topbar/add.php';
            break;
            case "admin/topbar/delete":
                require 'views/settings/topbar/delete.php';
            break;
            
            case "admin/banner/list":
                $menu_selector = 21;
                require 'views/settings/banner/list.php';
            break;
            case "admin/banner/edit":
                $menu_selector = 21;
                require 'views/settings/banner/edit.php';
            break;
            case "admin/banner/add":
                $menu_selector = 21;
                require 'views/settings/banner/add.php';
            break;
            case "admin/banner/delete":
                require 'views/settings/banner/delete.php';
            break;
            
            case "admin/product-badges/list":
                $menu_selector = 21;
                require 'views/settings/product-badges/list.php';
            break;
            case "admin/product-badges/edit":
                $menu_selector = 21;
                require 'views/settings/product-badges/edit.php';
            break;
            case "admin/product-badges/add":
                $menu_selector = 21;
                require 'views/settings/product-badges/add.php';
            break;
            case "admin/product-badges/delete":
                require 'views/settings/product-badges/delete.php';
            break;


            case "admin/menu-banners/list":
                $menu_selector = 21;
                require 'views/settings/menu-banners/list.php';
            break;
            case "admin/menu-banners/edit":
                $menu_selector = 21;
                require 'views/settings/menu-banners/edit.php';
            break;
            case "admin/menu-banners/add":
                $menu_selector = 21;
                require 'views/settings/menu-banners/add.php';
            break;
            case "admin/menu-banners/delete":
                require 'views/settings/menu-banners/delete.php';
            break;
    
            case "admin/menu/list":
                $menu_selector = 21;
                require 'views/settings/menu/list.php';
            break;
            case "admin/menu/edit":
                $menu_selector = 21;
                require 'views/settings/menu/edit.php';
            break;
            case "admin/menu/add":
                $menu_selector = 21;
                require 'views/settings/menu/add.php';
            break;
            case "admin/menu/delete":
                require 'views/settings/menu/delete.php';
            break;
    
            case "admin/file-manager":
                $menu_selector = 21;
                require 'views/file-manager/index.php';
            break;
    
    
            case "admin/shipping/list":
                $menu_selector = 36;
                require 'views/shipping/list.php';
            break;
            case "admin/shipping/edit":
                $menu_selector = 36;
                require 'views/shipping/edit.php';
            break;
            case "admin/shipping/add":
                $menu_selector = 36;
                require 'views/shipping/add.php';
            break;
            case "admin/shipping/delete":
                require 'views/shipping/delete.php';
            break;
    
    
            case "admin/blog/list":
                $menu_selector = 22;
                require 'views/blog/list.php';
            break;
            case "admin/blog/edit":
                $menu_selector = 22;
                require 'views/blog/edit.php';
            break;
            case "admin/blog/add":
                $menu_selector = 22;
                require 'views/blog/add.php';
            break;
            case "admin/blog/delete":
                require 'views/blog/delete.php';
            break;
    
            case "admin/blog-categories/list":
                $menu_selector = 23;
                require 'views/blog/categories/list.php';
            break;
            case "admin/blog-categories/edit":
                $menu_selector = 23;
                require 'views/blog/categories/edit.php';
            break;
            case "admin/blog-categories/add":
                $menu_selector = 23;
                require 'views/blog/categories/add.php';
            break;
            case "admin/blog-categories/delete":
                require 'views/blog/categories/delete.php';
            break;
    
            case "admin/pages/list":
                $menu_selector = 24;
                require 'views/pages/list.php';
            break;
            case "admin/pages/edit":
                $menu_selector = 24;
                require 'views/pages/edit.php';
            break;
            case "admin/pages/add":
                $menu_selector = 24;
                require 'views/pages/add.php';
            break;
            case "admin/pages/delete":
                require 'views/pages/delete.php';
            break;
    
            case "admin/faq/list":
                $menu_selector = 25;
                require 'views/faq/list.php';
            break;
            case "admin/faq/edit":
                $menu_selector = 25;
                require 'views/faq/edit.php';
            break;
            case "admin/faq/add":
                $menu_selector = 25;
                require 'views/faq/add.php';
            break;
            case "admin/faq/delete":
                require 'views/faq/delete.php';
            break;
            case "admin/faq/categories/list":
                $menu_selector = 26;
                require 'views/faq/categories/list.php';
            break;
            case "admin/faq/categories/edit":
                $menu_selector = 26;
                require 'views/faq/categories/edit.php';
            break;
            case "admin/faq/categories/add":
                $menu_selector = 26;
                require 'views/faq/categories/add.php';
            break;
            case "admin/faq/categories/delete":
                require 'views/faq/categories/delete.php';
            break;

            case "admin/paytr":
                $menu_selector = 99;
                require 'views/paytr/index.php';
            break;

            case "admin/cimri":
                $menu_selector = 95;
                require 'views/cimri/index.php';
            break;
            case "admin/cimri/excel":
                require 'views/cimri/excel.php';
            break;

            case "admin/akakce":
                $menu_selector = 97;
                require 'views/akakce/index.php';
            break;
            case "admin/akakce/excel":
                require 'views/akakce/excel.php';
            break;

            
            case "admin/sellers/list":
                $menu_selector = 98;
                require 'views/sellers/list.php';
            break;
            case "admin/sellers/edit":
                $menu_selector = 98;
                require 'views/sellers/edit.php';
            break;
            case "admin/sellers/add":
                $menu_selector = 98;
                require 'views/sellers/add.php';
            break;
            case "admin/sellers/delete":
                require 'views/sellers/delete.php';
            break;
        }
    }
?>