Commit 991a6bc4 by Julien Jorry

Fix Adherer page with free amount above minimum + fix issue with return of…

Fix Adherer page with free amount above minimum + fix issue with return of adhesion + fix error on comptoir liste page
parent 46c7b24e
......@@ -5,10 +5,14 @@ namespace App\Controller;
use App\Entity\Adherent;
use App\Entity\Payment;
use App\Form\Type\AdhererFormType;
use Gamez\Symfony\Component\Serializer\Normalizer\UuidNormalizer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
class AdhesionController extends AbstractController
{
......@@ -27,15 +31,18 @@ class AdhesionController extends AbstractController
$adherentNew = $form->getData();
// Serialize form data in json to store with payment object and persist when payment is valid
$serializer = $this->container->get('serializer');
$encoders = [new JsonEncoder()];
$normalizers = [new UuidNormalizer(), new ObjectNormalizer()];
$serializer = new Serializer($normalizers, $encoders);
$data = $serializer->normalize(
$adherentNew,
null,
[AbstractNormalizer::ATTRIBUTES => ['user' => ['username', 'email', 'firstname', 'lastname', 'plainPassword'],
'groupe' => ['id'],
'geoloc' => ['adresse',
'cpostal',
'ville', ], ]]
'groupe' => ['id' => 'uuid'],
'geoloc' => ['adresse',
'cpostal',
'ville', ], ]]
);
$jsondata = $serializer->serialize($data, 'json');
......
......@@ -131,13 +131,13 @@ class FluxController extends AbstractController
// return new Response('', Response::HTTP_BAD_REQUEST);
// }
$form->handleRequest($request);
if ($form->isSubmitted() && !$this->tokenManager->isTokenValid($this->tokenManager->getToken("flux_form"))) {
if ($form->isSubmitted() && !$this->tokenManager->isTokenValid($this->tokenManager->getToken('flux_form'))) {
$referer = $request->headers->get('referer');
return $this->redirect($referer);
}
if ($form->isSubmitted() && $form->isValid()) {
$this->tokenManager->refreshToken("flux_form");
$this->tokenManager->refreshToken('flux_form');
$flux = $form->getData();
// try {
if ($this->operationUtils->executeOperations($flux)) {
......
......@@ -5,7 +5,6 @@ namespace App\Form\Type;
use App\Entity\Cotisation;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum;
use App\Form\Type\CotisationInfosFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
......@@ -13,6 +12,7 @@ use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
class AddCotisationFormType extends AbstractType
......@@ -29,22 +29,23 @@ class AddCotisationFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$now = new \DateTime();
$cotisationMinimum = intval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT));
$builder
->add('reference', HiddenType::class, array(
'label' => 'Reference :',
->add('reference', HiddenType::class, [
'required' => true,
'data' => 'Adhésion '.$now->format('d/m/Y')
))
->add('montant', IntegerType::class, array(
'data' => intval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT)),
'disabled' => true,
'data' => 'Adhésion ' . $now->format('d/m/Y'),
])
->add('montant', IntegerType::class, [
'label' => 'Montant en prix libre (minimum ' . $cotisationMinimum . '€) :',
'data' => $cotisationMinimum,
'constraints' => [
new NotBlank()
new NotBlank(),
new GreaterThanOrEqual(['value' => $cotisationMinimum]),
],
))
->add('moyen', HiddenType::class, array(
])
->add('moyen', HiddenType::class, [
'data' => MoyenEnum::MOYEN_CB,
))
])
;
}
......@@ -53,10 +54,10 @@ class AddCotisationFormType extends AbstractType
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => Cotisation::class,
'cascade_validation' => true
));
'cascade_validation' => true,
]);
}
public function getBlockPrefix()
......
......@@ -4,11 +4,7 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\Groupe;
use App\Enum\MoyenEnum;
use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
......@@ -34,38 +30,38 @@ class AdhererFormType extends AbstractType
{
$adherent = $options['data'];
$builder
->add('user', RegistrationFormType::class, array(
->add('user', RegistrationFormType::class, [
'label' => false,
'required' => true
))
->add('groupe', ChoiceType::class, array(
'required' => true,
])
->add('groupe', ChoiceType::class, [
'required' => true,
'label' => 'Groupe local',
'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findBy(['enabled' => true], ['name' => 'ASC']),
'choice_label' => 'name',
'choice_value' => 'id',
'placeholder' => 'Choisir un groupe',
))
->add('geoloc', GeolocFormType::class, array(
])
->add('geoloc', GeolocFormType::class, [
'label' => false,
'required' => true,
'with_geoloc' => false,
'with_latlon' => false
))
->add('cotisation', AddCotisationFormType::class, array(
'with_latlon' => false,
])
->add('cotisation', AddCotisationFormType::class, [
'label' => false,
'required' => true,
'mapped' => false,
'data_class' => null
))
->add('save', SubmitType::class, ['label' => "Payer en CB"]);
;
'data_class' => null,
])
->add('save', SubmitType::class, ['label' => 'Payer en CB']);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Adherent::class,
'cascade_validation' => true
'cascade_validation' => true,
]);
}
......
{% 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, 'currency' : KOH_MLC_SYMBOL|default('')} %}
{% 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' %} #}
\ No newline at end of file
{% trans_default_domain 'messages' %}
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="fr-FR"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="fr-FR">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{{title|default('Kohinos') }}</title>
<meta name="description" content="{{ description|default('Kohinos : Outil de gestion de monnaie locale complémentaire') }}" />
<meta name="keywords" content="{{ keywords|default('Kohinos, mlc, mlcc, monnaie locale, monnaies locales') }}" />
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
{# TMP : remove canonical link because generate a lot of CRITICAL error !
<link rel="canonical" href="{{ url(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) }}">
#}
{# FAVICON #}
{% block favicon %}
{# https://www.favicon-generator.org #}
<link rel="apple-touch-icon" sizes="57x57" href="/images/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/images/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/images/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/images/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/images/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/images/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/images/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/images/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon/favicon-16x16.png">
<link rel="manifest" href="/images/favicon/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/images/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
{% endblock favicon %}
{# POUR AJOUTER DES META ( like og: ) #}
{% block meta %} {% endblock meta %}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock stylesheets %}
<link rel="stylesheet" href="/leaflet/leaflet.css">
{# POUR AJOUTER DES CSS #}
{% block css %} {% endblock css %}
</head>
<body>
<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 '@kohinos/common/modale_choix_groupe.html.twig' %}
{% include '@kohinos/common/modale_confirmation_transaction.html.twig' %}
<!-- HEADER -->
{% block header %}
{% include '@kohinos/common/header.html.twig' %}
{% endblock header %}
<!-- CONTAINER -->
<div class="container">
{% include '@kohinos/common/flash-messages.html.twig' %}
{% block content %}
<!-- CONTENT -->
{% endblock content %}
</div>
<!-- FOOTER -->
{% block footer %}
{% include '@kohinos/common/footer.html.twig' %}
{% endblock footer %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock javascripts %}
{# POUR AJOUTER DES JS #}
{% block js %} {% endblock js %}
<script>
$(document).ready(function() {
{# Modification pour la doume : Payer autrement = uniquement par virement#}
$('input[name="formAchatMonnaieAConfirmerPrestataire[moyen]"][value="cheque"]').parent().addClass('d-none');
$('input[name="formAchatMonnaieAConfirmerPrestataire[moyen]"][value="helloasso"]').parent().addClass('d-none');
$('input[name="formAchatMonnaieAConfirmerPrestataire[moyen]"][value="virement"]').prop("checked", true);
});
</script>
{# AFFICHAGE DE LA MODALE DE CHOIX DU RÔLE (groupe associé aux rôles) #}
{% if showModalGroupChoice() %}
<script>
$(document).ready(function() {
$('#roleGroupeModal').modal('show');
});
</script>
{% endif %}
<script>
$('.viewChoiceGroup').on('click', function () {
$('#roleGroupeModal').modal('show');
});
</script>
{# https://stackoverflow.com/questions/34369951/how-to-get-add-to-home-screen-pop-up-on-site-open-in-mobile-browser #}
<script>
if ('serviceWorker' in navigator) {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/js/service-worker.js')
.then(function(reg){
}).catch(function(err) {
});
}
}
</script>
</body>
</html>
<div class="allrubriques">
<h4> <i class="fa fa-flag"></i> {{ 'Rubriques'|trans }}</h4>
<ul class="list-group">
{% for rubrique in getAllRubriques() %}
{% if rubrique.prestataires|length > 0 %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<a class='rubrique' href='{{ path('show_rubrique', {'slug': rubrique.slug}) }}'>
{% if rubrique.media is not null %}
<span style='width:100px;'>{% thumbnail rubrique.media, 'preview' with {'style': 'width: 25px; max-width: 25px'} %}</span>
{% endif %} {{rubrique.name}}
</a>
<span class="badge badge-primary badge-pill" data-toggle="tooltip" data-placement="bottom" title="{{rubrique.prestataires|length}} {{ 'prestataires'|trans }}">{{rubrique.prestataires|length}}</span>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
\ No newline at end of file
{% set prestaMLC = getMLCPrestataire() %}
{{ form_start(form) }}
{{ form_row(form.expediteur) }}
{{ form_row(form.destinataire) }}
{{ form_row(form.moyen) }}
<p id='demande_achat_text_cheque' class='demande_achat_text' style="display: none;">
{{ 'demande_achat_text_cheque'|trans({'%ordre%': prestaMLC.raison, '%adresse%' : ((prestaMLC.geolocs|length > 0) ? prestaMLC.geolocs[0].geoloc : '')}, 'flux')|raw }}
</p>
<p id='demande_achat_text_virement' class='demande_achat_text' style="display: none;">
{{ 'demande_achat_text_virement'|trans({'%iban%': prestaMLC.iban}, 'flux')|raw }}
</p>
<p id='demande_achat_text_helloasso' class='demande_achat_text' style="display: none;">
<a target='_blank' href='{{ prestaMLC.web|raw }}'>
{{ prestaMLC.web|raw }}
</a><br/>
<em>Préciser le montant, la date et la référence</em>
</p>
{{ form_row(form.montant) }}
{{ form_row(form.reference, {'label' : 'Référence du virement'}) }}
{{ form_row(form.save) }}
{{ form_end(form) }}
<a class='btn {{ hasDemandeAchatMonnaie(false) ? 'btn-warning' : 'btn-secondary' }}' href='{{ path('listachatMonnaieAConfirmer') }}'>Voir les demande(s) {{ hasDemandeAchatMonnaie(false) ? '('~getDemandeAchatMonnaie(false)|length~' en attente)' }}</a>
\ No newline at end of file
......@@ -15,7 +15,7 @@
{% endif %}
{% if comptoir.content != null %}
<p>
{% if news.content|striptags|length < 50 %}
{% if comptoir.content|striptags|length < 50 %}
{{ comptoir.content|striptags|raw }}
{% else %}
{{ comptoir.content|striptags|truncate(50, true, '...')|raw }}</p>
......
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