<?php
require_once $_main_root . 'db/model.php';
require_once $_main_root . 'config/config.php';

$db = new Model();

$_userProfileImage = $_main_root . "img/user/" . User::UserName() . '.jpg';
if (!file_exists($_userProfileImage)) {
    $_userProfileImage = $_main_root . "img/user/default_user.png";
}
?>

<a class="navbar-brand" href=<?php echo ($_main_root . "content/dashboard.php"); ?>>
    <img src="<?php echo ($_main_root . 'img/logo.png'); ?>" width="150px" alt="" srcset="">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
    aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse menu_custom" id="navbarNav">
    <ul class="navbar-nav ms-auto">

        <?= $db->RenderMenu(); ?>

        <li class="nav-item dropdown ms-md-4">
            <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">
                <img src="<?php echo $_userProfileImage; ?>" alt="" width="30" height="30" class="rounded-circle">
                <?= User::UserName(); ?>
            </a>
            <ul class="dropdown-menu">
                <li>
                    <a class="dropdown-item" href=<?php echo ($_main_root . "content/profile.php"); ?>><i
                            class="bi bi-people me-3"></i> Profile</a>
                </li>
                <li>
                    <hr class="dropdown-divider">
                </li>
                <li class="text-center">
                    <a class="dropdown-item" href="<?php echo ($_main_root . 'db/do_logout.php'); ?>">LOGOUT<i
                            class="bi bi-box-arrow-right ms-2"></i></a>
                </li>
            </ul>
        </li>
    </ul>
</div>