Commit a1cfaf23 by Damien Moulard

display cotisation amount from profile on comptoir encaissement cotisation

parent 4314a749
...@@ -100,4 +100,9 @@ legend.required:after { ...@@ -100,4 +100,9 @@ legend.required:after {
font-style: italic; font-style: italic;
margin-top: -10px; margin-top: -10px;
margin-bottom: 20px; margin-bottom: 20px;
}
.formEncaisserCotisationAdherent-no-profile {
font-style: italic;
color: #ff4136;
} }
\ No newline at end of file
...@@ -507,6 +507,32 @@ $(function() { ...@@ -507,6 +507,32 @@ $(function() {
$("#code-visual").text("*".repeat(code.length)); $("#code-visual").text("*".repeat(code.length));
}); });
$("#formEncaisserCotisationAdherent_destinataire").on("change", function() {
const cotisationMontants = JSON.parse($("#formEncaisserCotisationAdherent_cotisationMontants").val());
let cotisationmontant = cotisationMontants[this.value];
console.log(cotisationmontant);
if (cotisationmontant === undefined) {
$("#formEncaisserCotisationAdherent-montant-container").hide();
$("#formEncaisserCotisationAdherent-no-profile").hide();
return;
}
if (cotisationmontant !== null) {
$("#formEncaisserCotisationAdherent-montant-display").text(`${cotisationmontant} €`);
$("#formEncaisserCotisationAdherent-montant-container").show();
$("#formEncaisserCotisationAdherent-no-profile").hide();
$("#formEncaisserCotisationAdherent_save").prop("disabled",false);
} else {
// no cotisation profile
$("#formEncaisserCotisationAdherent-montant-container").hide();
$("#formEncaisserCotisationAdherent-no-profile").show();
$("#formEncaisserCotisationAdherent_save").prop("disabled",true);
}
});
// $('.js-datepicker').datepicker({ // $('.js-datepicker').datepicker({
// closeText: 'Fermer', // closeText: 'Fermer',
// prevText: '<Préc', // prevText: '<Préc',
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
"app": { "app": {
"js": [ "js": [
"/build/runtime.6ad5c9da.js", "/build/runtime.6ad5c9da.js",
"/build/app.07dbfd30.js" "/build/app.e59ff819.js"
], ],
"css": [ "css": [
"/build/app.0815270c.css" "/build/app.2a0f820a.css"
] ]
}, },
"admin": { "admin": {
......
{ {
"build/app.css": "/build/app.0815270c.css", "build/app.css": "/build/app.2a0f820a.css",
"build/app.js": "/build/app.07dbfd30.js", "build/app.js": "/build/app.e59ff819.js",
"build/admin.css": "/build/admin.5dc0eea7.css", "build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.8a6adf4b.js", "build/admin.js": "/build/admin.8a6adf4b.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js", "build/runtime.js": "/build/runtime.6ad5c9da.js",
......
...@@ -51,6 +51,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; ...@@ -51,6 +51,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment; use Twig\Environment;
/** /**
...@@ -92,6 +93,7 @@ class FluxController extends AbstractController ...@@ -92,6 +93,7 @@ class FluxController extends AbstractController
protected $operationUtils; protected $operationUtils;
protected $tokenGenerator; protected $tokenGenerator;
protected $validator; protected $validator;
protected $router;
public function __construct( public function __construct(
Security $security, Security $security,
...@@ -107,7 +109,8 @@ class FluxController extends AbstractController ...@@ -107,7 +109,8 @@ class FluxController extends AbstractController
OperationUtils $operationUtils, OperationUtils $operationUtils,
TokenGeneratorInterface $tokenGenerator, TokenGeneratorInterface $tokenGenerator,
ValidatorInterface $validator, ValidatorInterface $validator,
CsrfTokenManagerInterface $tokenManager CsrfTokenManagerInterface $tokenManager,
RouterInterface $router
) { ) {
$this->security = $security; $this->security = $security;
$this->em = $em; $this->em = $em;
...@@ -123,6 +126,7 @@ class FluxController extends AbstractController ...@@ -123,6 +126,7 @@ class FluxController extends AbstractController
$this->tokenGenerator = $tokenGenerator; $this->tokenGenerator = $tokenGenerator;
$this->validator = $validator; $this->validator = $validator;
$this->tokenManager = $tokenManager; $this->tokenManager = $tokenManager;
$this->router = $router;
} }
protected function manageFluxForm(Request $request, Form $form, $template = '@kohinos/flux/transaction.html.twig', $params = []) protected function manageFluxForm(Request $request, Form $form, $template = '@kohinos/flux/transaction.html.twig', $params = [])
......
...@@ -21,6 +21,8 @@ use App\Form\Type\VenteComptoirAdherentFormType; ...@@ -21,6 +21,8 @@ use App\Form\Type\VenteComptoirAdherentFormType;
use App\Form\Type\VenteComptoirPrestataireFormType; use App\Form\Type\VenteComptoirPrestataireFormType;
use App\Form\Type\VenteEmlcAdherentFormType; use App\Form\Type\VenteEmlcAdherentFormType;
use App\Form\Type\VenteEmlcPrestataireFormType; use App\Form\Type\VenteEmlcPrestataireFormType;
use App\Form\Type\EncaisserCotisationAdherentFormType;
use App\Form\Type\EncaisserCotisationAdherentValidationFormType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
...@@ -186,4 +188,50 @@ class UserComptoirController extends FluxController ...@@ -186,4 +188,50 @@ class UserComptoirController extends FluxController
$form $form
); );
} }
/**
* @Route("/user/comptoir/encaisser/cotisation/adherent/", name="comptoirEncaisserCotisation")
* @IsGranted("ROLE_COMPTOIR")
*/
public function comptoirEncaisserCotisationAction(Request $request)
{
$entity = new VenteEmlcComptoirAdherent();
$entity->setOperateur($this->getUser());
$form = $this->createForm(EncaisserCotisationAdherentFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$flux = $form->getData();
$destinataire = $flux->getDestinataire();
$profile = $destinataire->getProfilDeCotisation();
if (is_null($profile)) {
$this->addFlash(
'error',
$this->translator->trans('Opération impossible : l\'habitant.e n\'a pas de profil de cotisation associé.')
);
return $this->redirectToRoute('index');
}
$flux->setMontant($profile->getMontant());
$this->em->persist($flux);
$this->operationUtils->executeOperations($flux);
$this->em->flush();
$this->addFlash(
'success',
$this->translator->trans('Opération réussie !')
);
}
$this->addFlash(
'error',
$this->translator->trans('Opération impossible : l\'habitant.e n\'a pas de profil de cotisation associé.')
);
return $this->redirectToRoute('index');
}
} }
...@@ -51,6 +51,7 @@ use App\Form\Type\UserInfosFormType; ...@@ -51,6 +51,7 @@ use App\Form\Type\UserInfosFormType;
use App\Form\Type\VenteEmlcAdherentFormType; use App\Form\Type\VenteEmlcAdherentFormType;
use App\Form\Type\VenteEmlcPrestataireFormType; use App\Form\Type\VenteEmlcPrestataireFormType;
use App\Form\Type\SetPaymentCodeFormType; use App\Form\Type\SetPaymentCodeFormType;
use App\Form\Type\EncaisserCotisationAdherentFormType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Form\Type\ChangePasswordFormType; use FOS\UserBundle\Form\Type\ChangePasswordFormType;
use Symfony\Component\Form\FormFactoryInterface as FormF; use Symfony\Component\Form\FormFactoryInterface as FormF;
...@@ -444,4 +445,17 @@ class FormFactory ...@@ -444,4 +445,17 @@ class FormFactory
return $form->createView(); return $form->createView();
} }
public function getComptoirEncaisserCotisationForm(User $user)
{
if (empty($user) || empty($this->session->get('_comptoirgere'))) {
throw new \Exception('[FORM 26] Opération impossible !');
}
$entity = new AchatMonnaieAdherent();
$entity->setOperateur($user);
$form = $this->ff->create(EncaisserCotisationAdherentFormType::class, $entity, ['action' => $this->router->generate('comptoirEncaisserCotisation')]);
return $form->createView();
}
} }
<?php
namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\Adherent;
use App\Entity\VenteEmlcComptoirAdherent;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class EncaisserCotisationAdherentFormType extends VenteEmlcAdherentFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM VENTE EMLC] Opération impossible !');
}
$adherents = $this->em->getRepository(Adherent::class)->findOrderByName();
$adherentsProfiles = [];
foreach ($adherents as $adh) {
$montant = null;
if (!is_null($adh->getProfilDeCotisation()) ) {
$montant = $adh->getProfilDeCotisation()->getMontant();
}
$adherentsProfiles[strval($adh->getId())] = $montant;
}
$builder
->add('reference', HiddenType::class, [
'data' => 'Encaissement cotisation adhérent'
])
->add('montant', HiddenType::class, [
'data' => 0
])
->add('cotisationMontants', HiddenType::class, [
'data' => json_encode($adherentsProfiles),
'mapped' => false
])
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'class' => VenteEmlcComptoirAdherent::class,
]);
}
public function getParent()
{
return VenteEmlcAdherentFormType::class;
}
public function getBlockPrefix()
{
return 'formEncaisserCotisationAdherent';
}
}
...@@ -53,6 +53,7 @@ class FormExtension extends AbstractExtension ...@@ -53,6 +53,7 @@ class FormExtension extends AbstractExtension
new \Twig_SimpleFunction('getTicketFixPrintForm', [$this, 'getTicketFixPrintForm']), new \Twig_SimpleFunction('getTicketFixPrintForm', [$this, 'getTicketFixPrintForm']),
new \Twig_SimpleFunction('getTicketFixDestroyForm', [$this, 'getTicketFixDestroyForm']), new \Twig_SimpleFunction('getTicketFixDestroyForm', [$this, 'getTicketFixDestroyForm']),
new \Twig_SimpleFunction('getSetPaymentCodeForm', [$this, 'getSetPaymentCodeForm']), new \Twig_SimpleFunction('getSetPaymentCodeForm', [$this, 'getSetPaymentCodeForm']),
new \Twig_SimpleFunction('getComptoirEncaisserCotisationForm', [$this, 'getComptoirEncaisserCotisationForm']),
]; ];
} }
...@@ -205,4 +206,9 @@ class FormExtension extends AbstractExtension ...@@ -205,4 +206,9 @@ class FormExtension extends AbstractExtension
{ {
return $this->container->get('app.formfactory')->getSetPaymentCodeForm($user); return $this->container->get('app.formfactory')->getSetPaymentCodeForm($user);
} }
public function getComptoirEncaisserCotisationForm(User $user)
{
return $this->container->get('app.formfactory')->getComptoirEncaisserCotisationForm($user);
}
} }
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
{% include '@kohinos/comptoir/block/retrait_adherent.html.twig' %} {% include '@kohinos/comptoir/block/retrait_adherent.html.twig' %}
{% include '@kohinos/comptoir/block/reconversion.html.twig' %} {% include '@kohinos/comptoir/block/reconversion.html.twig' %}
{% include '@kohinos/comptoir/block/reconversion_adherent.html.twig' %} {% include '@kohinos/comptoir/block/reconversion_adherent.html.twig' %}
{% endif %} {% include '@kohinos/comptoir/block/vente_emlc_adherent.html.twig' %}
{% include '@kohinos/comptoir/block/vente_emlc_adherent.html.twig' %}
{% if not tav_env %}
{% include '@kohinos/comptoir/block/vente_emlc_prestataire.html.twig' %} {% include '@kohinos/comptoir/block/vente_emlc_prestataire.html.twig' %}
{% else %}
{% include '@kohinos/tav/block/comptoir_encaisser_cotisation.html.twig' %}
{% endif %} {% endif %}
{% endif %} {% endif %}
\ No newline at end of file
{% extends '@kohinos/block/onetransaction.html.twig' %}
{% block blocktitle %}
<i class="fa fa-exchange fa-exchange-alt mr-4"></i> {{ 'Encaisser la cotisation d\'un habitant'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% if app.session.has('_comptoirgere') %}
<div id="formEncaisserCotisationAdherent-montant-container" style="display:none">
<h5> <b>Montant de la cotisation : <span id="formEncaisserCotisationAdherent-montant-display"></span></b></h5>
<br/>
</div>
<div id="formEncaisserCotisationAdherent-no-profile" style="display:none">
<p class="formEncaisserCotisationAdherent-no-profile">
L'habitant•e n'a pas de profil de cotisation affecté, impossible de l'encaisser.
</p>
</div>
{% set form = getComptoirEncaisserCotisationForm(app.user) %}
{{ parent() }}
{% else %}
<span><em> {{ 'Aucun Comptoir assigné ! Veuillez contacter un administrateur !'|trans }} </em></span>
{% endif %}
{% 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