Commit 44297a55 by Yvon

send email and land on proper page

parent 9b8c8a30
...@@ -59,6 +59,7 @@ class IndexController extends AbstractController ...@@ -59,6 +59,7 @@ class IndexController extends AbstractController
private $tokenStorage; private $tokenStorage;
private $router; private $router;
private $security; private $security;
private $mailer;
public function __construct( public function __construct(
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
...@@ -70,7 +71,8 @@ class IndexController extends AbstractController ...@@ -70,7 +71,8 @@ class IndexController extends AbstractController
LoginAuthenticator $authenticator, LoginAuthenticator $authenticator,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
RouterInterface $router, RouterInterface $router,
Security $security Security $security,
\Swift_Mailer $mailer
) { ) {
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->em = $em; $this->em = $em;
...@@ -82,6 +84,7 @@ class IndexController extends AbstractController ...@@ -82,6 +84,7 @@ class IndexController extends AbstractController
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->router = $router; $this->router = $router;
$this->security = $security; $this->security = $security;
$this->mailer = $mailer;
} }
/** /**
...@@ -187,7 +190,7 @@ class IndexController extends AbstractController ...@@ -187,7 +190,7 @@ class IndexController extends AbstractController
return $this->redirectToRoute($redirRoute); return $this->redirectToRoute($redirRoute);
} }
return new Response("Votre questionnaire a bien été reçu. Nous allons vous contacter. Vous n'avez rien à faire de plus pour l'instant."); return $this->render('@kohinos/tav/prestaquiz_sent.html.twig');
} }
/** /**
...@@ -265,6 +268,9 @@ class IndexController extends AbstractController ...@@ -265,6 +268,9 @@ class IndexController extends AbstractController
$this->em->persist($quiz); $this->em->persist($quiz);
$this->em->flush(); $this->em->flush();
//Send email !
$this->notifyGestionnaireAfterPrestaquizSent($presta);
list($redirRoute,$presta) = $this->getAndDispatchPrestataire('prestaquiz-selfeval'); list($redirRoute,$presta) = $this->getAndDispatchPrestataire('prestaquiz-selfeval');
if ($redirRoute) { if ($redirRoute) {
return $this->redirectToRoute($redirRoute); return $this->redirectToRoute($redirRoute);
...@@ -280,6 +286,28 @@ class IndexController extends AbstractController ...@@ -280,6 +286,28 @@ class IndexController extends AbstractController
]); ]);
} }
private function notifyGestionnaireAfterPrestaquizSent(Prestataire $presta)
{
$user = $this->security->getUser();
$gestionnaires = $presta->getGroupe()->getGestionnaires();
if(!$gestionnaires || $gestionnaires->isEmpty() || !$gestionnaires->first()->getEmail()) {
$to = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_CONTACT_EMAIL);
} else {
$to = $gestionnaires->first()->getEmail();
}
$subject = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL)
. ' : Réception questionnaire point de vente';
$mail = (new \Swift_Message($subject))
->setFrom($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NOTIF_EMAIL)) //using $from here sometimes fails with 550 5.7.1 Sender mismatch
->setTo($to)
->setBody("L'utilisateur " . $user->getUsername()
. " vient de soumettre un questionnaire pour le point de vente " . $presta->getRaison() . "."
);
$this->mailer->send($mail);
}
/** /**
* @Route("/installation", name="installation") * @Route("/installation", name="installation")
*/ */
......
{% extends '@kohinos/common/layout.html.twig' %}
{% block content %}
<h2>Vous avez terminé votre demande d'inscription, merci !</h2>
<h2>Nous vous contacterons prochainement.</h2>
{% endblock %}
\ 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