<?php
$session = session();
$token = $session->get('token') ?? '';
$tfa = $session->get('tfa') ?? false;
$settings = $session->get('settings');

// Legacy TODO: check?
$picture = "/assets/img/default-user.png";
$pulse = session()->get('pulse');
$notification = session()->get('notification');

if (!empty($token) && $tfa == false) {
    //echo "<script>window.location.href = '/'; </script>";
}
?>

<!DOCTYPE html>

<html
        lang="<?= $session->get('lang') ?>"
        class="h-100"
        class="dark-style customizer-hide"
        dir="ltr"
        data-theme="theme-default"
        data-assets-path="<?= site_url('themes/vuexy/') ?>"
        data-template="vertical-menu-template-no-customizer"
>

<head>
    <meta charset="utf-8">
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title><?= lang("App.dashboard_title") ?> - <?= $settings['title']??'' ?></title>

    <meta name="description" content="" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="<?= site_url('themes/vuexy/img/favicon/favicon.ico') ?>"/>
    <link rel="apple-touch-icon" sizes="57x57" href="<?= site_url('themes/vuexy/img/favicon/apple-icon-57x57.png') ?>">
    <link rel="apple-touch-icon" sizes="60x60" href="<?= site_url('themes/vuexy/img/favicon/apple-icon-60x60.png') ?>">
    <link rel="apple-touch-icon" sizes="72x72" href="<?= site_url('themes/vuexy/img/favicon/apple-icon-72x72.png') ?>">
    <link rel="apple-touch-icon" sizes="76x76" href="<?= site_url('themes/vuexy/img/favicon/apple-icon-76x76.png') ?>">
    <link rel="apple-touch-icon" sizes="114x114"
          href="<?= site_url('themes/vuexy/img/favicon/apple-icon-114x114.png') ?>">
    <link rel="apple-touch-icon" sizes="120x120"
          href="<?= site_url('themes/vuexy/img/favicon/apple-icon-120x120.png') ?>">
    <link rel="apple-touch-icon" sizes="144x144"
          href="<?= site_url('themes/vuexy/img/favicon/apple-icon-144x144.png') ?>">
    <link rel="apple-touch-icon" sizes="152x152"
          href="<?= site_url('themes/vuexy/img/favicon/apple-icon-152x152.png') ?>">
    <link rel="apple-touch-icon" sizes="180x180"
          href="<?= site_url('themes/vuexy/img/favicon/apple-icon-180x180.png') ?>">
    <link rel="icon" type="image/png" sizes="192x192"
          href="<?= site_url('themes/vuexy/img/favicon/android-icon-192x192.png') ?>">
    <link rel="icon" type="image/png" sizes="32x32"
          href="<?= site_url('themes/vuexy/img/favicon/favicon-32x32.png') ?>">
    <link rel="icon" type="image/png" sizes="96x96"
          href="<?= site_url('themes/vuexy/img/favicon/favicon-96x96.png') ?>">
    <link rel="icon" type="image/png" sizes="16x16"
          href="<?= site_url('themes/vuexy/img/favicon/favicon-16x16.png') ?>">
    <link rel="manifest" href="<?= site_url('themes/vuexy/img/favicon/manifest.json') ?>">

    <!-- Fonts -->
    <link rel="preconnect" href="https:/fonts.googleapis.com"/>
    <link rel="preconnect" href="https:/fonts.gstatic.com" crossorigin/>
    <link
            href="https:/fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
            rel="stylesheet"
    />

    <!-- Icons -->
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/fonts/fontawesome.css') ?>"/>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/fonts/tabler-icons.css') ?>"/>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/fonts/flag-icons.css') ?>"/>

    <!-- Core CSS -->
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/rtl/core-dark.css') ?>"/>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/css/rtl/theme-default-dark.css') ?>"/>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/css/safekat.css') ?>"/>

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.css') ?>"/>
    <link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/node-waves/node-waves.css') ?>"/>

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="<?= site_url('themes/vuexy/vendor/js/helpers.js') ?>"></script>
    <script src="<?= site_url('themes/vuexy/js/config.js') ?>"></script>

