From: Raphaël Gertz Date: Fri, 7 May 2021 15:28:06 +0000 (+0200) Subject: Add dispute form X-Git-Tag: 0.2.2~9 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/40d20c715e67927f04b58462179065eb44ad267b Add dispute form --- diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php index ac25f63..11597f6 100644 --- a/Controller/DefaultController.php +++ b/Controller/DefaultController.php @@ -228,6 +228,131 @@ class DefaultController { return $this->render('@RapsysAir/form/contact.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context); } + + /** + * The dispute page + * + * @desc Generate a dispute document + * + * @param Request $request The request instance + * @param MailerInterface $mailer The mailer instance + * + * @return Response The rendered view or redirection + */ + public function dispute(Request $request, MailerInterface $mailer): Response { + //Prevent non-guest to access here + $this->denyAccessUnlessGranted('ROLE_USER', null, $this->translator->trans('Unable to access this page without role %role%!', ['%role%' => $this->translator->trans('User')])); + //Set section + $section = $this->translator->trans('Dispute'); + + //Set description + $this->context['description'] = $this->translator->trans('Libre Air dispute'); + + //Set keywords + $this->context['keywords'] = [ + $this->translator->trans('dispute'), + $this->translator->trans('Libre Air'), + $this->translator->trans('outdoor'), + $this->translator->trans('Argentine Tango'), + $this->translator->trans('calendar') + ]; + + //Set title + $title = $this->translator->trans($this->config['site']['title']).' - '.$section; + + //Create the form according to the FormType created previously. + //And give the proper parameters + $form = $this->createForm('Rapsys\AirBundle\Form\DisputeType', null, [ + 'action' => $this->generateUrl('rapsys_air_dispute'), + 'method' => 'POST' + ]); + + if ($request->isMethod('POST')) { + // Refill the fields in case the form is not valid. + $form->handleRequest($request); + + if ($form->isValid()) { + //Get data + $data = $form->getData(); + + header('Content-Type: text/plain'); + + //Infraction + var_dump($data['offense']); + + //Numéro d'avis + var_dump($data['notice']); + + //Numéro d'agent + var_dump($data['agent']); + + //Code service + var_dump($data['service']); + + //Masque porté + var_dump($data['mask']); + + //Civilité + var_dump($this->translator->trans($this->getUser()->getCivility()->getTitle())); + + //Prénom + var_dump($this->getUser()->getForename()); + + //Nom + var_dump($this->getUser()->getSurname()); + + //Mail + var_dump($this->getUser()->getMail()); + + exit; + +# //Create message +# $message = (new TemplatedEmail()) +# //Set sender +# ->from(new Address($data['mail'], $data['name'])) +# //Set recipient +# //XXX: remove the debug set in vendor/symfony/mime/Address.php +46 +# ->to(new Address($this->config['contact']['mail'], $this->config['contact']['name'])) +# //Set subject +# ->subject($data['subject']) +# +# //Set path to twig templates +# ->htmlTemplate('@RapsysAir/mail/contact.html.twig') +# ->textTemplate('@RapsysAir/mail/contact.text.twig') +# +# //Set context +# ->context( +# [ +# 'subject' => $data['subject'], +# 'message' => strip_tags($data['message']), +# ]+$this->context +# ); +# +# //Try sending message +# //XXX: mail delivery may silently fail +# try { +# //Send message +# $mailer->send($message); +# +# //Redirect on the same route with sent=1 to cleanup form +# return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params')); +# //Catch obvious transport exception +# } catch(TransportExceptionInterface $e) { +# if ($message = $e->getMessage()) { +# //Add error message mail unreachable +# $form->get('mail')->addError(new FormError($this->translator->trans('Unable to contact: %mail%: %message%', ['%mail%' => $this->config['contact']['mail'], '%message%' => $this->translator->trans($message)]))); +# } else { +# //Add error message mail unreachable +# $form->get('mail')->addError(new FormError($this->translator->trans('Unable to contact: %mail%', ['%mail%' => $this->config['contact']['mail']]))); +# } +# } + } + } + + //Render template + return $this->render('@RapsysAir/form/dispute.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context); + } + /** * The index page * diff --git a/Form/DisputeType.php b/Form/DisputeType.php new file mode 100644 index 0000000..6a63e9d --- /dev/null +++ b/Form/DisputeType.php @@ -0,0 +1,42 @@ +add('offense', ChoiceType::class, ['choices' => ['Forbidden gathering' => 'gathering', 'Traffic at prohibited time' => 'traffic'], 'attr' => ['placeholder' => 'Your offense'], 'constraints' => [new NotBlank(['message' => 'Please provide your offense'])]]) + ->add('notice', TextType::class, ['label' => 'Notice number', 'attr' => ['placeholder' => 'Your notice number'], 'constraints' => [new NotBlank(['message' => 'Please provide your notice'])]]) + ->add('agent', TextType::class, ['label' => 'Agent number', 'attr' => ['placeholder' => 'Your agent number'], 'constraints' => [new NotBlank(['message' => 'Please provide your agent'])]]) + ->add('service', TextType::class, ['label' => 'Service code', 'attr' => ['placeholder' => 'Your service code'], 'constraints' => [new NotBlank(['message' => 'Please provide your service'])]]) + ->add('mask', CheckboxType::class, ['label' => 'Mask worn', 'attr' => ['placeholder' => 'Your mask worn'], 'constraints' => [new NotBlank(['message' => 'Please provide your mask'])]]) + ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { + $resolver->setDefaults(['error_bubbling' => true]); + } + + /** + * {@inheritdoc} + */ + public function getName() { + return 'dispute_form'; + } +} diff --git a/Resources/config/routes/rapsys_air.yaml b/Resources/config/routes/rapsys_air.yaml index 845dd9a..2a57aae 100644 --- a/Resources/config/routes/rapsys_air.yaml +++ b/Resources/config/routes/rapsys_air.yaml @@ -14,6 +14,13 @@ rapsys_air_contact: controller: Rapsys\AirBundle\Controller\DefaultController::contact methods: GET|POST +rapsys_air_frequently_asked_questions: + path: + en: '/en/frequently-asked-questions' + fr: '/foire-aux-questions' + controller: Rapsys\AirBundle\Controller\DefaultController::frequentlyAskedQuestions + methods: GET + rapsys_air_organizer_regulation: path: en: '/en/organizer-regulation' @@ -28,12 +35,12 @@ rapsys_air_terms_of_service: controller: Rapsys\AirBundle\Controller\DefaultController::termsOfService methods: GET -rapsys_air_frequently_asked_questions: +rapsys_air_dispute: path: - en: '/en/frequently-asked-questions' - fr: '/foire-aux-questions' - controller: Rapsys\AirBundle\Controller\DefaultController::frequentlyAskedQuestions - methods: GET + en: '/en/dispute' + fr: '/contestation' + controller: Rapsys\AirBundle\Controller\DefaultController::dispute + methods: GET|POST rapsys_air_location: path: diff --git a/Resources/translations/messages.en.yaml b/Resources/translations/messages.en.yaml index 32e4f39..cb4255f 100644 --- a/Resources/translations/messages.en.yaml +++ b/Resources/translations/messages.en.yaml @@ -11,6 +11,7 @@ 'Advanced tango music programming': 'Advanced tango music programming' 'After': 'After' 'Afternoon': 'Afternoon' +'Agent number': 'Agent number' 'All rights reserved': 'All rights reserved' 'All slot canceled and account disabled for one month': 'All slot canceled and account disabled for one month' 'All slot canceled and account disabled for one week': 'All slot canceled and account disabled for one week' @@ -101,6 +102,8 @@ 'Dashboard': 'Dashboard' 'Date': 'Date' 'Description': 'Description' +'dispute': 'dispute' +'Dispute': 'Dispute' 'Docks': 'Docks' 'Donate': 'Donate' 'Donate to %pseudonym%': 'Donate to %pseudonym%' @@ -122,6 +125,7 @@ 'Evening': 'Evening' 'faq': 'faq' 'First time': 'First time' +'Forbidden gathering': 'Forbidden gathering' 'Force cancel': 'Force cancel' 'Forename': 'Forename' 'French': 'French' @@ -146,6 +150,7 @@ 'Kicked out for music too strong': 'Kicked out for music too strong' 'Latitude': 'Latitude' 'Length': 'Length' +'Libre Air dispute': 'Libre Air dispute' 'Libre Air frequently asked questions': 'Libre Air frequently asked questions' 'Libre Air is an initiative to have a powerful and shared calendar for outdoor Tango Argentin sessions.': 'Libre Air is an initiative to have a powerful and shared calendar for outdoor Tango Argentin sessions.' 'Libre Air': 'Libre Air' @@ -182,6 +187,7 @@ 'Managment': 'Managment' 'Managment veto possible': 'Managment veto possible' 'Maps': 'Maps' +'Mask worn': 'Mask worn' 'Medium change': 'Medium change' 'Meeting': 'Meeting' 'Message': 'Message' @@ -210,6 +216,8 @@ 'No more battery': 'No more battery' 'None': 'None' 'Not Found': 'Not Found' +'Notice number': 'Notice number' +'Offense': 'Offense' 'Only danceable songs': 'Only danceable songs' 'On this page you will find the most recurring questions of Libre Air users.': 'On this page you will find the most recurring questions of Libre Air users.' 'organizer': 'organizer' @@ -267,6 +275,7 @@ 'Send a message to %pseudonym%': 'Send a message to %pseudonym%' 'Send': 'Send' 'Senior': 'Senior' +'Service code': 'Service code' 'Session %id% by %pseudonym%': 'Session %id% by %pseudonym%' 'Session %id%': 'Session %id%' 'Session %id% updated': 'Session %id% updated' @@ -313,6 +322,7 @@ 'Tokyo': 'Tokyo' 'To recover your account you can follow this link: %recover_url%': 'To recover your account you can follow this link: %recover_url%' 'To recover your account you can follow this link:': 'To recover your account you can follow this link:' +'Traffic at prohibited time': 'Traffic at prohibited time' 'Trocadero esplanade': 'Trocadero esplanade' 'Trocadero': 'Trocadero' 'Tuesday': 'Tuesday' @@ -347,6 +357,7 @@ 'Your account password has been changed, to recover your account you can follow this link: %recover_url%': 'Your account password has been changed, to recover your account you can follow this link: %recover_url%' 'Your account password has been changed, to recover your account you can follow this link:': 'Your account password has been changed, to recover your account you can follow this link:' 'Your address': 'Your address' +'Your agent number': 'Your agent number' 'Your begin': 'Your begin' 'Your city': 'Your city' 'Your civility': 'Your civility' @@ -364,9 +375,12 @@ 'Your location': 'Your location' 'Your longitude': 'Your longitude' 'Your mail': 'Your mail address' +'Your mask worn': 'Your mask worn' 'Your message has been sent': 'Your message has been sent' 'Your message': 'Your message' 'Your name': 'Your name' +'Your notice number': 'Your notice number' +'Your offense': 'Your offense' 'Your password confirmation': 'Your password confirmation' 'Your password is updated and an account recover message has been sent': 'Your password is updated and an account recover message has been sent' 'Your password': 'Your password' @@ -374,6 +388,7 @@ 'Your profile': 'Your profile' 'Your pseudonym': 'Your pseudonym' 'Your recover account message has been sent': 'Your recover account message has been sent' +'Your service code': 'Your service code' 'Your short': 'Your short' 'Your slot': 'Your slot' 'Your surname': 'Your surname' diff --git a/Resources/translations/messages.fr.yaml b/Resources/translations/messages.fr.yaml index 1449712..c532dde 100644 --- a/Resources/translations/messages.fr.yaml +++ b/Resources/translations/messages.fr.yaml @@ -12,6 +12,7 @@ 'Advanced tango music programming': 'Programmation musicale de tango avancée' 'After': 'After' 'Afternoon': 'Après-midi' +'Agent number': 'Numéro d''agent' 'All rights reserved': 'Tous droits réservés' 'All slot canceled and account disabled for one month': 'Annulation de tous les créneaux et compte désactivé pour un mois' 'All slot canceled and account disabled for one week': 'Annulation de tous les créneaux et compte désactivé pour une semaine' @@ -107,6 +108,8 @@ 'Dashboard': 'Tableau de bord' 'Date': 'Date' 'Description': 'Description' +'dispute': 'contestation' +'Dispute': 'Contestation' 'Docks': 'Quais' 'Donate': 'Contribuer' 'Donate to %pseudonym%': 'Faire un don à %pseudonym%' @@ -128,6 +131,7 @@ 'Evening': 'Soirée' 'faq': 'faq' 'First time': 'Première fois' +'Forbidden gathering': 'Rassemblement interdit' 'Force cancel': 'Annulation forcée' 'Forename': 'Prénom' 'French': 'Français' @@ -153,6 +157,7 @@ 'Latitude': 'Latitude' 'Length': 'Durée' 'Libre Air': 'Air Libre' +'Libre Air dispute': 'Contestation Air Libre' 'Libre Air frequently asked questions': 'Foire aux questions d''Air Libre' 'Libre Air is an initiative to have a powerful and shared calendar for outdoor Tango Argentin sessions.': 'Air Libre est une initiative pour avoir un calendrier puissant et partagé pour les sessions de Tango Argentin en plein air.' 'Libre Air location list': 'Liste des emplacements d''Air Libre' @@ -188,6 +193,7 @@ 'Managment': 'Encadrement' 'Managment veto possible': 'Possibilité de véto encadrement' 'Maps': 'Cartes' +'Mask worn': 'Masque porté' 'Medium change': 'Changement intermédiaire' 'Meeting': 'Réunion' 'Message': 'Message' @@ -216,6 +222,8 @@ 'No more battery': 'Plus de batterie' 'None': 'Aucun' 'Not Found': 'Pas Trouvé' +'Notice number': 'Numéro d''avis' +'Offense': 'Infraction' 'Only danceable songs': 'Musique dançable uniquement' 'On this page you will find the most recurring questions of Libre Air users.': 'Sur cette page, vous trouverez les questions les plus récurrentes des utilisateurs d''Air Libre.' 'organizer': 'organisateur' @@ -274,6 +282,7 @@ 'Send a message to %pseudonym%': 'Envoyer un message à %pseudonym%' 'Send': 'Envoyer' 'Senior': 'Senior' +'Service code': 'Code service' 'Session %id% by %pseudonym%': 'Séance %id% par %pseudonym%' 'Session %id%': 'Séance %id%' 'Session %id% the %date% for %location% on the slot %slot% saved': 'Séance %id% Réservation le %date% pour %location% sur le créneau %slot% enregistrée' @@ -325,6 +334,7 @@ 'Tokyo': 'Tokyo' 'To recover your account you can follow this link:': 'Pour récupérer votre compte vous pouvez suivre ce lien :' 'To recover your account you can follow this link: %recover_url%': 'Pour récupérer votre compte vous pouvez suivre ce lien : %recover_url%' +'Traffic at prohibited time': 'Circulation à une heure interdite' 'Trocadero esplanade': 'Esplanade du Trocadéro' 'Trocadero': 'Trocadéro' 'Tuesday': 'Mardi' @@ -359,6 +369,7 @@ 'Your account password has been changed, to recover your account you can follow this link: %recover_url%': 'Votre mot de passe a été changé, pour récupérer votre compte vous pouvez suivre ce lien : %recover_url%' 'Your account password has been changed, to recover your account you can follow this link:': 'Votre mot de passe a été changé, pour récupérer votre compte vous pouvez suivre ce lien :' 'Your address': 'Votre adresse' +'Your agent number': 'Votre numéro d''agent' 'Your begin': 'Votre début' 'Your city': 'Votre ville' 'Your civility': 'Votre civilité' @@ -376,9 +387,12 @@ 'Your location': 'Votre emplacement' 'Your longitude': 'Votre longitude' 'Your mail': 'Votre courriel' +'Your mask worn': 'Votre masque porté' 'Your message has been sent': 'Votre message a été envoyé' 'Your message': 'Votre message' 'Your name': 'Votre nom' +'Your notice number': 'Votre numéro d''avis' +'Your offense': 'Votre infraction' 'Your password confirmation': 'Votre confirmation de mot de passe' 'Your password is updated and an account recover message has been sent': 'Votre mot de passe est modifié et un message de récupération de compte a été envoyé' 'Your password': 'Votre mot de passe' @@ -386,6 +400,7 @@ 'Your profile': 'Votre profil' 'Your pseudonym': 'Votre pseudonyme' 'Your recover account message has been sent': 'Votre message de récupération de compte a été envoyé' +'Your service code': 'Votre code service' 'Your short': 'Votre titre court' 'Your site': 'Votre site' 'Your slot': 'Your créneau'