Commit fd2fc170 by Damien Moulard

Message de confirmation sur transactions & cotisations mlc

parent 05cd0b98
......@@ -68,6 +68,30 @@ function addGroupeForm($collectionHolder, $newLinkLi) {
$newLinkLi.before($newFormLi);
}
function showConfirmTransactionModal(div, form, montant, destinataire = null) {
// Get modal
var modal = $('#confirmTransactionModal')
// Get relevant confirmation message div
var message = modal.find(div)
// Set data in modal
message.find('.montant_transaction').text(montant)
if (destinataire != null) {
message.find('.nom_destinataire').text(destinataire)
}
// Show modal and relevant confirmation message
modal.find(div).show()
modal.modal('show')
// Bind modal validation button with form submition
$('#confirmTransactionModal #confirmTransactionButton').off()
$('#confirmTransactionModal #confirmTransactionButton').on('click', function(e){
form.submit()
});
}
jQuery(document).ready(function() {
// Get the ul that holds the collection of groupes
$collectionHolder = $('.groupeprestas');
......@@ -101,4 +125,52 @@ jQuery(document).ready(function() {
$("span.achat_monnaie_montant_choisi").text(value + ' €')
});
$('.transactionSubmit').on('click', function(e){
// Stop form submition
e.preventDefault();
var form = this.closest('form')
if (form.checkValidity()) {
// Get destinataire type : presta or adherent
var destinataire_type = $('#' + form.name + '_destinataireType')[0].value
if (destinataire_type == 'prestataire') {
var div = '.confirmTransactionPrestataire'
} else {
var div = '.confirmTransactionAdherent'
}
// Get destinataire
var destinataire_select = $('#' + form.name + '_destinataire')[0]
var destinataire_name = destinataire_select.options[destinataire_select.selectedIndex].text
// Get montant
var montant_field = $('#' + form.name + '_montant')[0]
var montant_value = montant_field.value
showConfirmTransactionModal(div, form, montant_value, destinataire_name)
} else {
// Use symfony validation
form.submit()
}
});
$('.cotisationSubmit').on('click', function(e){
// Stop form submition
e.preventDefault();
var form = this.closest('form')
if (form.checkValidity()) {
var div = '.confirmCotisation'
// Get montant
var montant_field = $('#' + form.name + '_montant')[0]
var montant_value = montant_field.value
showConfirmTransactionModal(div, form, montant_value)
} else {
// Use symfony validation
form.submit()
}
});
});
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@
"app": {
"js": [
"/build/runtime.420770e4.js",
"/build/app.296f92c9.js"
"/build/app.a5bdb92a.js"
],
"css": [
"/build/app.0ecb0d81.css"
......
......@@ -2,7 +2,7 @@
"build/admin.css": "/build/admin.4d653142.css",
"build/admin.js": "/build/admin.3024c297.js",
"build/app.css": "/build/app.0ecb0d81.css",
"build/app.js": "/build/app.296f92c9.js",
"build/app.js": "/build/app.a5bdb92a.js",
"build/runtime.js": "/build/runtime.420770e4.js",
"build/ckeditor/adapters/jquery.js": "/build/ckeditor/adapters/jquery.js",
"build/ckeditor/ckeditor.js": "/build/ckeditor/ckeditor.js",
......
......@@ -58,7 +58,7 @@ class UserController extends AbstractController
$cotisation->setMoyen(MoyenEnum::MOYEN_CB);
}
if ($form->isValid()) {
if ($form->get('payMLC')->isClicked()) {
if ($form->get('payMLC')->isClicked() || !$form->get('payMLC')->isClicked() && !$form->get('payCB')->isClicked()) {
$cotisation->setRecu(true);
$this->em->persist($cotisation);
$this->em->flush();
......
......@@ -94,7 +94,12 @@ class CotiserFormType extends AbstractType
// 'choices' => $canPayWithMlc ? [MoyenEnum::getTypeName(MoyenEnum::MOYEN_MLC) => MoyenEnum::MOYEN_MLC, MoyenEnum::getTypeName(MoyenEnum::MOYEN_CB) => MoyenEnum::MOYEN_CB] : [MoyenEnum::getTypeName(MoyenEnum::MOYEN_CB) => MoyenEnum::MOYEN_CB]
// ))
if ($canPayWithMlc) {
$builder->add('payMLC', SubmitType::class, ['label' => "Payer en eMLC"]);
$builder->add('payMLC', SubmitType::class, array(
'label' => "Payer en eMLC",
'attr' => [
'class' => 'btn-primary btn cotisationSubmit'
]
));
}
if ($canPayWithCB) {
$builder->add('payCB', SubmitType::class, ['label' => "Payer en CB"]);
......
......@@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
......@@ -30,7 +31,10 @@ class FluxFormType extends AbstractType
protected $container;
protected $session;
public function __construct(EntityManagerInterface $em, Security $security, ContainerInterface $container, SessionInterface $session)
public function __construct(EntityManagerInterface $em,
Security $security,
ContainerInterface $container,
SessionInterface $session)
{
$this->em = $em;
$this->security = $security;
......@@ -98,7 +102,9 @@ class FluxFormType extends AbstractType
'label' => 'Reference :',
'required' => true
))
->add('save', SubmitType::class, ['label' => "Valider"])
->add('save', SubmitType::class, array(
'label' => "Valider"
))
->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($builder) {
$flux = $event->getData();
if ($event->getForm()->isValid() && (!$flux || null === $flux->getId()) && $flux->getParenttype() == Flux::TYPE_COTISATION && $flux->getMoyen() == MoyenEnum::MOYEN_MLC) {
......
......@@ -28,6 +28,10 @@ class TransactionAdherentAdherentFormType extends TransactionFormType
'required' => true,
'label' => 'Adherent :',
))
->add('destinataireType', HiddenType::class, array(
'data' => 'adherent',
'mapped' => false
))
;
}
......
......@@ -26,7 +26,11 @@ class TransactionAdherentPrestataireFormType extends TransactionFormType
'choices' => $this->em->getRepository(Prestataire::class)->findBy(array('enabled' => true, 'mlc' => false), array('raison'=> 'ASC')),
'placeholder' => 'Prestataire',
'required' => true,
'label' => 'Prestataire :',
'label' => 'Prestataire :'
))
->add('destinataireType', HiddenType::class, array(
'data' => 'prestataire',
'mapped' => false
))
;
}
......
......@@ -5,6 +5,7 @@ namespace App\Form\Type;
use App\Enum\MoyenEnum;
use App\Form\Type\FluxFormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
class TransactionFormType extends FluxFormType
......@@ -15,6 +16,12 @@ class TransactionFormType extends FluxFormType
->add('moyen', HiddenType::class, array(
'data' => MoyenEnum::MOYEN_VIREMENT
))
->add('save', SubmitType::class, array(
'label' => "Valider",
'attr' => [
'class' => 'btn-primary btn transactionSubmit'
]
))
;
}
......
......@@ -28,6 +28,10 @@ class TransactionPrestataireAdherentFormType extends TransactionFormType
'required' => true,
'label' => 'Adherent :',
))
->add('destinataireType', HiddenType::class, array(
'data' => 'adherent',
'mapped' => false
))
;
}
......
......@@ -28,6 +28,10 @@ class TransactionPrestatairePrestataireFormType extends TransactionFormType
'required' => true,
'label' => 'Prestataire :',
))
->add('destinataireType', HiddenType::class, array(
'data' => 'prestataire',
'mapped' => false
))
;
}
......
......@@ -26,4 +26,4 @@
{{ form_row(form.save) }}
{% endif %}
{{ form_end(form) }}
{% endblock blockcontent %}
\ No newline at end of file
{% endblock blockcontent %}
......@@ -38,7 +38,8 @@
<input type="hidden" name="koh_map_center" id="koh_map_center" value='{{KOH_MAP_CENTER|default('')}}' />
<input type="hidden" name="koh_map_zoom" id="koh_map_zoom" value='{{KOH_MAP_ZOOM|default('')}}' />
{% include 'common/modale_choix_groupe.html.twig' %}
{% include 'common/modale_choix_groupe.html.twig' %}
{% include 'common/modale_confirmation_transaction.html.twig' %}
<!-- HEADER -->
{% block header %}
......
<!-- Modal -->
<div class="modal fade" id="confirmTransactionModal" tabindex="-1" role="dialog" aria-labelledby="confirmTransactionModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmTransactionModalTitle">{{ 'Vous allez effectuer une transaction'|trans }}</h5>
</div>
<div class="modal-body">
<div class="confirmTransactionPrestataire" style="display:none;">
<p>{{ 'Vous vous apprêtez à effectuer une transaction au prestataire'|trans }} <b><span class="nom_destinataire"></span></b> {{ 'd\'une valeur de'|trans }} <b><span class="montant_transaction"></span> {{ 'eMLC'|trans }}</b>.</p>
</div>
<div class="confirmTransactionAdherent" style="display:none;">
<p>{{ 'Vous vous apprêtez à effectuer une transaction à l\'adhérent'|trans }} <b><span class="nom_destinataire"></span></b> {{ 'd\'une valeur de'|trans }} <b><span class="montant_transaction"></span> {{ 'eMLC'|trans }}</b>.</p>
</div>
<div class="confirmCotisation" style="display:none;">
<p>{{ 'Vous vous apprêtez à cotiser.'|trans }} {{ 'Montant de votre cotisation :'|trans }} <b><span class="montant_transaction"></span> {{ 'eMLC'|trans }}</b></p>
</div>
<p>{{ 'Voulez-vous continuer ?'|trans }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Annuler'|trans }}</button>
<button type="button" class="btn btn-primary" id="confirmTransactionButton">{{ 'Confirmer'|trans }}</button>
</div>
</div>
</div>
</div>
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