Commit 4aaf9a64 by Damien Moulard

create page to receive payments for prestataires

parent c1b51736
...@@ -14,6 +14,7 @@ use App\Form\Type\CotiserFormType; ...@@ -14,6 +14,7 @@ use App\Form\Type\CotiserFormType;
use App\Form\Type\DonAdherentFormType; use App\Form\Type\DonAdherentFormType;
use App\Form\Type\DonPrestataireFormType; use App\Form\Type\DonPrestataireFormType;
use App\Form\Type\UserInfosFormType; use App\Form\Type\UserInfosFormType;
use App\Form\Type\EncaissementFormType;
use App\Utils\CotisationUtils; use App\Utils\CotisationUtils;
use App\Utils\OperationUtils; use App\Utils\OperationUtils;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
...@@ -222,4 +223,34 @@ class UserController extends AbstractController ...@@ -222,4 +223,34 @@ class UserController extends AbstractController
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
/**
* @Route("/encaissement", name="encaissement")
* @IsGranted("ROLE_PRESTATAIRE")
*/
public function encaissementAction(Request $request)
{
$options = [];
$form = $this->createForm(EncaissementFormType::class, null, $options);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$data = $form->getData();
if ($form->isValid()) {
// TODO redirect to page to ask for validation code
// TODO check if user has validation code / code is ok / user has enough
// ifok save transfer (transaction?)
} else {
$this->addFlash(
'error',
$this->translator->trans('Problème avec l\'encaissement !') . ' ' . $form->getErrors()
);
}
}
return $this->render('@kohinos/tav/encaissement_page.html.twig', [
'form' => $form->createView()
]);
}
} }
<?php
namespace App\Form\Type;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use App\Entity\Adherent;
class EncaissementFormType extends AbstractType
{
protected $em;
protected $security;
public function __construct(
EntityManagerInterface $em,
Security $security
) {
$this->em = $em;
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('user', EntityType::class, [
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findOrderByName(),
'attr' => [
'class' => 'form-control select2',
],
'placeholder' => 'Choisissez un adhérent',
'required' => true,
'label' => 'Adherent :',
'choice_label' => 'name'
])
->add('montant', NumberType::class, [
'label' => 'Montant : ',
'required' => true,
])
->add('save', SubmitType::class, ['label' => 'Valider'])
;
}
public function getBlockPrefix()
{
return 'formEncaissement';
}
}
...@@ -28,6 +28,9 @@ class MlcGlobalsExtension extends AbstractExtension implements GlobalsInterface ...@@ -28,6 +28,9 @@ class MlcGlobalsExtension extends AbstractExtension implements GlobalsInterface
if (!isset($arrayGlobals['KOH_MAP_ZOOM'])) { if (!isset($arrayGlobals['KOH_MAP_ZOOM'])) {
$arrayGlobals['KOH_MAP_ZOOM'] = '6'; $arrayGlobals['KOH_MAP_ZOOM'] = '6';
} }
if (!isset($arrayGlobals['KOH_TAV'])) {
$arrayGlobals['KOH_TAV'] = $_ENV["TAV_ENV"];
}
// $solidoumeParam = $this->em->getRepository(SolidoumeParameter::class)->findTheOne(); // $solidoumeParam = $this->em->getRepository(SolidoumeParameter::class)->findTheOne();
// if (!empty($solidoumeParam)) { // if (!empty($solidoumeParam)) {
......
{% set esoldelabel = 'Solde e-mlc'|trans %} {% set esoldelabel = 'Solde e-mlc'|trans %}
{% include '@kohinos/block/solde.html.twig' with {'compte': getCurrentPrestataire().emlcAccount.balance, 'soldelabel': esoldelabel, 'currency' : 'e'~(KOH_MLC_SYMBOL|default(''))} %} {% include '@kohinos/block/solde.html.twig' with {'compte': getCurrentPrestataire().emlcAccount.balance, 'soldelabel': esoldelabel, 'currency' : 'e'~(KOH_MLC_SYMBOL|default(''))} %}
{% if KOH_TAV == 1 %}
{% include '@kohinos/tav/block/encaisser_paiement.html.twig' %}
{% endif %}
{% if getCurrentPrestataire().mlc == false %} {% if getCurrentPrestataire().mlc == false %}
{% include '@kohinos/presta/block/infos.html.twig' %} {% include '@kohinos/presta/block/infos.html.twig' %}
{% endif %} {% endif %}
......
{% extends '@kohinos/block/block_collapse.html.twig' %}
{% block blocktitle %}
<i class="fa fa-shopping-basket mr-4"></i> {{'Encaisser un paiement en Monnaie Solidaire'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
<a class='btn btn-xs btn-primary mt-2' href='{{ path('encaissement') }}'>
{{ 'Encaisser'|trans }}
</a>
{% endblock blockcontent %}
{% extends '@kohinos/common/layout.html.twig' %}
{% block content %}
<div class='container' style='max-width: 800px;'>
{% include '@kohinos/block/breadcrumb.html.twig' with {'label': 'Encaissement'} %}
<h2 class='text-center w-100 mt-4 mb-4'>{{ "Encaissement"|trans }}</h2>
<div class='text-center mb-5'>
{{ form_start(form) }}
{{ form_row(form.user) }}
{{ form_end(form) }}
</div>
</div>
{% endblock %}
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