Commit 5ec3bd09 by Damien Moulard

WIP role habitant screen

parent d1437332
......@@ -215,8 +215,22 @@ $(function() {
// BOOTSTRAP TOOLTIPS
$('[data-toggle="tooltip"]').tooltip()
$("input:text[name='formAchatMonnaieAdherent[don][montant]']").change(function() {
var valuetotal = parseFloat($('input.achatmonnaie-montant-slider').slider().val()) + parseFloat($("input:text[name='formAchatMonnaieAdherent[don][montant]']").val().replace(",", "."))
$("input:text[name='formAchatMonnaieAdherent[don][montant]']").on('input', function() {
let montant = 0;
let montantSlider = parseFloat($('input.achatmonnaie-montant-slider').slider().val());
if (!isNaN(montantSlider)) {
montant = montantSlider;
} else {
montant = parseFloat($('input#formAchatMonnaieAdherent_montant').val());
}
let montantDon = parseFloat($("input:text[name='formAchatMonnaieAdherent[don][montant]']").val().replace(",", "."));
if (isNaN(montantDon)) {
montantDon = 0;
}
var valuetotal = montant + montantDon;
$("span.achat_monnaie_montant_total").text(valuetotal + ' €')
});
$("input:text[name='formAchatMonnaieAConfirmerAdherent[don][montant]']").change(function() {
......
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,7 +3,7 @@
"app": {
"js": [
"/build/runtime.6ad5c9da.js",
"/build/app.07dbfd30.js"
"/build/app.d475cc01.js"
],
"css": [
"/build/app.0815270c.css"
......
{
"build/app.css": "/build/app.0815270c.css",
"build/app.js": "/build/app.07dbfd30.js",
"build/app.js": "/build/app.d475cc01.js",
"build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.8a6adf4b.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js",
......
......@@ -122,6 +122,45 @@ class UserAdherentController extends FluxController
}
/**
* @Route("/adherent/paiement-cotis-tav/", name="paiementCotisTav")
* @IsGranted("ROLE_ADHERENT")
*/
public function paiementCotisTavAction(Request $request)
{
if (empty($this->getUser()) || empty($this->getUser()->getAdherent())) {
return $this->redirectToRoute('index');
}
$entity = new AchatMonnaieAdherent();
$form = $this->createForm(AchatMonnaieAdherentFormType::class, $entity);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// TODO: set CB payment when functionality validated
$flux = $form->getData();
if (null != $flux->getDon() && 0 == $flux->getDon()->getMontant()) {
$flux->setDon(null);
}
$this->em->persist($flux);
$this->operationUtils->executeOperations($flux);
$this->em->flush();
$this->addFlash(
'success',
$this->translator->trans('Cotisation payée ! (la bonification n\'est pas encore active)')
);
return $this->redirectToRoute('index');
}
return $this->render('@kohinos/flux/transaction.html.twig', [
'form' => $form->createView(),
'title' => $this->translator->trans('Payer sa cotisation'),
]);
}
/**
* @Route("/adherent/demande/achat-monnaie/", name="achatMonnaieAConfirmerAdherent")
* @IsGranted("ROLE_ADHERENT")
*/
......
......@@ -253,7 +253,7 @@ class Adherent extends AccountableObject implements AccountableInterface
/**
* @return ProfilDeCotisation
*/
public function getProfilDeCotisation(): ProfilDeCotisation
public function getProfilDeCotisation(): ?ProfilDeCotisation
{
return $this->profilDeCotisation;
}
......
......@@ -438,10 +438,25 @@ class FormFactory
public function getSetPaymentCodeForm(User $user)
{
if (empty($user) || !$user->isGranted('ROLE_ADHERENT')) {
throw new \Exception('[FORM 23] Opération impossible !');
throw new \Exception('[FORM 24] Opération impossible !');
}
$form = $this->ff->create(SetPaymentCodeFormType::class, $user->getAdherent(), ['action' => $this->router->generate('adherentSetPaymentCode')]);
return $form->createView();
}
public function getPayerCotisationTAVForm(User $user)
{
if (empty($user) || !$user->isGranted('ROLE_ADHERENT')) {
throw new \Exception('[FORM 25] Opération impossible !');
}
$entity = new AchatMonnaieAdherent();
$entity->setOperateur($user);
// TODO route OU param tav dans get form achat monnaie (plutot 2eme option)
$form = $this->ff->create(AchatMonnaieAdherentFormType::class, $entity, ['action' => $this->router->generate('paiementCotisTav')]);
return $form->createView();
}
}
......@@ -32,6 +32,26 @@ class AchatMonnaieFormType extends FluxFormType
'entity_class' => Siege::class,
'em' => $this->em,
])
;
if ($this->container->getParameter('tav_env')) {
$montant = 0;
$profilDeCotisation = $this->security->getUser()->getAdherent()->getProfilDeCotisation();
if (null != $profilDeCotisation) {
// TODO after merge 3569
// $montant = $profilDeCotisation->getMontant();
$montant = 15;
} else {
$montant = intval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT_DEFAULT));
}
$builder
->add('montant', HiddenType::class, [
'data' => $montant,
])
;
} else {
$builder
->add('montantradio', ChoiceType::class, [
'choices' => [
'30 €' => 30,
......@@ -72,6 +92,8 @@ class AchatMonnaieFormType extends FluxFormType
],
])
;
}
if ('true' === $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN)) {
$builder
->add('save', SubmitType::class, [
......
......@@ -53,6 +53,7 @@ class FormExtension extends AbstractExtension
new \Twig_SimpleFunction('getTicketFixPrintForm', [$this, 'getTicketFixPrintForm']),
new \Twig_SimpleFunction('getTicketFixDestroyForm', [$this, 'getTicketFixDestroyForm']),
new \Twig_SimpleFunction('getSetPaymentCodeForm', [$this, 'getSetPaymentCodeForm']),
new \Twig_SimpleFunction('getPayerCotisationTAVForm', [$this, 'getPayerCotisationTAVForm']),
];
}
......@@ -205,4 +206,9 @@ class FormExtension extends AbstractExtension
{
return $this->container->get('app.formfactory')->getSetPaymentCodeForm($user);
}
public function getPayerCotisationTAVForm(User $user)
{
return $this->container->get('app.formfactory')->getPayerCotisationTAVForm($user);
}
}
......@@ -5,20 +5,23 @@
{% set esoldelabel = 'Solde e-mlc'|trans %}
{% include '@kohinos/block/solde.html.twig' with {'compte': app.user.adherent.emlcAccount.balance, 'soldelabel': esoldelabel, 'currency' : 'e'~(KOH_MLC_SYMBOL|default(''))} %}
{% if tav_env == 1 %}
{% include '@kohinos/tav/block/payment_code.html.twig' %}
{% endif %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% if not tav_env %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% include '@kohinos/adherent/block/achat_monnaie.html.twig' %}
{% else %}
{% else %}
{% include '@kohinos/adherent/block/demande_achat_monnaie.html.twig' %}
{% endif %}
{% include '@kohinos/adherent/block/transaction_presta.html.twig' %}
{% include '@kohinos/adherent/block/transaction_adherent.html.twig' %}
{# {% include '@kohinos/block/transactions.html.twig' %} #}
{% include '@kohinos/block/operations.html.twig' %}
{% include '@kohinos/block/cotisations.html.twig' %}
{% include '@kohinos/adherent/block/infos.html.twig' %}
{% if KOH_USE_SOLIDOUME|default('false') == 'true' and getSolidoumeParam('name')|default('') is not null %}
{% endif %}
{% include '@kohinos/adherent/block/transaction_presta.html.twig' %}
{% include '@kohinos/adherent/block/transaction_adherent.html.twig' %}
{# {% include '@kohinos/block/transactions.html.twig' %} #}
{% include '@kohinos/block/operations.html.twig' %}
{% include '@kohinos/block/cotisations.html.twig' %}
{% include '@kohinos/adherent/block/infos.html.twig' %}
{% if KOH_USE_SOLIDOUME|default('false') == 'true' and getSolidoumeParam('name')|default('') is not null %}
{% include '@kohinos/adherent/block/solidoume.html.twig' %}
{% endif %}
{% else %}
{% include '@kohinos/tav/block/adherent_payer_cotisation.html.twig' %}
{% include '@kohinos/tav/block/adherent_payment_code.html.twig' %}
{% include '@kohinos/block/operations.html.twig' %}
{% endif %}
......@@ -4,7 +4,9 @@
<div class='container' style='max-width: 800px;'>
{% include '@kohinos/block/breadcrumb.html.twig' with {'label' : 'Mon compte'|trans } %}
<div id="accordion" class='text-center mb-5'>
{% if not tav_env %}
{% include '@kohinos/block/userinfos.html.twig' %}
{% endif %}
{% include '@kohinos/block/userpassword.html.twig' %}
</div>
</div>
......
{% extends '@kohinos/block/block_collapse.html.twig' %}
{% block blocktitle %}
<i class="fa fa-shopping-basket mr-4"></i> {{'Payer ma cotisation'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getPayerCotisationTAVForm(app.user) %}
<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)}}
{% 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