Commit 9fe60959 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Les mails du module de formation sont maintenant des templates

parent a00e11c8
Loading
Loading
Loading
Loading
+5 −0
Changes for module/Formation/src/Formation/Provider/Template/MailTemplates.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,5 +6,10 @@ class MailTemplates {

    const INSCRIPTION_ENREGISTREE                   = "FORMATION_INSCRIPTION_ENREGISTREE";
    const INSCRIPTION_LISTE_PRINCIPALE              = "FORMATION_INSCRIPTION_LISTE_PRINCIPALE";
    const INSCRIPTION_LISTE_COMPLEMENTAIRE          = "FORMATION_INSCRIPTION_LISTE_COMPLEMENTAIRE";
    const INSCRIPTION_ECHEC                         = "FORMATION_INSCRIPTION_ECHEC";

    const SESSION_IMMINENTE                         = "FORMATION_SESSION_IMMINENTE";
    const SESSION_TERMINEE                          = "FORMATION_SESSION_TERMINEE";

}
 No newline at end of file
+77 −62
Changes for module/Formation/src/Formation/Service/Notification/NotificationService.php: 77 added lines, 62 removed lines.
Original line number Diff line number Diff line
@@ -5,46 +5,50 @@ namespace Formation\Service\Notification;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Session;
use Formation\Provider\Template\MailTemplates;
use Notification\Exception\NotificationException;
use Notification\Notification;
use Notification\Service\NotifierService;
use Laminas\View\Helper\Url as UrlHelper;
use UnicaenRenderer\Service\Rendu\RenduServiceAwareTrait;

class NotificationService extends NotifierService
{
    use RenduServiceAwareTrait;

    /** INSCRIPTION ***************************************************************************************************/

    /**
     * @var UrlHelper
     * @param Inscription $inscription
     * @return void
     * @throws NotificationException
     */
    protected $urlHelper;

    public function setUrlHelper($urlHelper)
    public function triggerInscriptionEnregistree(Inscription $inscription) : void
    {
        $this->urlHelper = $urlHelper;
    }

    /** Mail lié à l'inscription à une formation **********************************************************************/
        $vars = [
            'doctorant' => $inscription->getDoctorant(),
            'formation' => $inscription->getSession()->getFormation(),
            'session'   => $inscription->getSession(),
        ];

    public function triggerInscriptionEnregistree(Inscription $inscription)
    {
        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ENREGISTREE, $vars);
        $mail = $inscription->getDoctorant()->getIndividu()->getEmail();
        $libelle = $inscription->getSession()->getFormation()->getLibelle();

