Commit c53a92cc by Damien Moulard

check if cotisation profile exists on adherent side

parent d32f7a49
...@@ -109,7 +109,7 @@ class FluxController extends AbstractController ...@@ -109,7 +109,7 @@ class FluxController extends AbstractController
TAVCotisationUtils $tavCotisationsUtils, TAVCotisationUtils $tavCotisationsUtils,
TokenGeneratorInterface $tokenGenerator, TokenGeneratorInterface $tokenGenerator,
ValidatorInterface $validator, ValidatorInterface $validator,
CsrfTokenManagerInterface $tokenManager, CsrfTokenManagerInterface $tokenManager
) { ) {
$this->security = $security; $this->security = $security;
$this->em = $em; $this->em = $em;
......
...@@ -137,6 +137,7 @@ class UserAdherentController extends FluxController ...@@ -137,6 +137,7 @@ class UserAdherentController extends FluxController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// TODO: set CB payment when the functionality is validated // TODO: set CB payment when the functionality is validated
$flux = $form->getData(); $flux = $form->getData();
// Look for existing cotisation // Look for existing cotisation
...@@ -149,6 +150,18 @@ class UserAdherentController extends FluxController ...@@ -149,6 +150,18 @@ class UserAdherentController extends FluxController
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
$destinataire = $flux->getDestinataire();
$profile = $destinataire->getProfilDeCotisation();
if (is_null($profile)) {
$this->addFlash(
'error',
$this->translator->trans('Opération impossible : vous n\'avez pas de profil de cotisation associé. Veuillez contacter un administrateur.')
);
return $this->redirectToRoute('index');
}
if (null == $flux->getDon() || 0 == $flux->getDon()->getMontant()) { if (null == $flux->getDon() || 0 == $flux->getDon()->getMontant()) {
$flux->setDon(null); $flux->setDon(null);
} }
......
...@@ -40,7 +40,7 @@ class AchatMonnaieFormType extends FluxFormType ...@@ -40,7 +40,7 @@ class AchatMonnaieFormType extends FluxFormType
if (null != $profilDeCotisation) { if (null != $profilDeCotisation) {
$montant = $profilDeCotisation->getMontant(); $montant = $profilDeCotisation->getMontant();
} else { } else {
$montant = intval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT_DEFAULT)); $montant = false;
} }
$builder $builder
......
...@@ -6,22 +6,27 @@ ...@@ -6,22 +6,27 @@
{% block blockcontent %} {% block blockcontent %}
{% set form = getPayerCotisationTAVForm(app.user) %} {% set form = getPayerCotisationTAVForm(app.user) %}
<p> {% if form.montant.vars.value == false %}
{{ 'Montant de la cotisation à payer'|trans }} : <span class="paiement_cotisation_montant">{{ form.montant.vars.value }}</span> <p>{{ 'Vous n\'avez pas de profil de cotisation associé, vous ne pouvez donc pas payer de cotisation.'|trans }}</p>
</p> <p>{{ 'Veuillez contacter un administrateur.'|trans }}</p>
{% else %}
<p>
{{ 'Montant de la cotisation à payer'|trans }} : <span class="paiement_cotisation_montant">{{ form.montant.vars.value }}</span>
</p>
{{form_start(form)}}
{% if form.don is defined %}
{{ form_row(form.don, {row_attr:{style: 'max-width: 200px;margin: 0 auto;'}}) }}
<hr/>
<p><b>{{ 'TOTAL A PAYER'|trans }} : <span class="achat_monnaie_montant_total">{{ form.montant.vars.value }}</span></b></p>
{% endif %}
{% if form.save is defined %}
{{ form_widget(form.save) }}
{% endif %}
{% if form.saveHelloAsso is defined %}
{{ form_widget(form.saveHelloAsso) }}
{% endif %}
{{form_end(form)}}
{% endif %}
{{form_start(form)}}
{% if form.don is defined %}
{{ form_row(form.don, {row_attr:{style: 'max-width: 200px;margin: 0 auto;'}}) }}
<hr/>
<p><b>{{ 'TOTAL A PAYER'|trans }} : <span class="achat_monnaie_montant_total">{{ form.montant.vars.value }}</span></b></p>
{% endif %}
{% if form.save is defined %}
{{ form_widget(form.save) }}
{% endif %}
{% if form.saveHelloAsso is defined %}
{{ form_widget(form.saveHelloAsso) }}
{% endif %}
{{form_end(form)}}
{% endblock blockcontent %} {% endblock blockcontent %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment