<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 and ((KOH_USE_WORDPRESS is defined and KOH_USE_PAYZEN == 'true') or (KOH_USE_HELLOASSO  is defined and KOH_USE_HELLOASSO == 'true')) and not tav_env %}

			<li class="nav-item dropdownmenu-item has-child dropdown" role="menuitem">
                <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 '@kohinos/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="menuitem">
				<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 %}
		{% set printBugReport = KOH_BUG_REPORT|default('') %}
        {% if app.user and (is_granted('ROLE_ADMIN') and printBugReport == 'ROLE_ADMIN') or (is_granted('ROLE_USER') and printBugReport == 'ROLE_USER') %}
			<li class="nav-item" role="menuitem">
				<a class='nav-link text-warning' href='{{ path('bugreport') }}' target='_blank' rel="noopener noreferrer" data-toggle="tooltip" data-placement="bottom" title="{{ 'Reporter un bug'|trans }}">
					<i class="fas fa-bug"></i>
				</a>
			</li>
		{% endif %}
		{# MENU UTILISATEUR CONNECTE #}
		{% if app.user %}
			<li class="nav-item dropdown" role="menuitem">
				<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') and app.session.get('_groupId').name != 'ROLE_USER' %}
							{% set groupeUser = app.session.get('_groupId') %}
								{{groupeUser.name}}
						{% elseif app.user.groups|length > 0 %}
							{% if app.user.groups[0].name != 'ROLE_USER' %}
								{{app.user.groups[0].name}}
							{% else %}
								{{app.user.name}}
							{% endif %}
						{% elseif app.user.roles|length > 0 %}
							{% if app.user.roles[0] != 'ROLE_USER' %}
								{{app.user.roles[0]}}
							{% else %}
								{{app.user.name}}
							{% endif %}
						{% 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 app.user.adherent and is_granted('ROLE_ADHERENT') %}
                		<b class="dropdown-item bg-primary text-white"> Ecompte : {{app.user.adherent.emlcAccount.balance }}</b>
                	{% elseif app.user and is_granted('ROLE_PRESTATAIRE') and getCurrentPrestataire() != null %}
                		<b class="dropdown-item bg-primary text-white"> Ecompte : {{getCurrentPrestataire().emlcAccount.balance }}</b>
                	{% elseif getCurrentGroupe() != null %}
                		<b class="dropdown-item bg-primary text-white"> Compte : {{getCurrentGroupe().mlcAccount.balance }}</b>
                	{% elseif getCurrentComptoir() != null %}
                		<b class="dropdown-item bg-primary text-white"> Compte : {{getCurrentComptoir().mlcAccount.balance }}</b>
                	{% endif %}
                	{% if app.user %}
                		<a href="{{path('myaccount')}}" class="dropdown-item">{{ 'Mon compte'|trans }}</a>
                	{% 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>
