{% include '@kohinos/block/demo_shortcut.html.twig' %}

{# ACTIONS PRINCIPALES POUR CHAQUE UTILISATEUR CONNECTE #}
<div id="accordion">
	{% if not app.request.session.has('_choixGroup') %}

		{# 
		// @TODO : Ajouter des raccourcis en fonction des droits de l'utilisateur : 
			- ajout d'un adhérent (avec reception de la cotisation en comptoir par exemple)
			- ajout d'un prestataire (avec reception de la cotisation en comptoir par exemple)
		{% if app.user and is_granted('ROLE_ADMIN_ADHERENT_GERER_CREATE') %}
			<a href='{{ path('adherent_create') }}' class='btn btn-secondary'>Créer un nouvel adhérent</a>
		{% endif %} #}

		{% if app.user and is_granted('ROLE_ADMIN_SIEGE') %}

			{% include '@kohinos/block/soldes_siege.html.twig' %}
			{% include '@kohinos/siege/block/solde_edit.html.twig' %}
			{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte billets non nantis', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_MLC'))} %}
			{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte eMLC nantie', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EMLC'))} %}
			{# {% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte fond de garanti', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %} #}
			{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte MLC nantie', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_MLC_NANTIE'))} %}
			{% include '@kohinos/siege/block/transfert_siegegroupe.html.twig' %}
			{% include '@kohinos/siege/block/transfert_groupesiege.html.twig' %}

		{% elseif app.user and is_granted('ROLE_REDACTEUR') %}

			{# Rien à ajouter pour un rédacteur #}

		{% elseif app.user and is_granted('ROLE_TRESORIER') %}

			{% include '@kohinos/block/soldes_siege.html.twig' %}
			{# {% include '@kohinos/block/soldegroupes.html.twig' %} #}

		{% elseif app.user and is_granted('ROLE_CONTROLEUR') %}

			{% include '@kohinos/block/soldes_siege.html.twig' %}

		{% elseif app.user and is_granted('ROLE_GESTION_GROUPE') %}

			{% if getCurrentGroupe() != null %}
				{% set compte = getCurrentGroupe().compte %}
				{% set soldelabel = 'Solde du groupe'|trans %}
				{% include '@kohinos/block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
			{% endif %}
			{% include '@kohinos/groupe/block/infos.html.twig' %}
			{# {% include '@kohinos/block/transactions.html.twig' %} #}
			{% include '@kohinos/block/operations.html.twig' %}
			{% include '@kohinos/groupe/block/transaction_comptoir.html.twig' %}
			{% include '@kohinos/groupe/block/retourgroupe.html.twig' %}

		{% elseif app.user and is_granted('ROLE_COMPTOIR') %}

			{% if getCurrentComptoir() != null %}
				{% set compte = getCurrentComptoir().mlcAccount.balance %}
				{% set soldelabel = 'Solde du comptoir "'|trans ~ getCurrentComptoir() ~ '"' %}
				{% include '@kohinos/block/solde.html.twig' with {'compte': compte, 'soldelabel': soldelabel} %}
			{% endif %}
			{% include '@kohinos/comptoir/block/infos.html.twig' %}
			{# {% include '@kohinos/block/transactions.html.twig' %} #}
			{% include '@kohinos/block/operations.html.twig' %}
			{% include '@kohinos/comptoir/block/vente_adherent.html.twig' %}
			{% include '@kohinos/comptoir/block/vente_prestataire.html.twig' %}
			{% include '@kohinos/comptoir/block/retrait_prestataire.html.twig' %}
			{% include '@kohinos/comptoir/block/retrait_adherent.html.twig' %}
			{% include '@kohinos/comptoir/block/reconversion.html.twig' %}
			{% include '@kohinos/comptoir/block/reconversion_adherent.html.twig' %}
			{% include '@kohinos/comptoir/block/vente_emlc_adherent.html.twig' %}
			{% include '@kohinos/comptoir/block/vente_emlc_prestataire.html.twig' %}

		{% elseif app.user and is_granted('ROLE_CONTACT') %}

			{% include '@kohinos/groupe/block/infos.html.twig' %}

		{% elseif app.user and is_granted('ROLE_SUPER_ADMIN') %}

			{% include '@kohinos/block/soldes_siege.html.twig' %}

		{% elseif app.user and is_granted('ROLE_PRESTATAIRE') and getCurrentPrestataire() != null %}

			{% set esoldelabel = 'Solde e-mlc'|trans %}
			{% include '@kohinos/block/solde.html.twig' with {'compte': getCurrentPrestataire().emlcAccount.balance, 'soldelabel': esoldelabel} %}
			{% if getCurrentPrestataire().mlc == false %}
				{% include '@kohinos/presta/block/infos.html.twig' %}
			{% endif %}
			{# {% include '@kohinos/block/transactions.html.twig' %} #}
			{% include '@kohinos/block/operations.html.twig' %}
			{% if getCurrentPrestataire().mlc == true %}
				{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte de fonctionnement €', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %}
			{% else %}
				{% include '@kohinos/block/cotisations.html.twig' %}
				{% include '@kohinos/groupepresta/block/inscription.html.twig' %}
			{% endif %}
			{% if isPayzenEnabled() %}
				{% include '@kohinos/presta/block/achat_monnaie.html.twig' %}
			{% else %}
				{% include '@kohinos/presta/block/demande_achat_monnaie.html.twig' %}
			{% endif %}
			{% include '@kohinos/presta/block/transaction_presta.html.twig' %}
			{% include '@kohinos/presta/block/transaction_adherent.html.twig' %}
			{% if getCurrentPrestataire().mlc == false and getCurrentPrestataire().emlcAccount.balance > 0 %}
				{% include '@kohinos/presta/block/reconversion.html.twig' %}
			{% endif %}

		{% elseif app.user and is_granted('ROLE_CAISSIER') and getCurrentPrestataire() != null %}

			{% include '@kohinos/block/transactions.html.twig' with {'title': 'Transactions'} %}

		{% elseif app.user and is_granted('ROLE_ADHERENT') and app.user.adherent %}

			{% set esoldelabel = 'Solde e-mlc'|trans %}
			{% include '@kohinos/block/solde.html.twig' with {'compte': app.user.adherent.emlcAccount.balance, 'soldelabel': esoldelabel} %}
			{% if isPayzenEnabled() %}
				{% include '@kohinos/adherent/block/achat_monnaie.html.twig' %}
			{% else %}
				{% include '@kohinos/adherent/block/demande_achat_monnaie.html.twig' %}
			{% endif %}
			{% include '@kohinos/adherent/block/transaction_presta.html.twig' %}
			{% include '@kohinos/adherent/block/transaction_adherent.html.twig' %}
			{# {% include '@kohinos/block/transactions.html.twig' %} #}
			{% include '@kohinos/block/operations.html.twig' %}
			{% include '@kohinos/block/cotisations.html.twig' %}
			{% include '@kohinos/adherent/block/infos.html.twig' %}

		{% else %}
			{# User not loggued #}
		{% endif %}

		{# Valider les demandes d'achat de monnaie si on a le droit #}
		{% if app.user and is_granted('ROLE_VALIDE_ACHAT') %}

		{% endif %}

		{# Affichage de la carte des prestataires pour les adhérents #}
		{% if KOH_USE_WORDPRESS is defined and KOH_USE_WORDPRESS == 'false' and ((app.user and is_granted('ROLE_ADHERENT')) or not app.user) %}
			{% include '@kohinos/presta/block/carte.html.twig' with {'title': 'Situer les Prestataires'|trans}%}
		{% endif %}
	{% endif %}
</div>
