Commit 0632cd73 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout d'une mention de l'envoi à tous les responsables de structure lorsque...

Ajout d'une mention de l'envoi à tous les responsables de structure lorsque aucun responsable de site n'a été trouvé
parent d4d6e87d
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Journal des modifications
- [FIX] Changement du comptage des engagements et des avis dans le cas de rapporteurs historisés mais ayant déjà rendu quelque chose
- [FIX] Le menu 'Mes thèses' inclut désormais les thèses soutenues (indispensable pour le profil Président du jury).
- [FIX] Utilisation de l'état ETABLISSEMENT pour le feu vert des soutenances plutôt que VALIDE
- Ajout d'une mention de l'envoi à tous les responsables de structure lorsque aucun responsable de site n'a été trouvé. 

3.0.10
-----
+41 −15
Changes for module/Soutenance/src/Soutenance/Service/Notifier/NotifierSoutenanceService.php: 41 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Soutenance\Service\Notifier;

use Application\Controller\Plugin\UrlFichierThese;
use Doctorant\Entity\Db\Doctorant;
use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
@@ -17,6 +16,7 @@ use Application\Service\These\TheseServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Application\Service\Variable\VariableServiceAwareTrait;
use DateTime;
use Notification\Exception\NotificationException;
use Notification\Notification;
use Notification\Service\NotifierService;
use Soutenance\Entity\Avis;
@@ -47,19 +47,33 @@ class NotifierSoutenanceService extends NotifierService
        $this->urlHelper = $urlHelper;
    }



    /**
     * @param These $these
     * @return string
     */
    protected function fetchEmailBdd(These $these)
    protected function fetchEmailBdd(These $these) : string
    {
        $variable = $this->variableService->getRepository()->findByCodeAndThese(Variable::CODE_EMAIL_BDD, $these);
        return $variable->getValeur();

    }

    /**
     * @param IndividuRole[] $individuRoles
     * @param These $these
     * @return bool
     */
    protected function hasEmailsByEtablissement(array $individuRoles, These $these) : bool
    {
        foreach ($individuRoles as $individuRole) {
            $individu = $individuRole->getIndividu();
            if ($individu->getEtablissement() === $these->getEtablissement()) {
                if ($individu->getEmail() !== null) return true;
            }
        }
        return false;
    }

    /**
     * @param IndividuRole[] $individuRoles
     * @param These $these
@@ -96,7 +110,7 @@ class NotifierSoutenanceService extends NotifierService

    /**
     * @param These $these
     * @return array
     * @return string[]
     */
    protected function fetchEmailEcoleDoctorale(These $these) : array
    {
@@ -109,7 +123,7 @@ class NotifierSoutenanceService extends NotifierService
     * @param These $these
     * @return string[]
     */
    protected function fetchEmailUniteRecherche(These $these)
    protected function fetchEmailUniteRecherche(These $these) : array
    {
        /** @var IndividuRole[] $individuRoles */
        $individuRoles = $this->roleService->getIndividuRoleByStructure($these->getUniteRecherche()->getStructure());
@@ -120,7 +134,7 @@ class NotifierSoutenanceService extends NotifierService
     * @param These $these
     * @return string[]
     */
    protected function fetchEmailMaisonDuDoctorat(These $these)
    protected function fetchEmailMaisonDuDoctorat(These $these) : array
    {
        /** @var IndividuRole[] $individuRoles */
        $individuRoles = $this->roleService->getIndividuRoleByStructure($these->getEtablissement()->getStructure());
@@ -132,7 +146,7 @@ class NotifierSoutenanceService extends NotifierService
     * @param These $these
     * @return string[]
     */
    protected function fetchEmailEncadrants(These $these)
    protected function fetchEmailEncadrants(These $these) : array
    {
        $emails = [];
        $encadrants = $this->getActeurService()->getRepository()->findEncadrementThese($these);
@@ -151,7 +165,7 @@ class NotifierSoutenanceService extends NotifierService
     * @param These $these
     * @return array
     */
    protected function fetchEmailActeursDirects(These $these)
    protected function fetchEmailActeursDirects(These $these) : array
    {
        $emails = [];
        $emails[] = $these->getDoctorant()->getIndividu()->getEmail();
@@ -216,10 +230,14 @@ class NotifierSoutenanceService extends NotifierService
    /**
     * @param These $these
     * @see Application/view/soutenance/notification/validation-structure.phtml
     * @throws NotificationException
     */
    public function triggerNotificationUniteRechercheProposition($these)
    public function triggerNotificationUniteRechercheProposition(These $these)
    {
        $emails = $this->fetchEmailUniteRecherche($these);
        $individuRoles = $this->roleService->getIndividuRoleByStructure($these->getUniteRecherche()->getStructure());
        $panic = $this->hasEmailsByEtablissement($individuRoles, $these);
        $emails = $this->fetchEmailsByEtablissement($individuRoles, $these);
        //$emails = $this->fetchEmailUniteRecherche($these);

        if (!empty($emails)) {
            $notif = new Notification();
@@ -230,6 +248,7 @@ class NotifierSoutenanceService extends NotifierService
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'unité de recherche',
                    'panic' => $panic,
                ]);
            $this->trigger($notif);
        }
@@ -238,10 +257,14 @@ class NotifierSoutenanceService extends NotifierService
    /**
     * @param These $these
     * @see Application/view/soutenance/notification/validation-structure.phtml
     * @throws NotificationException
     */
    public function triggerNotificationEcoleDoctoraleProposition($these)
    public function triggerNotificationEcoleDoctoraleProposition(These $these)
    {
        $emails = $this->fetchEmailEcoleDoctorale($these);
        $individuRoles = $this->roleService->getIndividuRoleByStructure($these->getEcoleDoctorale()->getStructure());
        $panic = $this->hasEmailsByEtablissement($individuRoles, $these);
        $emails = $this->fetchEmailsByEtablissement($individuRoles, $these);
        //$emails = $this->fetchEmailEcoleDoctorale($these);

        if (!empty($emails)) {
            $notif = new Notification();
@@ -252,6 +275,7 @@ class NotifierSoutenanceService extends NotifierService
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'école doctorale',
                    'panic' => $panic,
                ]);
            $this->trigger($notif);
        }
@@ -260,8 +284,9 @@ class NotifierSoutenanceService extends NotifierService
    /**
     * @param These $these
     * @see Application/view/soutenance/notification/validation-structure.phtml
     * @throws NotificationException
     */
    public function triggerNotificationBureauDesDoctoratsProposition($these)
    public function triggerNotificationBureauDesDoctoratsProposition(These $these)
    {
        $email = $this->fetchEmailMaisonDuDoctorat($these);

@@ -274,13 +299,14 @@ class NotifierSoutenanceService extends NotifierService
                ->setTemplateVariables([
                    'these' => $these,
                    'type' => 'maison du doctorat',
                    'panic' => false,
                ]);
            $this->trigger($notif);
        }
    }

    /** @param These $these */
    public function triggerNotificationPropositionValidee($these)
    public function triggerNotificationPropositionValidee(These $these)
    {
        $emailsBDD = $this->fetchEmailMaisonDuDoctorat($these);
        $emailsED = $this->fetchEmailEcoleDoctorale($these);
+9 −0
Changes for module/Soutenance/view/soutenance/notification/validation-structure.phtml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ use Application\View\Renderer\PhpRenderer;
 * @var PhpRenderer $this
 * @var These $these
 * @var string $type
 * @var bool $panic
 */

$urlRetour = $this->url('soutenance/proposition', ['these' => $these->getId()], ['force_canonical'=>true], true);
@@ -60,4 +61,12 @@ $justification = true;
        <li> vous êtes un&middot;e gestionnaire du bureau des doctorat de l'établissement d'inscription du doctorant.</li>
    <?php endif; ?>
</ol>

    <?php if ($panic) : ?>
        <p>
            <strong>Aucun responsable de site n'a pu être trouvé pour le site '<?php echo $these->getEtablissement()->getLibelle(); ?>'</strong>.
            Par conséquent tous les responsables de la structure ont été notifiés.
        </p>
    <?php endif; ?>

<?php endif; ?>