Commit 8e14715a by Félicie

Merge branch '4121-interface-adherent' into 'develop'

role habitant screen

See merge request cooperatic/kohinos-tav!11
parents e35e896f 921a609b
......@@ -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 ! [Payzen désactivé en attent du compte ; bonification et mensualité pas encore implémentés]')
);
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")
*/
......
......@@ -438,10 +438,24 @@ 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);
$form = $this->ff->create(AchatMonnaieAdherentFormType::class, $entity, ['action' => $this->router->generate('paiementCotisTav')]);
return $form->createView();
}
}
......@@ -32,46 +32,66 @@ class AchatMonnaieFormType extends FluxFormType
'entity_class' => Siege::class,
'em' => $this->em,
])
->add('montantradio', ChoiceType::class, [
'choices' => [
'30 €' => 30,
'50 €' => 50,
'100 €' => 100,
],
'required' => false,
'placeholder' => false,
'data' => $this->defaultMontantSlider,
'expanded' => true,
'multiple' => false,
'label' => 'Sélectionnez un montant :',
'mapped' => false,
])
->add('montant', RangeType::class, [
'attr' => [
'min' => 0,
'max' => $this->maxMontantSlider,
'data-provide' => 'slider',
'data-slider-ticks' => '[0, 50, 100, 150, 200, 250]',
'data-slider-ticks-labels' => '[0, 50, 100, 150, 200, 250]',
'data-slider-ticks-positions' => '[0, 20, 40, 60, 80, 100]',
'data-slider-min' => '0',
'data-slider-max' => $this->maxMontantSlider,
'data-slider-step' => '5',
'data-slider-value' => $this->defaultMontantSlider,
'style' => 'width:100%;',
'class' => 'achatmonnaie-montant-slider',
],
'label' => 'Ou choisissez librement le montant : ',
'required' => false,
])
->add('payOther', SubmitType::class, [
'label' => 'Payer autrement',
'translation_domain' => 'messages',
'attr' => [
'class' => 'btn-secondary',
],
])
;
if ($this->container->getParameter('tav_env')) {
$montant = 0;
$profilDeCotisation = $this->security->getUser()->getAdherent()->getProfilDeCotisation();
if (null != $profilDeCotisation) {
$montant = $profilDeCotisation->getMontant();
} 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,
'50 €' => 50,
'100 €' => 100,
],
'required' => false,
'placeholder' => false,
'data' => $this->defaultMontantSlider,
'expanded' => true,
'multiple' => false,
'label' => 'Sélectionnez un montant :',
'mapped' => false,
])
->add('montant', RangeType::class, [
'attr' => [
'min' => 0,
'max' => $this->maxMontantSlider,
'data-provide' => 'slider',
'data-slider-ticks' => '[0, 50, 100, 150, 200, 250]',
'data-slider-ticks-labels' => '[0, 50, 100, 150, 200, 250]',
'data-slider-ticks-positions' => '[0, 20, 40, 60, 80, 100]',
'data-slider-min' => '0',
'data-slider-max' => $this->maxMontantSlider,
'data-slider-step' => '5',
'data-slider-value' => $this->defaultMontantSlider,
'style' => 'width:100%;',
'class' => 'achatmonnaie-montant-slider',
],
'label' => 'Ou choisissez librement le montant : ',
'required' => false,
])
->add('payOther', SubmitType::class, [
'label' => 'Payer autrement',
'translation_domain' => 'messages',
'attr' => [
'class' => 'btn-secondary',
],
])
;
}
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' %}
{% include '@kohinos/adherent/block/achat_monnaie.html.twig' %}
{% if not tav_env %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% include '@kohinos/adherent/block/achat_monnaie.html.twig' %}
{% 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 %}
{% include '@kohinos/adherent/block/solidoume.html.twig' %}
{% endif %}
{% else %}
{% include '@kohinos/adherent/block/demande_achat_monnaie.html.twig' %}
{% 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 %}
{% 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 %}
\ No newline at end of file
......@@ -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'>
{% include '@kohinos/block/userinfos.html.twig' %}
{% if not tav_env or tav_env == 1 and not (is_granted('ROLE_ADHERENT') and app.user.adherent) %}
{% 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