diff --git a/module/Formation/src/Formation/Service/Notification/NotificationService.php b/module/Formation/src/Formation/Service/Notification/NotificationService.php index f894c2f43ad13467ef18e559316cd377a4733574..9dce064cf34242345fe28f0006a4bbe0349a548a 100644 --- a/module/Formation/src/Formation/Service/Notification/NotificationService.php +++ b/module/Formation/src/Formation/Service/Notification/NotificationService.php @@ -82,12 +82,17 @@ class NotificationService public function generateAndSend(string $templateCode, $adresses, array $motsClefs = [], array $vars = []): ?Mail { + try { $rendu = $this->getRenduService()->generateRenduByTemplateCode($templateCode, $vars); $mail = $this->getMailService()->sendMail($adresses, $rendu->getSujet(), $rendu->getCorps(), 'Formation'); $motsClefs[] = $rendu->getTemplate()->generateTag(); $mail->setMotsClefs($motsClefs); $this->getMailService()->update($mail); return $mail; + } catch (RuntimeException $e) { + $adresses = (is_array($adresses))?implode('|', $adresses):$adresses; + throw new RuntimeException("Un problème est survenu lors de l'envoi du mail vers [".$adresses."]",0,$e); + } } /** GESTION DES INSCRIPTIONS **************************************************************************************/ @@ -294,7 +299,7 @@ class NotificationService $vars = $this->generateVariableArray($inscrit); $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_DEMANDE_RETOUR, $vars); - if ($inscrit->getIndividu() !== null) { + if ($inscrit->getIndividu() !== null AND $inscrit->getIndividu()->getEmail() !== null) { $mail = $this->getMailService()->sendMail($inscrit->getIndividu()->getEmail(), $rendu->getSujet(), $rendu->getCorps(), 'Formation'); $mail->setMotsClefs([$session->generateTag(), $inscrit->generateTag(), $rendu->getTemplate()->generateTag()]); $this->getMailService()->update($mail); diff --git a/module/Formation/src/Formation/Service/Session/SessionService.php b/module/Formation/src/Formation/Service/Session/SessionService.php index c95fd47529cd3024e0e1a78748317688022c93fc..3eb5f45c440595022bd27f9287955c0d6842c65b 100644 --- a/module/Formation/src/Formation/Service/Session/SessionService.php +++ b/module/Formation/src/Formation/Service/Session/SessionService.php @@ -474,7 +474,10 @@ class SessionService { if ($instance->isEmargementActive()) { $this->update($instance); - $this->getNotificationService()->triggerLienPourEmargement($instance); + $configuration = $this->getNotificationConfigurationService()->getNotificationConfigurationWithParams("SESSION", MailTemplates::SESSION_EMARGEMENT, "Envoi de l'emargement"); + if ($configuration === null OR $configuration->isActive()) { + $this->getNotificationService()->triggerLienPourEmargement($instance); + } } return $instance; }