{% if menuItems is not defined %}
	{% set menuItems = getMenuItemsFromAlias('main') %}
{% endif %}



<nav class="menu navbar navbar-expand-md navbar-light bg-light">
	<a class="navbar-brand" href="{{ url('index') }}">
		<img src="/images/logo.png" height="45" class="d-inline-block align-top" alt="{{KOH_MLC_NAME is defined ? KOH_MLC_NAME : ''}}">
	</a>
	<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
		<span class="navbar-toggler-icon"></span>
	</button>

	{% if menuItems is not null and menuItems|length > 0 %}
		{% import 'common/menu_tree_macro.html.twig' as tree %}
		{% set currentPath = app.request.requestUri %}
		<div class="collapse navbar-collapse" id="navbarSupportedContent">
			<ul class="navbar-nav ml-auto">
				{% if app.user is null %}
					<li class="nav-item dropdownmenu-item has-child dropdown" role="menu-item">
	                    <a href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle ">{{ 'Adhérer'|trans }}</a>
	                	<div class="dropdown-menu" aria-labelledby="navbarDropdown1">
							<a href="/adherer" class="dropdown-item ">{{ 'Adhérer à la MLC'|trans }}</a>
	                	</div>
	                </li>
	            {% endif %}
				{{ tree.menu(menuItems, currentPath) }}
				{# MENU UTILISATEUR AYANT ACCES A L'ADMIN CONNECTE #}
				{% if app.user and (isCurrentRoleGranted('ROLE_ADMIN_SIEGE') or
									isCurrentRoleGranted('ROLE_SUPER_ADMIN') or
									isCurrentRoleGranted('ROLE_TRESORIER') or
									isCurrentRoleGranted('ROLE_REDACTEUR') or
									isCurrentRoleGranted('ROLE_CONTACT') or
									isCurrentRoleGranted('ROLE_GESTION_GROUPE') or
									isCurrentRoleGranted('ROLE_COMPTOIR') or
									isCurrentRoleGranted('ROLE_CONTROLEUR')
									) %}
					<li class="nav-item" role="menu-item">
						<a href="{{ path('sonata_admin_dashboard') }}" class="nav-link" data-toggle="tooltip" data-placement="bottom" title="{{ 'Administration'|trans }}">
							<i class="fas fa-cog text-primary"></i>
						</a>
					</li>
				{% endif %}
				{# MENU UTILISATEUR CONNECTE #}
				{% if app.user %}
					<li class="nav-item dropdown" role="menu-item">
						<a href="#" id="navbarDropdownUC" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link parent dropdown-toggle" alt='{{ app.user.name }}'>
							<span style="{# font-size: 1em; color: grey; #}">
								<i class="fas fa-user"></i>
								<span class='ml-1'>
								{% if app.session.has('_groupId') %}
									{% set groupeUser = app.session.get('_groupId') %}
										{{groupeUser.name}}
								{% else %}
									{{app.user.groups[0].name}}
								{% endif %}
								{% if app.session.has('_groupegere') %}
									- {{app.session.get('_groupegere')}}
								{% endif %}
								{% if app.session.has('_comptoirgere') %}
									- {{app.session.get('_comptoirgere')}}
								{% endif %}
								{% if app.session.has('_prestagere') %}
									- {{app.session.get('_prestagere')}}
								{% endif %}
								</span>
							</span>
						</a>
	                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownUC">
	                    	{% if app.user.groups|length > 1 %}
		                    	<a href="#" class="viewChoiceGroup dropdown-item">{{ 'Choix du rôle'|trans }}</a>
		                    {% endif %}
		                    {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
							    <a href="{{path('index')}}?_switch_user=_exit" class="dropdown-item">{{ 'Retour SUPER ADMIN'|trans }}</a>
							{% endif %}
		                    <a href="{{ path('fos_user_security_logout') }}" class="dropdown-item">{{ 'Déconnexion'|trans }}</a>
	                    </div>
					</li>
				{% endif %}
			</ul>
		</div>
	{% endif %}

</nav>
