Commit 2f11af02 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Email lors de l'absence d'un logo

parent f460c9be
Loading
Loading
Loading
Loading
+2
Changes for module/Application/src/Application/Controller/TheseController.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1367,9 +1367,11 @@ class TheseController extends AbstractController implements
    {
        $these = $this->requestedThese();
        $renderer = $this->getServiceLocator()->get('view_renderer'); /* @var $renderer \Zend\View\Renderer\PhpRenderer */
        $notifier = $this->getServiceLocator()->get('NotificationService');
        $exporter = new PageDeCouverturePdfExporter($renderer, 'A4');
        $exporter->setVars([
            'these'              => $these,
            'notifier'           => $notifier,
        ]);
        $exporter->export('export.pdf');
        exit;
+69 −2
Changes for module/Application/src/Application/Service/Notification/NotificationService.php: 69 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,9 +2,13 @@

namespace Application\Service\Notification;

use Application\Entity\Db\EcoleDoctorale;
use Application\Entity\Db\EcoleDoctoraleIndividu;
use Application\Entity\Db\Etablissement;
use Application\Entity\Db\Fichier;
use Application\Entity\Db\Individu;
use Application\Entity\Db\These;
use Application\Entity\Db\UniteRecherche;
use Application\Entity\Db\ValiditeFichier;
use Application\Entity\Db\Variable;
use Application\Service\Notification\Notification;
@@ -15,6 +19,7 @@ use Application\Notification\ValidationRdvBuNotification;
use Application\Service\Variable\VariableServiceAwareInterface;
use Application\Service\Variable\VariableServiceAwareTrait;
use UnicaenApp\Traits\MessageAwareTrait;
use Zend\Db\Sql\Predicate\In;
use Zend\View\Model\ViewModel;
use Zend\View\Renderer\RendererInterface;

@@ -365,7 +370,7 @@ class NotificationService implements VariableServiceAwareInterface, MailerServic
    {
        $html = $this->renderer->render($viewModel);

        $subject = "[SoDoct] " . $viewModel->getVariable('subject');
        $subject = "[SyGAL] " . $viewModel->getVariable('subject');
        $to = $viewModel->getVariable('to');
        $cc = $viewModel->getVariable('cc');
        $bcc = $viewModel->getVariable('bcc');
@@ -386,7 +391,6 @@ class NotificationService implements VariableServiceAwareInterface, MailerServic
        if (isset($this->options['bcc'])) {
            $mail->addBcc($this->options['bcc']);
        }

        $this->mailerService->send($mail);
    }

@@ -436,4 +440,67 @@ class NotificationService implements VariableServiceAwareInterface, MailerServic
    {
        return $this->getMessages();
    }

    public function notifierLogoAbsentEcoleDoctorale(EcoleDoctorale $ecole) {

        $libelle = $ecole->getLibelle();
        $viewModel = (new ViewModel())
            ->setTemplate('application/these/mail/notif-logo-absent')
            ->setVariables([
                'subject' => "Logo manquant pour l'ED [".$libelle."]",
                'type' => "l'école doctorale",
                'libelle' => $libelle,
            ]);

        $mails = [];
        foreach ($ecole->getEcoleDoctoraleIndividus() as $individu) {
            /** @var EcoleDoctoraleIndividu $individu */
            $email = $individu->getIndividu()->getEmail();
            if ($email !== null) $mails[] = $email;

        }

        $viewModel->setVariable('to', $mails);
        $this->notifier($viewModel);
    }

    public function notifierLogoAbsentUniteRecherche(UniteRecherche $unite) {

        $libelle = $unite->getLibelle();
        $viewModel = (new ViewModel())
            ->setTemplate('application/these/mail/notif-logo-absent')
            ->setVariables([
                'subject' => "Logo manquant pour l'UR [".$libelle."]",
                'type' => "l'unité de recherche",
                'libelle' => $libelle,
            ]);

        $mails = [];
        foreach ($unite->getUniteRechercheIndividus() as $individu) {
            /** @var EcoleDoctoraleIndividu $individu */
            $email = $individu->getIndividu()->getEmail();
            if ($email !== null) $mails[] = $email;

        }

        $viewModel->setVariable('to', $mails);
        $this->notifier($viewModel);
    }

    public function notifierLogoAbsentEtablissement(Etablissement $etablissement) {

        $libelle = $etablissement->getLibelle();
        $viewModel = (new ViewModel())
            ->setTemplate('application/these/mail/notif-logo-absent')
            ->setVariables([
                'subject' => "Logo manquant pour l'Etab [".$libelle."]",
                'type' => "l'établissement",
                'libelle' => $libelle,
            ]);

        //TODO ne pas laisser en dur ... (mail les administrateurs techniques de l'établissement)
        $mails = ["jean-philippe.metivier@unicaen.fr", "bertrand.gauthier@unicaen.fr"];
        $viewModel->setVariable('to', $mails);
        $this->notifier($viewModel);
    }
}
 No newline at end of file
+11 −3
Changes for module/Application/src/Application/Service/These/PageDeGarde/pagedecouverture.phtml: 11 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use Application\Entity\Db\Acteur;
use Application\Entity\Db\Doctorant;
use Application\Entity\Db\Individu;
use Application\View\Renderer\PhpRenderer;
use Application\Service\Notification\NotificationService;

/**
 * @var PhpRenderer $this
@@ -229,10 +230,17 @@ function generateEncadrementInfos(These $these) {

/** Fonction générant le code HTML lié au encradrant
 * @param These         $these
 * @param NotificationService $notifier
 * @return string
 */
function generateLogos(These $these) {

function generateLogos(These $these, NotificationService $notifier) {

    if ($these->getEtablissement()->getCheminLogo() === null)
        $notifier->notifierLogoAbsentEtablissement($these->getEtablissement());
    if ($these->getEcoleDoctorale()->getCheminLogo() === null)
        $notifier->notifierLogoAbsentEcoleDoctorale($these->getEcoleDoctorale());
    if ($these->getUniteRecherche()->getCheminLogo() === null)
        $notifier->notifierLogoAbsentUniteRecherche($these->getUniteRecherche());
    $logouni = APPLICATION_DIR. $these->getEtablissement()->getCheminLogo();
    $logoed  = APPLICATION_DIR. $these->getEcoleDoctorale()->getCheminLogo();
    $logour  = APPLICATION_DIR. $these->getUniteRecherche()->getCheminLogo();
@@ -266,5 +274,5 @@ function generateLogos(These $these) {
<?php echo generateJuryInfos($these) ?>
<br/>
<?php echo generateEncadrementInfos($these); ?>
<?php echo generateLogos($these); ?>
<?php echo generateLogos($these, $notifier); ?>
+27
Changes for module/Application/view/application/these/mail/notif-logo-absent.phtml: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

use Application\Entity\Db\These;
use Application\Entity\Db\VersionFichier;
use Application\Filter\IdifyFilter;
use Application\View\Renderer\PhpRenderer;

/**
 * @var PhpRenderer $this
 * @var string $structure
 * @var string $libelle
 */
?>

<p>
    Bonjour,
</p>
<p>
    Ceci est un mail envoyé automatiquement par l'application SyGAL.
</p>
<p>
    Vous êtes informé-e que le logo associé à <?php echo $structure ?> [<?php echo $libelle ?>] est manquant.<br/>
    Connectez vous afin d'ajouter celui-ci.
</p>
<p>
<!--    Cliquez sur <a href="--><?php //echo $this->url('ecole-doctorale') ?><!--">ce lien</a> pour accéder à la page correspondante de l'application.-->
</p>
+x(64.8 KiB)

File mode changed from 100644 to 100755.