Commit ae07f76d by Damien Moulard

payment form workflow

parent 9960deea
......@@ -15,6 +15,7 @@ use App\Form\Type\DonAdherentFormType;
use App\Form\Type\DonPrestataireFormType;
use App\Form\Type\UserInfosFormType;
use App\Form\Type\EncaissementFormType;
use App\Form\Type\EncaissementValidationFormType;
use App\Utils\CotisationUtils;
use App\Utils\OperationUtils;
use Doctrine\ORM\EntityManagerInterface;
......@@ -234,11 +235,46 @@ class UserController extends AbstractController
$form = $this->createForm(EncaissementFormType::class, null, $options);
$form->handleRequest($request);
$validation = false;
if ($form->isSubmitted()) {
$data = $form->getData();
if ($form->isValid()) {
// TODO redirect to page to ask for validation code
$code = $data["payment_code"];
$validation = true; // As soon as the form is valid, we're in validation
if (empty($code)) {
// First step validated (set user & amount) -> go to validation
goto end;
}
// $adherent = $data["adherent"];
// if adherent doesn't have a validation code
// if (is_null($adherent->payment_code)) {
// $this->addFlash(
// 'error',
// $this->translator->trans('L\'utilisateur n\'a pas encore défini un code de validation de paiement sur son espace personnel, il ne peut pas faire d'encaissement pour l'instant.')
// );
// goto end;
// }
// Check validation code
// printf($adherent->payment_code);
// // if bad validation code
// $this->addFlash(
// 'error',
// $this->translator->trans('Le code de validation de l\'habitant est erroné') . ' ' . $form->getErrors()
// );
// $validation = true;
// TODO check if user has validation code / code is ok / user has enough
// ifok save transfer (transaction?)
} else {
......@@ -249,8 +285,10 @@ class UserController extends AbstractController
}
}
end:
return $this->render('@kohinos/tav/encaissement_page.html.twig', [
'form' => $form->createView()
'form' => $form->createView(),
'validation' => $validation
]);
}
}
......@@ -6,6 +6,7 @@ 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\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
......@@ -27,7 +28,7 @@ class EncaissementFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('user', EntityType::class, [
->add('adherent', EntityType::class, [
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findOrderByName(),
'attr' => [
......@@ -42,6 +43,10 @@ class EncaissementFormType extends AbstractType
'label' => 'Montant : ',
'required' => true,
])
->add('payment_code', PasswordType::class, [
'label' => 'Code de validation : ',
'required' => false,
])
->add('save', SubmitType::class, ['label' => 'Valider'])
;
}
......
......@@ -7,7 +7,19 @@
<div class='text-center mb-5'>
{{ form_start(form) }}
{{ form_row(form.user) }}
{% if validation == true %}
<div style="display:none;">
{{ form_row(form.adherent) }}
{{ form_row(form.montant) }}
</div>
{{ form_row(form.payment_code) }}
{% else %}
{{ form_row(form.adherent) }}
{{ form_row(form.montant) }}
<div style="display:none;">
{{ form_row(form.payment_code) }}
</div>
{% endif %}
{{ form_end(form) }}
</div>
</div>
......
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