Commit e7899e6f by Damien Moulard

Adhérer par le kohinos

parent 8798f1ce
...@@ -25,10 +25,14 @@ use App\Entity\Siege; ...@@ -25,10 +25,14 @@ use App\Entity\Siege;
use App\Entity\User; use App\Entity\User;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Geoloc;
use App\Entity\Groupe;
use App\Entity\Usergroup;
use App\Entity\AchatMonnaieAdherent; use App\Entity\AchatMonnaieAdherent;
use App\Entity\AchatMonnaiePrestataire; use App\Entity\AchatMonnaiePrestataire;
use App\Entity\CotisationAdherent; use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire; use App\Entity\CotisationPrestataire;
use App\Entity\GlobalParameter;
use Sonata\Exporter\Handler; use Sonata\Exporter\Handler;
use Sonata\Exporter\Source\DoctrineORMQuerySourceIterator; use Sonata\Exporter\Source\DoctrineORMQuerySourceIterator;
use Sonata\Exporter\Writer\CsvWriter; use Sonata\Exporter\Writer\CsvWriter;
...@@ -36,6 +40,9 @@ use Sonata\Exporter\Writer\JsonWriter; ...@@ -36,6 +40,9 @@ use Sonata\Exporter\Writer\JsonWriter;
use Sonata\Exporter\Writer\XmlWriter; use Sonata\Exporter\Writer\XmlWriter;
use Sonata\Exporter\Writer\XlsWriter; use Sonata\Exporter\Writer\XlsWriter;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use FOS\UserBundle\Model\UserManagerInterface;
use App\Security\LoginAuthenticator;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
/** /**
* *
...@@ -65,8 +72,17 @@ class FluxController extends AbstractController ...@@ -65,8 +72,17 @@ class FluxController extends AbstractController
protected $eventDispatcher; protected $eventDispatcher;
protected $session; protected $session;
protected $payum; protected $payum;
protected $authenticator;
public function __construct(Security $security, EntityManagerInterface $em, TranslatorInterface $translator, EventDispatcherInterface $eventDispatcher, SessionInterface $session, Payum $payum) protected $guardHandler;
public function __construct(Security $security,
EntityManagerInterface $em,
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
SessionInterface $session,
LoginAuthenticator $authenticator,
GuardAuthenticatorHandler $guardHandler,
Payum $payum)
{ {
$this->security = $security; $this->security = $security;
$this->em = $em; $this->em = $em;
...@@ -74,6 +90,8 @@ class FluxController extends AbstractController ...@@ -74,6 +90,8 @@ class FluxController extends AbstractController
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->session = $session; $this->session = $session;
$this->payum = $payum; $this->payum = $payum;
$this->authenticator = $authenticator;
$this->guardHandler = $guardHandler;
} }
protected function manageFluxForm(Request $request, Form $form, $compte, $success, $title) protected function manageFluxForm(Request $request, Form $form, $compte, $success, $title)
...@@ -194,16 +212,15 @@ class FluxController extends AbstractController ...@@ -194,16 +212,15 @@ class FluxController extends AbstractController
]); ]);
} }
/* /**
* Crée une instance de Payment et redirige vers la page de paiement * Crée une instance de Payment et redirige vers la page de paiement
*/ */
public function preparePaymentAction(Form $form, $type) public function preparePaymentAction(Form $form, $type)
{ {
$flux_data = $form->getData();
// Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé // Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé
$serializer = $this->container->get('serializer'); $serializer = $this->container->get('serializer');
$data = $serializer->normalize($flux_data, null, $toSerialize = Payment::TYPE_ADHESION == $type ? $form->get('cotisation')->getData() : $form->getData();
$data = $serializer->normalize($toSerialize, null,
[AbstractNormalizer::ATTRIBUTES => ['reference', [AbstractNormalizer::ATTRIBUTES => ['reference',
'moyen', 'moyen',
'montant', 'montant',
...@@ -215,18 +232,33 @@ class FluxController extends AbstractController ...@@ -215,18 +232,33 @@ class FluxController extends AbstractController
$jsondata = $serializer->serialize($data, 'json'); $jsondata = $serializer->serialize($data, 'json');
// Prepare CB Payment // Prepare CB Payment
if ($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN) === 'true') {
$gatewayName = 'payzen'; $gatewayName = 'payzen';
} else {
$this->addFlash(
'error',
$this->translator->trans('Une erreur est survenue due à la configuration du paiement dans l\'application. Il est pour l\'instant impossible de payer par CB, merci de contacter votre monnaie locale.')
);
return $this->redirectToRoute('index');
}
$storage = $this->payum->getStorage('App\Entity\Payment'); $storage = $this->payum->getStorage('App\Entity\Payment');
$payment = $storage->create(); $payment = $storage->create();
$payment->setNumber(uniqid()); $payment->setNumber(uniqid());
$payment->setCurrencyCode('978'); $payment->setCurrencyCode('978');
$payment->setTotalAmount($form->get('montant')->getData()*100); // 1.23 EUR
$payment->setDescription($type); $payment->setDescription($type);
$payment->setFluxData($jsondata);
if ($type == Payment::TYPE_ADHESION) {
$payment->setTotalAmount($form->get('cotisation')->get('montant')->getData()*100); // 1.23 EUR
$payment->setClientId('Nouvel adhérent');
$payment->setClientEmail($form->get('user')->get('email')->getData());
} else {
$payment->setTotalAmount($form->get('montant')->getData()*100); // 1.23 EUR
$payment->setClientId($this->getUser()->getId()); $payment->setClientId($this->getUser()->getId());
$payment->setClientEmail($this->getUser()->getEmail()); $payment->setClientEmail($this->getUser()->getEmail());
$payment->setFluxData($jsondata); }
$storage->update($payment); $storage->update($payment);
...@@ -275,11 +307,16 @@ class FluxController extends AbstractController ...@@ -275,11 +307,16 @@ class FluxController extends AbstractController
'success', 'success',
$this->translator->trans('Achat de monnaie locale bien effectué !') $this->translator->trans('Achat de monnaie locale bien effectué !')
); );
} else { } else if (Payment::TYPE_COTISATION_ADHERENT == $type || Payment::TYPE_COTISATION_PRESTA == $type) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Cotisation bien reçue. Merci !') $this->translator->trans('Cotisation bien reçue. Merci !')
); );
} else if (Payment::TYPE_ADHESION == $type) {
$this->addFlash(
'success',
$this->translator->trans('Votre adhésion a bien été prise en compte, bienvenue !')
);
} }
// Update payment status // Update payment status
...@@ -338,6 +375,9 @@ class FluxController extends AbstractController ...@@ -338,6 +375,9 @@ class FluxController extends AbstractController
$dest = $this->em->getRepository(Adherent::class)->find($flux_array['destinataire']); $dest = $this->em->getRepository(Adherent::class)->find($flux_array['destinataire']);
$flux->setDestinataire($dest); $flux->setDestinataire($dest);
$op = $this->em->getRepository(User::class)->find($flux_array['operateur']);
$flux->setOperateur($op);
} else if (Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) { } else if (Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) {
$flux = $serializer->deserialize( $flux = $serializer->deserialize(
$payment->getFluxData(), $payment->getFluxData(),
...@@ -351,6 +391,9 @@ class FluxController extends AbstractController ...@@ -351,6 +391,9 @@ class FluxController extends AbstractController
$dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']); $dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']);
$flux->setDestinataire($dest); $flux->setDestinataire($dest);
$op = $this->em->getRepository(User::class)->find($flux_array['operateur']);
$flux->setOperateur($op);
} else if (Payment::TYPE_COTISATION_ADHERENT == $type) { } else if (Payment::TYPE_COTISATION_ADHERENT == $type) {
$flux = $serializer->deserialize( $flux = $serializer->deserialize(
$payment->getFluxData(), $payment->getFluxData(),
...@@ -365,6 +408,9 @@ class FluxController extends AbstractController ...@@ -365,6 +408,9 @@ class FluxController extends AbstractController
$dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']); $dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']);
$flux->setDestinataire($dest); $flux->setDestinataire($dest);
$op = $this->em->getRepository(User::class)->find($flux_array['operateur']);
$flux->setOperateur($op);
$flux->setRecu(true); $flux->setRecu(true);
} else if (Payment::TYPE_COTISATION_PRESTA == $type) { } else if (Payment::TYPE_COTISATION_PRESTA == $type) {
$flux = $serializer->deserialize( $flux = $serializer->deserialize(
...@@ -380,14 +426,67 @@ class FluxController extends AbstractController ...@@ -380,14 +426,67 @@ class FluxController extends AbstractController
$dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']); $dest = $this->em->getRepository(Prestataire::class)->find($flux_array['destinataire']);
$flux->setDestinataire($dest); $flux->setDestinataire($dest);
$op = $this->em->getRepository(User::class)->find($flux_array['operateur']);
$flux->setOperateur($op);
$flux->setRecu(true); $flux->setRecu(true);
} else if (Payment::TYPE_ADHESION == $type) {
$new_adherent_data = json_decode($this->session->get('new_adherent'));
$adherent = new Adherent();
$user = $this->userManager->createUser();
$usergroup = $this->em->getRepository(Usergroup::class)->findOneByName('Adherent');
$group = $this->em->getRepository(Groupe::class)->findOneBy(array('id' => $new_adherent_data->groupe->id));
$user->setEmail($new_adherent_data->user->email);
$user->setUsername($new_adherent_data->user->username);
$user->setFirstname($new_adherent_data->user->firstname);
$user->setLastname($new_adherent_data->user->lastname);
$user->setPlainPassword($new_adherent_data->user->plainPassword);
$user->setEnabled(true);
$user->addPossiblegroup($usergroup);
$user->addGroup($usergroup);
$user->addRole('ROLE_ADHERENT');
$user->setAdherent($adherent);
$adherent->setEcompte('0');
$adherent->setUser($user);
$adherent->setGroupe($group);
if ($adherent->getGeoloc() == null) {
$geoloc = new Geoloc();
$geoloc->setAdresse($new_adherent_data->geoloc->adresse);
$geoloc->setCpostal($new_adherent_data->geoloc->cpostal);
$geoloc->setVille($new_adherent_data->geoloc->ville);
$adherent->setGeoloc($geoloc);
}
$this->em->persist($adherent);
$this->em->flush();
// Remove new user data from session
$this->session->remove('new_adherent');
// Create first cotisation
$flux = $serializer->deserialize(
$payment->getFluxData(),
CotisationAdherent::class,
'json',
['disable_type_enforcement' => true]
);
$flux->setOperateur($user);
$flux->setExpediteur($adherent);
$flux->setDestinataire($this->em->getRepository(Prestataire::class)->findOneBy(array('mlc' => true)));
$flux->setRole('Adherent');
$flux->setRecu(true);
// Update payment with new user id
$payment->setClientId($user->getId());
$this->em->persist($payment);
} else { } else {
return new Response('', Response::HTTP_BAD_REQUEST); return new Response('', Response::HTTP_BAD_REQUEST);
} }
$op = $this->em->getRepository(User::class)->find($flux_array['operateur']);
$flux->setOperateur($op);
$this->em->persist($flux); $this->em->persist($flux);
$this->em->flush(); $this->em->flush();
...@@ -396,11 +495,23 @@ class FluxController extends AbstractController ...@@ -396,11 +495,23 @@ class FluxController extends AbstractController
new FluxEvent($flux) new FluxEvent($flux)
); );
// Add Flash message here in case Gataway doesn't notify // Add flash message here too in case Gataway doesn't notify
if (Payment::TYPE_ACHAT_MONNAIE_ADHERENT == $type || Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Achat de monnaie locale bien effectué !') $this->translator->trans('Achat de monnaie locale bien effectué !')
); );
} else if (Payment::TYPE_COTISATION_ADHERENT == $type || Payment::TYPE_COTISATION_PRESTA == $type) {
$this->addFlash(
'success',
$this->translator->trans('Cotisation bien reçue. Merci !')
);
} else if (Payment::TYPE_ADHESION == $type) {
$this->addFlash(
'success',
$this->translator->trans('Votre adhésion a bien été prise en compte, bienvenue !')
);
}
// Invalidate token // Invalidate token
$this->payum->getHttpRequestVerifier()->invalidate($token); $this->payum->getHttpRequestVerifier()->invalidate($token);
...@@ -417,7 +528,19 @@ class FluxController extends AbstractController ...@@ -417,7 +528,19 @@ class FluxController extends AbstractController
$this->payum->getHttpRequestVerifier()->invalidate($token); $this->payum->getHttpRequestVerifier()->invalidate($token);
} }
if (Payment::TYPE_ADHESION == $type) {
// Auto login after adhesion
return $this->guardHandler
->authenticateUserAndHandleSuccess(
$user,
$request,
$this->authenticator,
'main'
);
} else {
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
}
} }
...@@ -14,6 +14,7 @@ use App\Entity\Prestataire; ...@@ -14,6 +14,7 @@ use App\Entity\Prestataire;
use App\Entity\Siege; use App\Entity\Siege;
use App\Entity\User; use App\Entity\User;
use App\Entity\Usergroup; use App\Entity\Usergroup;
use App\Entity\Payment;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use App\Form\Type\AdhererFormType; use App\Form\Type\AdhererFormType;
use App\Form\Type\ContactFormType; use App\Form\Type\ContactFormType;
...@@ -49,6 +50,7 @@ use Symfony\Component\Security\Core\Security as Secur; ...@@ -49,6 +50,7 @@ use Symfony\Component\Security\Core\Security as Secur;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use Symfony\Component\Templating\EngineInterface; use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
class IndexController extends AbstractController class IndexController extends AbstractController
{ {
...@@ -202,47 +204,30 @@ class IndexController extends AbstractController ...@@ -202,47 +204,30 @@ class IndexController extends AbstractController
*/ */
public function adhererAction(Request $request) public function adhererAction(Request $request)
{ {
// @TODO : formulaire d'adhésion sans cotisation ? à valider après ?
$adherent = new Adherent(); $adherent = new Adherent();
$user = $this->userManager->createUser();
$groupe = $this->em->getRepository(Usergroup::class)->findOneByName('Adherent');
$user->setEnabled(false);
$user->addPossiblegroup($groupe);
$user->addGroup($groupe);
$user->addRole('ROLE_ADHERENT');
$adherent->setEcompte('0');
$user->setAdherent($adherent);
$adherent->setUser($user);
// @TODO : ajouter le moyen de payer sa cotisation en CB directement
// if (count($adherent->getUser()->getCotisations()) <= 0) {
// $cotisation = new Cotisation();
// $cotisation->setMontant(floatval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT)));
// $cotisation->setOperateur($adherent->getUser());
// $cotisation->setExpediteur($adherent);
// $cotisation->setMoyen(MoyenEnum::MOYEN_AUTRE);
// $cotisation->setDebut(new \DateTime());
// $cotisation->setFin(new \DateTime('+ 1 year'));
// $adherent->getUser()->addCotisation($cotisation);
// }
if ($adherent->getGeoloc() == null) {
$adherent->setGeoloc(new Geoloc());
}
$form = $this->createForm(AdhererFormType::class, $adherent); $form = $this->createForm(AdhererFormType::class, $adherent);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted()) { if ($form->isSubmitted()) {
if ($form->isValid()) { if ($form->isValid()) {
$adherentNew = $form->getData(); $adherentNew = $form->getData();
// @TODO : redirect to paiement page
// $this->em->persist($adherentNew); // Store form data in session to deal with it at payment callback
// $this->em->flush(); $serializer = $this->container->get('serializer');
// $this->addFlash( $data = $serializer->normalize($adherentNew, null,
// 'success', [AbstractNormalizer::ATTRIBUTES => ['user' => ['username', 'email', 'firstname', 'lastname', 'plainPassword'],
// 'Adhésion bien pris en compte, vous recevrez un email très bientôt !' 'groupe' => ['id'],
// ); 'geoloc' => ['adresse', 'cpostal', 'ville']]]);
return $this->redirectToRoute('index');
$jsondata = $serializer->serialize($data, 'json');
$this->session->set('new_adherent', $jsondata);
// Redirect to payment page
return $this->forward('App\Controller\FluxController::preparePaymentAction', [
'form' => $form,
'type' => Payment::TYPE_ADHESION
]);
} else { } else {
$this->addFlash( $this->addFlash(
'error', 'error',
......
...@@ -122,12 +122,14 @@ class Adherent ...@@ -122,12 +122,14 @@ class Adherent
public function __toString(): string public function __toString(): string
{ {
if (!empty($this->getUser())) {
if (!empty($this->getUser()->getLastname().$this->getUser()->getFirstname())) { if (!empty($this->getUser()->getLastname().$this->getUser()->getFirstname())) {
return $this->getUser()->getLastname().' '.$this->getUser()->getFirstname(); return $this->getUser()->getLastname().' '.$this->getUser()->getFirstname();
} }
if (!empty($this->getUser()->getUsername())) { if (!empty($this->getUser()->getUsername())) {
return $this->getUser()->getUsername(); return $this->getUser()->getUsername();
} }
}
return 'Adhérent ['.$this->getId().']'; return 'Adhérent ['.$this->getId().']';
} }
} }
...@@ -14,6 +14,7 @@ class Payment extends BasePayment ...@@ -14,6 +14,7 @@ class Payment extends BasePayment
const TYPE_ACHAT_MONNAIE_PRESTA = 'achat_monnaie_presta'; const TYPE_ACHAT_MONNAIE_PRESTA = 'achat_monnaie_presta';
const TYPE_COTISATION_ADHERENT = 'cotisation_adherent'; const TYPE_COTISATION_ADHERENT = 'cotisation_adherent';
const TYPE_COTISATION_PRESTA = 'cotisation_presta'; const TYPE_COTISATION_PRESTA = 'cotisation_presta';
const TYPE_ADHESION = 'adhesion';
/** /**
......
...@@ -3,18 +3,17 @@ ...@@ -3,18 +3,17 @@
namespace App\Form\Type; namespace App\Form\Type;
use App\Entity\Cotisation; use App\Entity\Cotisation;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use App\Form\Type\CotisationInfosFormType; use App\Form\Type\CotisationInfosFormType;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotBlank;
class AddCotisationFormType extends AbstractType class AddCotisationFormType extends AbstractType
{ {
...@@ -30,29 +29,22 @@ class AddCotisationFormType extends AbstractType ...@@ -30,29 +29,22 @@ class AddCotisationFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$now = new \DateTime(); $now = new \DateTime();
$flux = $options['data'];
if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception("Opération impossible ! Utilisateur non connecté !");
}
$builder $builder
->add('operateur', HiddenType::class, array(
'entity_class' => User::class,
'em' => $this->em,
'data_class' => null,
'data' => $this->security->getUser()
))
->add('reference', HiddenType::class, array( ->add('reference', HiddenType::class, array(
'label' => 'Reference :', 'label' => 'Reference :',
'required' => true, 'required' => true,
'data' => 'Cotisation '.$now->format('Y') 'data' => 'Adhésion '.$now->format('d/m/Y')
)) ))
->add('montant', HiddenType::class, array( ->add('montant', IntegerType::class, array(
'data' => intval($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COTISATION_ADHERENT)),
'constraints' => [
new NotBlank()
],
)) ))
->add('moyen', HiddenType::class, array( ->add('moyen', HiddenType::class, array(
'data' => MoyenEnum::MOYEN_AUTRE, 'data' => MoyenEnum::MOYEN_CB,
)) ))
; ;
;
} }
/** /**
......
...@@ -8,7 +8,6 @@ use App\Entity\Prestataire; ...@@ -8,7 +8,6 @@ use App\Entity\Prestataire;
use App\Entity\User; use App\Entity\User;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use App\Form\Type\GeolocFormType; use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType;
use App\Form\Type\UserInfosFormType; use App\Form\Type\UserInfosFormType;
use Doctrine\DBAL\Types\FloatType; use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
......
...@@ -4,26 +4,16 @@ namespace App\Form\Type; ...@@ -4,26 +4,16 @@ namespace App\Form\Type;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\Groupe; use App\Entity\Groupe;
use App\Entity\Prestataire;
use App\Entity\User;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use App\Form\Type\GeolocFormType; use App\Form\Type\GeolocFormType;
use App\Form\Type\RegistrationFormType; use App\Form\Type\RegistrationFormType;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
...@@ -46,28 +36,27 @@ class AdhererFormType extends AbstractType ...@@ -46,28 +36,27 @@ class AdhererFormType extends AbstractType
$builder $builder
->add('user', RegistrationFormType::class, array( ->add('user', RegistrationFormType::class, array(
'label' => false, 'label' => false,
'required' => false 'required' => true
))
->add('groupe', ChoiceType::class, array(
'required' => true,
'label' => 'Groupe local',
'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
'choice_label' => 'name',
'placeholder' => 'Choisir un groupe',
)) ))
// ->add('groupe', ChoiceType::class, array(
// 'required' => true,
// 'label' => 'GROUPE LOCAL',
// 'choices' => $this->container->get('doctrine')->getRepository(Groupe::class)->findAll(),
// 'choice_label' => 'name',
// 'placeholder' => 'Choisir un groupe',
// ))
->add('geoloc', GeolocFormType::class, array( ->add('geoloc', GeolocFormType::class, array(
'label' => false, 'label' => false,
'required' => true, 'required' => true,
'with_geoloc' => false, 'with_geoloc' => false,
'with_latlon' => false 'with_latlon' => false
)) ))
// ->add('cotisation', AddCotisationFormType::class, array( ->add('cotisation', AddCotisationFormType::class, array(
// 'label' => false, 'label' => false,
// 'required' => false, 'required' => true,
// 'mapped' => false, 'mapped' => false,
// 'data' => $adherent->getUser()->getCotisations()->last() 'data_class' => null
// )) ))
// ->add('save', SubmitType::class, ['label' => "Valider l'adhésion"])
->add('save', SubmitType::class, ['label' => "Payer en CB"]); ->add('save', SubmitType::class, ['label' => "Payer en CB"]);
; ;
} }
......
...@@ -39,11 +39,11 @@ class RegistrationFormType extends AbstractType ...@@ -39,11 +39,11 @@ class RegistrationFormType extends AbstractType
)) ))
->add('firstname', TextType::class, array( ->add('firstname', TextType::class, array(
'label' => 'Prénom', 'label' => 'Prénom',
'required' => false, 'required' => true,
)) ))
->add('lastname', TextType::class, array( ->add('lastname', TextType::class, array(
'label' => 'Nom', 'label' => 'Nom',
'required' => false, 'required' => true,
)) ))
->add('plainPassword', RepeatedType::class, array( ->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class, 'type' => PasswordType::class,
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
{% block content %} {% block content %}
<div class='container' style='max-width:800px;'> <div class='container' style='max-width:800px;'>
<h4 class='mt-3'>{{'Adhérer'|trans }} :</h4> <div class='text-center mb-5 mt-2'>
<h4 class='mt-3'><b>{{'Adhérer'|trans }}</b></h4>
</div>
<p> <p>
{{form_start(form)}} {{form_start(form)}}
{{ form_row(form.user) }} {{ form_row(form.user) }}
...@@ -11,7 +13,10 @@ ...@@ -11,7 +13,10 @@
{% endif %} {% endif %}
{{ form_row(form.geoloc) }} {{ form_row(form.geoloc) }}
<div class='text-center mb-5 mt-2'> <div class='text-center mb-5 mt-2'>
<h5>{{ 'Montant de la cotisation'|trans }} : <b>{{ KOH_COTISATION_ADHERENT|default('') }}</b></h5> <h5><b>{{ 'Cotisation'|trans }}</b></h5>
</div>
{{ form_row(form.cotisation) }}
<div class='text-center mb-5 mt-2'>
{{ form_row(form.save) }} {{ form_row(form.save) }}
</div> </div>
{{form_end(form)}} {{form_end(form)}}
......
...@@ -889,6 +889,18 @@ ...@@ -889,6 +889,18 @@
<source>Infos du prestataire modifiées !</source> <source>Infos du prestataire modifiées !</source>
<target>Infos du prestataire modifiées !</target> <target>Infos du prestataire modifiées !</target>
</trans-unit> </trans-unit>
<trans-unit id="JkNHITX" resname="Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.">
<source>Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.</source>
<target>Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.</target>
</trans-unit>
<trans-unit id="FXJP8R7" resname="Cotisation">
<source>Cotisation</source>
<target>Cotisation</target>
</trans-unit>
<trans-unit id="QZ19VOy" resname="Votre adhésion a bien été prise en compte, bienvenue !">
<source>Votre adhésion a bien été prise en compte, bienvenue !</source>
<target>Votre adhésion a bien été prise en compte, bienvenue !</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>
...@@ -905,6 +905,18 @@ ...@@ -905,6 +905,18 @@
<source>Infos du prestataire modifiées !</source> <source>Infos du prestataire modifiées !</source>
<target>Infos du prestataire modifiées !</target> <target>Infos du prestataire modifiées !</target>
</trans-unit> </trans-unit>
<trans-unit id="JkNHITX" resname="Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.">
<source>Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.</source>
<target>Une erreur est survenue due à la configuration du paiement dans l'application. Il est pour l'instant impossible de payer par CB, merci de contacter votre monnaie locale.</target>
</trans-unit>
<trans-unit id="FXJP8R7" resname="Cotisation">
<source>Cotisation</source>
<target>Cotisation</target>
</trans-unit>
<trans-unit id="QZ19VOy" resname="Votre adhésion a bien été prise en compte, bienvenue !">
<source>Votre adhésion a bien été prise en compte, bienvenue !</source>
<target>Votre adhésion a bien été prise en compte, bienvenue !</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>
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