<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 defined %}
	{% set menuItems = getMenuItemsFromAlias('main') %}
{% endif %}

<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 %}
        {% if KOH_USE_WORDPRESS is not defined %}
        	{% set KOH_USE_WORDPRESS = true %}
        {% endif %}
        {% if KOH_USE_WORDPRESS == 'false' and menuItems is not null and menuItems|length > 0 %}
			{% import 'common/menu_tree_macro.html.twig' as tree %}
			{% set currentPath = app.request.requestUri %}
			{{ tree.menu(menuItems, currentPath) }}
		{% endif %}
		{# MENU UTILISATEUR AYANT ACCES A L'ADMIN CONNECTE #}
		{% if app.user and is_granted('ROLE_ADMIN') %}
			<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>{% if KOH_USE_WORDPRESS != 'false' %}<span class='ml-1 text-primary'>Administration</span>{% endif %}
				</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}}
						{% elseif app.user.groups|length > 0 %}
							{{app.user.groups[0].name}}
						{% elseif app.user.roles|length > 0 %}
							{{app.user.roles[0]}}
						{% else %}
							{{app.user.name}}
						{% endif %}
						{% if getCurrentGroupe() != null %}
							- {{ getCurrentGroupe() }}
						{% endif %}
						{% if getCurrentComptoir() != null %}
							- {{ getCurrentComptoir() }}
						{% endif %}
						{% if getCurrentPrestataire() != null %}
							- {{ getCurrentPrestataire() }}
						{% endif %}
						</span>
					</span>
				</a>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownUC">
                	{# COMPTE ou ECOMPTE  : @TODO : mettre plutôt dans le header en visible tout le temps ? #}
                	{% if app.user and is_granted('ROLE_ADHERENT') %}
                		<b class="dropdown-item bg-primary text-white"> Ecompte : {{app.user.adherent.ecompte }}</b>
                	{% elseif app.user and is_granted('ROLE_PRESTATAIRE') and getCurrentPrestataire() != null %}
                		<b class="dropdown-item bg-primary text-white"> Ecompte : {{getCurrentPrestataire().ecompte }}</b>
                	{% elseif getCurrentGroupe() != null %}
                		<b class="dropdown-item bg-primary text-white"> Compte : {{getCurrentGroupe().compte }}</b>
                	{% elseif getCurrentComptoir() != null %}
                		<b class="dropdown-item bg-primary text-white"> Compte : {{getCurrentComptoir().compte }}</b>
                	{% endif %}
                	{% if app.user.possiblegroups|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>
