{% extends '@kohinos/common/layout.html.twig' %}

{% block content %}
	{% if app.request.session.has('_solidoumeSubmit') and item is not null %}
		{% include '@kohinos/solidoume/modale_confirmation_solidoume.html.twig' %}
	{% endif %}

	<div class='container homepage'>
		{% include '@kohinos/block/breadcrumb.html.twig' with {'label' : param.name } %}
		<div class="card mx-auto mt-2">
			<div class="card-header">{{ param.name }}</div>
			<div class="card-body">
				<p>{{ param.descriptionCotisation|raw }}</p><br/><br/>
				<div class="mx-auto text-center" style="max-width: 600px;">
					{{form_start(form)}}
						<input type="hidden" name="referer" value="{{app.request.headers.get('referer')}}"/>
						<input type="hidden" id="{{form.vars.id~'_balance'}}" nmae="{{form.vars.id~'_balance'}}" value="{{app.user.adherent.getAccountWithCurrency(constant('App\\Enum\\CurrencyEnum::CURRENCY_EMLC')).balance}}"/>
						{{ form_row(form.user) }}
						{{ form_row(form.adherent) }}
						{{ form_row(form.amount) }}
						{{ form_row(form.isRecurrent) }}
						{{ form_row(form.paiementDate) }}
						{{ form_row(form.isDonation) }}
						<div class='row mt-4'>
							<p class='text-danger my-2' id='{{form.vars.id~'_error'}}' style="display:none;">
								{{ 'Votre solde (%balance% e%symbol%) est inférieur au montant'|trans({'%balance%': app.user.adherent.getAccountWithCurrency(constant('App\\Enum\\CurrencyEnum::CURRENCY_EMLC')).balance, '%symbol%': KOH_MLC_SYMBOL|default('Mlc') }) }}
							</p>
							{% if getSolidoumeParticipation() == null %}
								<div class='col-12'>
									{{ form_widget(form.save) }}
								</div>
							{% else %}
								<div class='col-6'>
									<a class='btn btn-outline-danger' href='{{ path('solidoume_unsubscribe') }}'>Se désinscrire</a>
								</div>
								<div class='col-6'>
									{{ form_widget(form.save, {label: 'Modifier ma participation'}) }}
								</div>
							{% endif %}
						</div>
					{{form_end(form)}}
		 		</div>
		 	</div>
		</div>
	</div>
{% endblock %}

{% block js %}
	<script>
		$(document).ready(function() {
			{% if app.request.session.has('_solidoumeSubmit') and item is not null %}
				$("#confirmSolidoumeModal").modal('show');
			{% endif %}
		});
	</script>
{% endblock js %}