        if ($mail !== null) {
            $notif = new Notification();
            $notif
                ->setSubject("Validation de votre inscription à la session de formation ".$libelle)
                ->setTo($mail)
                ->setTemplatePath('formation/notification/inscription-enregistree')
                ->setTemplateVariables([
                    'inscription' => $inscription,
                    'libelle' => $libelle,
                ]);
                ->setSubject($rendu->getSujet())
                ->setBody($rendu->getCorps())
            ;
            $this->trigger($notif);
        }
    }

    public function triggerInscriptionListePrincipale(Inscription $inscription)
    /**
     * @param Inscription $inscription
     * @return void
     * @throws NotificationException
     */
    public function triggerInscriptionListePrincipale(Inscription $inscription) : void
    {
        $vars = [
            'doctorant' => $inscription->getDoctorant(),
@@ -61,86 +65,95 @@ class NotificationService extends NotifierService
                ->setTo($mail)
                ->setSubject($rendu->getSujet())
                ->setBody($rendu->getCorps())
//                ->setTemplatePath('formation/notification/renderer-mail')
//                ->setTemplateVariables([
//                    'corps' => $rendu->getCorps()])
                ;
            $this->trigger($notif);
        }
    }

    public function triggerInscriptionListeComplementaire(Inscription $inscription)
    /**
     * @param Inscription $inscription
     * @return void
     * @throws NotificationException
     */
    public function triggerInscriptionListeComplementaire(Inscription $inscription) : void
    {
        $vars = [
            'doctorant' => $inscription->getDoctorant(),
            'formation' => $inscription->getSession()->getFormation(),
            'session'   => $inscription->getSession(),
        ];

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_LISTE_COMPLEMENTAIRE, $vars);
        $mail = $inscription->getDoctorant()->getIndividu()->getEmail();
        $libelle = $inscription->getSession()->getFormation()->getLibelle();

        if ($mail !== null) {
            $notif = new Notification();
            $notif
                ->setSubject("Vous êtes sur la liste complementaire de la formation ".$libelle)
                ->setTo($mail)
                ->setTemplatePath('formation/notification/inscription-complementaire')
                ->setTemplateVariables([
                    'inscription' => $inscription,
                    'libelle' => $libelle,
                ]);
                ->setSubject($rendu->getSujet())
                ->setBody($rendu->getCorps())
            ;
            $this->trigger($notif);
        }
    }

    /** Mail de rappel ************************************************************************************************/

    /**
     * @param Session $session
     * @see Application/view/formation/notification/session-imminente.phtml
     * @return void
     * @throws NotificationException
     */
    public function triggerInscriptionEchec(Session $session)
    public function triggerInscriptionEchec(Session $session) : void
    {
        /** @var Inscription[] $inscriptions */
        $inscriptions = $session->getListeComplementaire();
        $libelle = $session->getFormation()->getLibelle(). " #".$session->getIndex();

        foreach ($inscriptions as $inscription) {
            $vars = [
                'doctorant' => $inscription->getDoctorant(),
                'formation' => $inscription->getSession()->getFormation(),
                'session'   => $inscription->getSession(),
            ];
            $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::INSCRIPTION_ECHEC, $vars);
            $mail = $inscription->getDoctorant()->getIndividu()->getEmail();

            if ($mail !== null) {
                $notif = new Notification();
                $notif
                    ->setSubject("Inscription à la formation ".$libelle." impossible.")
                    ->setTo($mail)
                    ->setTemplatePath('formation/notification/inscription-echec')
                    ->setTemplateVariables([
                        'inscription' => $inscription,
                        'libelle' => $libelle,
                    ]);
                    ->setSubject($rendu->getSujet())
                    ->setBody($rendu->getCorps())
                ;
                $this->trigger($notif);
            }
        }
    }

    /** SESSIONS ******************************************************************************************************/

    /**
     * @param Session $session
     * @see Application/view/formation/notification/session-imminente.phtml
     * @return void
     * @throws NotificationException
     */
    public function triggerSessionImminente(Session $session)
    public function triggerSessionImminente(Session $session) : void
    {
        /** @var Inscription[] $inscriptions */
        $inscriptions = $session->getListePrincipale();
        $libelle = $session->getFormation()->getLibelle(). " #".$session->getIndex();

        foreach ($inscriptions as $inscription) {
            $vars = [
                'doctorant' => $inscription->getDoctorant(),
                'formation' => $inscription->getSession()->getFormation(),
                'session'   => $inscription->getSession(),
            ];
            $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_IMMINENTE, $vars);
            $mail = $inscription->getDoctorant()->getIndividu()->getEmail();

            if ($mail !== null) {
                $notif = new Notification();
                $notif
                    ->setSubject("La session de formation ".$libelle." va bientôt commencée.")
                    ->setTo($mail)
                    ->setTemplatePath('formation/notification/session-imminente')
                    ->setTemplateVariables([
                        'inscription' => $inscription,
                        'libelle' => $libelle,
                    ]);
                    ->setSubject($rendu->getSujet())
                    ->setBody($rendu->getCorps())
                ;
                $this->trigger($notif);
            }
        }
@@ -148,27 +161,29 @@ class NotificationService extends NotifierService

    /**
     * @param Session $session
     * @see Application/view/formation/notification/session-imminente.phtml
     * @return void
     * @throws NotificationException
     */
    public function triggerSessionTerminee(Session $session)
    public function triggerSessionTerminee(Session $session) : void
    {
        /** @var Inscription[] $inscriptions */
        $inscriptions = $session->getListePrincipale();
        $libelle = $session->getFormation()->getLibelle(). " #".$session->getIndex();

        foreach ($inscriptions as $inscription) {
            $vars = [
                'doctorant' => $inscription->getDoctorant(),
                'formation' => $inscription->getSession()->getFormation(),
                'session'   => $inscription->getSession(),
            ];
            $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_TERMINEE, $vars);
            $mail = $inscription->getDoctorant()->getIndividu()->getEmail();

            if ($mail !== null) {
                $notif = new Notification();
                $notif
                    ->setSubject("La session de formation ".$libelle." est maintenant terminée.")
                    ->setTo($mail)
                    ->setTemplatePath('formation/notification/session-terminee')
                    ->setTemplateVariables([
                        'inscription' => $inscription,
                        'libelle' => $libelle,
                    ]);
                    ->setSubject($rendu->getSujet())
                    ->setBody($rendu->getCorps())
                ;
                $this->trigger($notif);
            }
        }
