<!-- Sidebar Menu -->
<nav class="mt-2">
    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
        <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
        <?php
        foreach ($menus as $menu) :
            if ($menu['accesslevel'] >= $user->accesslevel) :
                $temp = getContent();
                $main = '';
                if(isset($temp[0])){
                    $main = $temp[0]['menuurl'];
                }
        ?>
                <li class="nav-item <?php  echo ($menu['menuurl']==$main)?'menu-open':''?>">
                    <a class="nav-link <?php  echo ($menu['menuurl']==$main)?'active':'1'?>">
                        <i class="nav-icon fas <?php echo $menu['icon'] ?>"></i>
                        <p>
                            <?php echo $menu['menuname'] ?>
                            <?php
                            if (isset($menu['submenu']) && $menu['accesslevel'] >= $user->accesslevel) :
                            ?>
                                <i class="fas fa-angle-left right"></i>
                            <?php
                            endif;
                            ?>
                        </p>
                    </a>
                    <?php
                    //echo $menu['accesslevel']." # ".$user->accesslevel;
                    if (isset($menu['submenu']) && $menu['accesslevel'] >= $user->accesslevel) :
                    ?>
                        <ul class="nav nav-treeview">
                            <?php
                            foreach ($menu['submenu'] as $submenu) :
                                if(isset($temp[1]))
                                    $sub= $temp[1]['menuurl'];
                                if ($submenu['accesslevel'] >= $user->accesslevel) :
                            ?>
                                    <li class="nav-item">
                                        <a href="<?php echo SITEURL . '/' . $menu['menuurl'] . "/" . $submenu['menuurl'] ?>" class="nav-link <?php  echo ($submenu['menuurl']==$sub)?'active':''?>">
                                            <i class="fas  <?php echo $submenu['icon'] ?> nav-icon"></i>
                                            <p><?php echo $submenu['menuname'] ?></p>
                                        </a>
                                    </li>
                            <?php
                                endif;
                            endforeach;
                            ?>
                        </ul>
                    <?php
                    endif;
                    ?>
                </li>
        <?php
            endif;
        endforeach;
        ?>
    </ul>
</nav>
<!-- /.sidebar-menu -->