</head>

<body>
<!--Main Wrapper-->
<div id="main-wrapper">
    <!--Nav Header-->
    <div class="nav-header">
        <a href="<?=site_url('home')?>" class="brand-logo">
            
        </a>
        <div class="nav-control">
            <div class="hamburger">
                <span class="line"></span><span class="line"></span><span class="line"></span>
            </div>
        </div>
    </div>
    <!--Header-->
    <div class="header">
        <div class="header-content">
            <nav class="navbar navbar-expand">
                <div class="collapse navbar-collapse justify-content-between">
                    <div class="header-left"></div>
                    <ul class="navbar-nav header-right">
                        <!--- JJO
                        <li class="nav-item dropdown notification_dropdown">
                            <a class="nav-link" href="#" role="button" data-toggle="dropdown">
                                <i class="fas fa-bell"></i>
                                <?php if ($pulse > 0) : ?>
                                    <div class="pulse-css text-danger"></div>
                                <?php endif; ?>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right">
                                <ul class="list-unstyled">
                                    <?php foreach ($notification??[] as $item) : ?>
                                        <a href="<?=site_url('my/notification_view/'.$item['token'])?>">
                                            <li class="media dropdown-item">
                                                <?php if ($item['is_read']) : ?>
                                                    <span class="success"><i class="far fa-envelope-open"></i> </span>
                                                <?php else : ?>
                                                    <span class="primary"><i class="far fa-envelope"></i> </span>
                                                <?php endif; ?>
                                                <div class="media-body">
                                                    <p><?=$item['title']?></p>
                                                </div>
                                                <span class="notify-time timeAgo"><?=$item['created_at']?></span>
                                            </li>
                                        </a>
                                    <?php endforeach; ?>
                                </ul>
                                <a class="all-notification" href="<?=site_url('my/notification')?>"><?= lang("App.notification_bell_btn") ?> <i class="ti-arrow-right"></i></a>
                            </div>
                        </li>
                        --->
                        <li class="nav-item dropdown header-profile">
                            <a class="nav-link" href="#" role="button" data-toggle="dropdown">
                                <i class="fas fa-globe-americas"></i>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right">
                                <a href="<?= site_url('lang/en'); ?>" class="dropdown-item">
                                    <img src="<?=site_url('assets/flags/us_32_circle.png')?>">
                                    <span class="ml-2"><?= lang("App.lang_en") ?></span>
                                </a>
                                <a href="<?= site_url('lang/es'); ?>" class="dropdown-item">
                                    <img src="<?=site_url('assets/flags/es_32_circle.png')?>">
                                    <span class="ml-2"><?= lang("App.lang_es") ?></span>
                                </a>
                            </div>
                        </li>
                        <li class="nav-item dropdown header-profile">
                            <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                <img src="<?= $picture??''?>" class="btn-circle btn-circle-sm" style="width: 50px ; height: 50px;">
                            </a>
                            <div class="dropdown-menu dropdown-menu-right">
                                <a href="<?= site_url('profile'); ?>" class="dropdown-item">
                                    <i class="fas fa-user"></i>
                                    <span class="ml-2"><?= lang("App.menu_profile") ?></span>
                                </a>
                                <!--- JJO
                                <a href="<?= site_url('activity'); ?>" class="dropdown-item">
                                    <i class="fas fa-list"></i>
                                    <span class="ml-2"><?= lang("App.menu_activity") ?></span>
                                </a>
                                --->
                                <a href="<?= site_url('logout'); ?>" class="dropdown-item">
                                    <i class="fas fa-sign-out-alt"></i>
                                    <span class="ml-2"><?= lang("App.menu_logout") ?></span>
                                </a>
                            </div>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>
    <?php include "selector_menu.php" ?>