+0 −5
Changes for module/Formation/src/Formation/Service/Notification/NotificationServiceFactory.php: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Formation\Service\Notification;
use Application\Service\Notification\NotificationFactory;
use Interop\Container\ContainerInterface;
use Notification\Service\NotifierServiceFactory;
use Laminas\View\Helper\Url as UrlHelper;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenRenderer\Service\Rendu\RenduService;
@@ -30,14 +29,10 @@ class NotificationServiceFactory extends NotifierServiceFactory
        $service = parent::__invoke($container);
        $renduService = $container->get(RenduService::class);

        /** @var UrlHelper $urlHelper */
        $urlHelper = $container->get('ViewHelperManager')->get('Url');

        /** @var NotificationFactory $notificationFactory */
        $notificationFactory = $container->get(NotificationFactory::class);

        $service->setNotificationFactory($notificationFactory);
        $service->setUrlHelper($urlHelper);
        $service->setRenduService($renduService);

        return $service;
+0 −29
Changes for module/Formation/view/formation/notification/inscription-complementaire.phtml: 0 added lines, 29 removed lines.
Original line number Diff line number Diff line
<?php

use Formation\Entity\Db\Inscription;

/**
 * @see \Formation\Service\Notification\NotificationService::triggerInscriptionListeComplementaire()
 * @var Inscription $inscription
 * @var string $lilbelle
 */

$session = $inscription->getSession();
$libelle = $session->getFormation()->getLibelle();
$date = $session->getDateDebut()->format('d/m/Y');
$horaire = $session->getDateDebut()->format('H:i');
$gestionnaire = ($session->getFormation()->getResponsable())?$session->getFormation()->getResponsable()->getNomComplet():$this->appInfos()->nom;

?>
<p>
Cher&middot;e doctorant&middot;e,
</p>

<p>
    Vous êtes inscrit&middot;e sur la <strong>liste complementaire</strong> de la formation <?php echo $libelle; ?> le <?php echo $date; ?> de <?php echo $horaire; ?>.
    Si une place en liste principale se libère vous serez informé&middot;e par l'application <?php echo $this->appInfos()->nom ?>.
</p>
<p>
    Cordialement,<br/>
    <?php echo $gestionnaire; ?>
</p>
 No newline at end of file
+0 −29
Changes for module/Formation/view/formation/notification/inscription-echec.phtml: 0 added lines, 29 removed lines.
Original line number Diff line number Diff line
<?php

use Formation\Entity\Db\Inscription;

/**
 * @see \Formation\Service\Notification\NotificationService::triggerInscriptionEchec()
 * @var Inscription $inscription
 * @var string $lilbelle
 */

$session = $inscription->getSession();
$libelle = $session->getFormation()->getLibelle();
$date = $session->getDateDebut()->format('d/m/Y');
$horaire = $session->getDateDebut()->format('H:i');
$gestionnaire = ($session->getFormation()->getResponsable())?$session->getFormation()->getResponsable()->getNomComplet():$this->appInfos()->nom;

?>

<p>
    Cher&middot;e doctorant&middot;e,
</p>
<p>
    Vous étiez inscrit&middot;e sur liste complémentaire à la formation <?php echo $libelle; ?> le <?php echo $date; ?>  de <?php echo $horaire; ?> .<br/>
    Cependant, aucune place ne s’étant libérée, nous sommes au regret de vous informer que vous ne pourrez pas participer à la formation.
</p>
<p>
    Cordialement,<br/>
    <?php echo $gestionnaire; ?>
</p>
Loading