{% set cotisations = getValidCotisations(app.user, app.request) %}
{% if cotisations|length > 0 %}
	{% set idcard = 'cotisationspresta' %}
	{% extends '@kohinos/block/block_collapse.html.twig' %}

	{% block blocktitle %}
		<i class="fa fa-clipboard-list mr-4"></i> {{ 'Mes cotisations'|trans }}
	{% endblock blocktitle %}
	{% block blocksubtitle %}
	{% endblock blocksubtitle %}
	{% block blockcontent %}
		{% if false == isCotisationValid(app.user) %}
			{% if cotisations|length > 0 %}
				<div class='text-danger mb-3'>{{ 'Votre dernière cotisation est arrivée à expiration, veuillez cotiser de nouveau pour accéder aux fonctionnalités de votre compte !'|trans }}</div>
			{% else %}
				<div class='text-danger mb-3'>{{ 'Si vous souhaitez utiliser les fonctionnalités de votre compte, vous devez avoir une cotisation valide !'|trans }}</div>
			{% endif %}
		{% endif %}
		<ul class='list-group'>
			{% if cotisations|length <= 0 %}
				<em>{{ 'Aucunes cotisations à ce jour'|trans }}</em>
			{% else %}
				{% for cotisation in cotisations %}
					<li class="list-group-item"><span class='btn btn-xs btn-primary disabled'>{{cotisation.annee|upper}}</span> <b>{{cotisation.montant}}&euro;</b> <em> {{ 'payée le'|trans }} {{cotisation.createdAt|date('d/m/Y')}} en {{cotisation.moyen}}</em></li>
				{% endfor %}
			{% endif %}
		</ul>

		{% set cotisEnd = false %}
		{% if (app.user and is_granted('ROLE_ADHERENT') and app.user.adherent) %}
			{% set cotisEnd = isCotisationValidForAdherent(app.user.adherent) %}
		{% elseif (app.user and is_granted('ROLE_PRESTATAIRE') and app.session.has('_prestagere')) %}
			{% set cotisEnd = isCotisationValidForPresta(app.session.get('_prestagere')) %}
		{% endif %}
		{% if false != cotisEnd %}
			<span class='btn btn-secondary disabled mt-2' disabled='disabled'>
				{{ "Votre cotisation est à jour jusqu'au %date%" |trans({'%date%': cotisEnd|date('d/m/Y')}) }}
			</span>
			<a class='btn btn-xs btn-primary mt-2' href='{{ path('cotisernextyear') }}'>
				{{ "Cotiser pour l'année suivante"|trans }}
			</a>
		{% else %}
			<a class='btn btn-xs btn-primary mt-2' href='{{ path('cotiser') }}'>
				{{ 'Cotiser'|trans }}
			</a>
		{% endif %}
	{% endblock blockcontent %}
{% endif %}