@php
  if(!isset($menu_home) || ($menu_home=="")) $menu_home="";
  if(!isset($menu) || ($menu=="")) $menu="";
  if(!isset($submenu) || ($submenu=="")) $submenu="";
@endphp

<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">

  <li class="nav-item {!! ($menu=='edt')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link {!! ($menu=='edt')?'active':'' !!}">
      <p>BENEFICIAIRES<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('/home/allocations') !!}" class="nav-link {!! ($submenu=='allocations')?'active':'' !!}">
          <i class="nav-icon fas fa-people-roof"></i>
          <p>Allocations</p>
        </a>
      </li>
      <li class="nav-item ">
        <a href="{!! url('') !!}" class="nav-link {!! ($submenu=='edt-formateur')?'active':'' !!}">
          <i class="nav-icon fas fa-person-shelter"></i>
          <p>Aides sociales</p>
        </a>
      </li>
      <li class="nav-item ">
        <a href="{!! url('') !!}" class="nav-link {!! ($submenu=='edt-salle')?'active':'' !!}">
          <i class="nav-icon fas fa-person-cane"></i>
          <p>Retraites</p>
        </a>
      </li>
    </ul>
  </li>

  <li class="nav-item {!! ($menu=='enseignement')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link {!! ($menu=='enseignement')?'active':'' !!}">
      <p>RECOUVREMENT<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('') !!}" class="nav-link {!! ($submenu=='formateurs')?'active':'' !!}">
          <i class="nav-icon fas fa-industry"></i>
          <p>Entreprises</p>
        </a>
      </li>
    </ul>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('') !!}" class="nav-link {!! ($submenu=='cours')?'active':'' !!}">
          <i class="nav-icon fas fa-person-digging"></i>
          <p>Salariés</p>
        </a>
      </li>
    </ul>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('evaluations') !!}" class="nav-link {!! ($submenu=='evaluations')?'active':'' !!}">
          <i class="nav-icon fas fa-hand-holding-dollar"></i>
          <p>Cotisations</p>
        </a>
      </li>
    </ul>
  </li>
          
  <li class="nav-item {!! ($menu=='')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link {!! ($menu=='vie-scolaire')?'active':'' !!}">
      <p>MANDATEMENT<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('etudiants') !!}" class="nav-link {!! ($submenu=='etudiants')?'active':'' !!}">
          <i class="nav-icon fas fa-cash-register"></i>
          <p>Mandats</p>
        </a>
      </li>
    </ul>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('trombinoscope') !!}" class="nav-link {!! ($submenu=='trombinoscope')?'active':'' !!}">
          <i class="nav-icon fas fa-file-invoice"></i>
          <p>Imputations</p>
        </a>
      </li>
    </ul>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('groupes') !!}" class="nav-link {!! ($submenu=='groupes')?'active':'' !!}">
          <i class="nav-icon fas fa-money-bill-transfer"></i>
          <p>Transferts</p>
        </a>
      </li>
    </ul>
  </li>

  <!-- COMPTA -->
  <li class="nav-item {!! ($menu=='structures')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link {!! ($menu=='structures')?'active':'' !!}">
      <p>COMPTABILITE<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview ">
      <li class="nav-item ">
        <a href="{!! url('etablissements') !!}" class="nav-link {!! ($submenu=='etablissements')?'active':'' !!}">
          <i class="nav-icon fas fa-coins"></i>
          <p>Règlements</p>
        </a>
      </li>
    </ul>
  </li>

  <!-- ACCES -->
  @if($user->hasRole("ADMINISTRATEUR") || $user->can("consulter utilisateurs"))
  <li class="nav-item {!! ($menu=='acces')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link">
      <p>ACCES<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview">
      @if($user->hasRole("ADMINISTRATEUR") || $user->can("consulter utilisateurs"))
        <li class="nav-item">
          <a href="{!! url('users') !!}" class="nav-link {!! ($submenu=='utilisateurs')?'active':'' !!}">
            <i class="nav-icon fa fa-user"></i>
            <p>Utilisateurs</p>
          </a>
        </li>
      @endif

      @if($user->hasRole("ADMINISTRATEUR") || $user->can("consulter roles"))
        <li class="nav-item">
          <a href="{!! url('roles') !!}" class="nav-link  {!! ($submenu=='roles')?'active':'' !!}">
            <i class="nav-icon fa fa-lock"></i>
            <p>Rôles</p>
          </a>
        </li>
      @endif

      @if($user->hasRole("ADMINISTRATEUR"))
        <li class="nav-item">
          <a href="{!! url('permissions') !!}" class="nav-link  {!! ($submenu=='permissions')?'active':'' !!}">
            <i class="nav-icon fa fa-cogs"></i>
            <p>Permissions</p>
          </a>
        </li>
      @endif

      @if($user->hasRole("ADMINISTRATEUR")&&(1==0))
        <li class="nav-item">
          <a href="{!! url('import') !!}" class="nav-link  {!! ($submenu=='permissions')?'active':'' !!}">
            <i class="nav-icon fa fa-cogs"></i>
            <p>Import CalEdt</p>
          </a>
        </li>
      @endif
    </ul>
  </li>
  @endif

   <!-- STATISTIQUES -->
  <li class="nav-item {!! ($menu=='statistiques')?'menu-is-opening menu-open':'' !!}">
    <a href="#" class="nav-link">
      <p>STATISTIQUES<i class="fas fa-angle-left right"></i></p>
    </a>

    <ul class="nav nav-treeview">
        <li class="nav-item">
          <a href="{!! url('stat_cnx') !!}" class="nav-link {!! ($submenu=='connexions')?'active':'' !!}">
            <i class="nav-icon fa fa-chart-pie"></i>
            <p>Connexions</p>
          </a>
        </li>
    </ul>
  </li>

  <!-- PARMETRAGE GENERAL -->
  @if($user->hasRole("ADMINISTRATEUR") || $user->can("consulter parametres"))
    <li class="nav-item {!! ($menu=='parametres')?'menu-is-opening menu-open':'' !!}">
      <a href="#" class="nav-link">
        <p>PARAMETRES<i class="fas fa-angle-left right"></i></p>
      </a>

      <ul class="nav nav-treeview">
          <li class="nav-item">
            <a href="{!! url('parametres') !!}" class="nav-link {!! ($submenu=='generaux')?'active':'' !!}">
              <i class="nav-icon fa fa-gears"></i>
              <p>Généraux</p>
            </a>
          </li>
      </ul>
    </li>
  @endif

</ul>