Commit 0bc4a719 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Nouveau template et Notification SOUTENANCE_CONVOCATION_MEMBRE

parent 1819631c
Loading
Loading
Loading
Loading
+2 −1
Changes for doc/release-notes/v6.0.7.md: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ INSERT INTO unicaen_renderer_macro (code, description, variable_name, methode_na
('Soutenance#Lieu', '<p>Retourne le lieu inscrit dans la proposition</p>', 'soutenance', 'toStringLieu'),
('Soutenance#ModeSoutenance', '<p>Précise le caractère public ou huis clos</p>', 'soutenance', 'toStringPublicOuHuisClos'),
('Url#ConvocationMembre', null, 'Url', 'getSoutenanceConvocationMembre'),
('Url#ConvocationDoctorant', null, 'Url', 'getSoutenanceConvocationDoctorant')
('Url#ConvocationDoctorant', null, 'Url', 'getSoutenanceConvocationDoctorant'),
('These#Encadrement', null, 'these', 'toStringEncadrement')
;

-- Nouveaux templates
+2 −26
Changes for module/Soutenance/src/Soutenance/Controller/PresoutenanceController.php: 2 added lines, 26 removed lines.
Original line number Diff line number Diff line
@@ -681,33 +681,10 @@ class PresoutenanceController extends AbstractController
        $these = $this->requestedThese();
        $proposition = $this->getPropositionService()->findOneForThese($these);

        $validationMDD = $this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_VALIDATION_PROPOSITION_BDD, $these);
        $dateValidation = (!empty($validationMDD)) ? current($validationMDD)->getHistoModification() : null;

        $avisArray = [];
        /** @var Avis $avis */
        foreach ($proposition->getAvis() as $avis) {
            if ($avis->estNonHistorise()) {
                $denomination = $avis->getMembre()->getDenomination();
                $lien = $this->url()->fromRoute('soutenance/avis-soutenance/telecharger', [
                    'these' => $these->getId(),
                    'rapporteur' => $avis->getMembre()->getId()
                    ], [
                        'force_canonical'=>true
                    ], true);
                $avisArray[$denomination] = $lien;
            }
        }

        //doctorant
        $doctorant = $these->getDoctorant();
        $email = $doctorant->getIndividu()->getEmailContact() ?:
            $doctorant->getIndividu()->getEmailPro() ?:
            $doctorant->getIndividu()->getEmailUtilisateur();
        /** @see PresoutenanceController::convocationDoctorantAction() */
        $url = $this->url()->fromRoute('soutenance/presoutenance/convocation-doctorant', ['proposition' => $proposition->getId()], ['force_canonical' => true], true);
        try {
            $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationDoctorant($doctorant, $proposition, $dateValidation, $email, $url, $avisArray);
            $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationDoctorant($doctorant, $proposition);
            $this->notifierService->trigger($notif);
        } catch (\Notification\Exception\RuntimeException $e) {
            // aucun destinataire, todo : cas à gérer !
@@ -721,9 +698,8 @@ class PresoutenanceController extends AbstractController
                if ($membre->getIndividu() and $membre->getIndividu()->getEmailPro()) $email = $membre->getIndividu()->getEmailPro();
                if ($email === null or trim($email) === '') $email = $membre->getEmail();
                /** @see PresoutenanceController::convocationMembreAction() */
                $url = $this->url()->fromRoute('soutenance/presoutenance/convocation-membre', ['proposition' => $proposition->getId(), 'membre' => $membre->getId()], ['force_canonical' => true], true);
                try {
                    $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationMembre($membre, $proposition, $dateValidation, $email, $url, $avisArray);
                    $notif = $this->soutenanceNotificationFactory->createNotificationEnvoiConvocationMembre($membre, $proposition);
                    $this->notifierService->trigger($notif);
                } catch (\Notification\Exception\RuntimeException $e) {
                    // aucun destinataire, todo : cas à gérer !
+1 −0
Changes for module/Soutenance/src/Soutenance/Provider/Template/MailTemplates.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ class MailTemplates
    const SOUTENANCE_FEU_VERT                           = 'SOUTENANCE_FEU_VERT';
    const SOUTENANCE_STOP_DEMARCHE                      = 'SOUTENANCE_STOP_DEMARCHE';
    const SOUTENANCE_CONVOCATION_DOCTORANT              = 'SOUTENANCE_CONVOCATION_DOCTORANT';
    const SOUTENANCE_CONVOCATION_MEMBRE                 = 'SOUTENANCE_CONVOCATION_MEMBRE';
}
 No newline at end of file
+25 −31
Changes for module/Soutenance/src/Soutenance/Service/Notification/SoutenanceNotificationFactory.php: 25 added lines, 31 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use Application\Service\Email\EmailTheseServiceAwareTrait;
use Application\Service\Role\RoleServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Application\Service\Validation\ValidationServiceAwareTrait;
use DateTime;
use Doctorant\Entity\Db\Doctorant;
use Individu\Entity\Db\Individu;
use Notification\Exception\RuntimeException;
@@ -21,15 +20,19 @@ use Soutenance\Entity\Proposition;
use Soutenance\Provider\Template\MailTemplates;
use Soutenance\Service\Membre\MembreServiceAwareTrait;
use Soutenance\Service\Url\UrlServiceAwareTrait;
use Soutenance\Service\Validation\ValidatationServiceAwareTrait;
use These\Entity\Db\These;
use These\Service\Acteur\ActeurServiceAwareTrait;
use These\Service\These\TheseServiceAwareTrait;
use UnicaenRenderer\Service\Rendu\RenduServiceAwareTrait;

class StringElement {
class StringElement
{
    public string $texte = "Aucun texte";
    public function getTexte() : string {return $this->texte; }

    public function getTexte(): string
    {
        return $this->texte;
    }
}

/**
@@ -212,7 +215,8 @@ class SoutenanceNotificationFactory extends NotificationFactory
            throw new RuntimeException("Aucune adresse électronique trouvée pour les acteurs directs de la thèse {$these->getId()}");
        }

        $refus = new StringElement(); $refus->texte = $motif;
        $refus = new StringElement();
        $refus->texte = $motif;
        $vars = ['individu' => $currentUser, 'role' => $currentRole, 'etablissement' => $currentRole->getStructure(), 'stringelement' => $refus, 'these' => $these, 'doctorant' => $these->getDoctorant()];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;
@@ -536,7 +540,7 @@ class SoutenanceNotificationFactory extends NotificationFactory

    /** Mails de fin de procédure *************************************************************************************/

    public function createNotificationEnvoiConvocationDoctorant(Doctorant $doctorant, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification
    public function createNotificationEnvoiConvocationDoctorant(Doctorant $doctorant, Proposition $proposition): Notification
    {
        $email = $doctorant->getIndividu()->getEmailUtilisateur();
        if ($email === null) {
@@ -561,38 +565,28 @@ class SoutenanceNotificationFactory extends NotificationFactory
        return $notif;
    }

    /**
     * TODO
     */
    public function createNotificationEnvoiConvocationMembre(Membre $membre, Proposition $proposition, DateTime $date, string $email, string $url, array $avisArray): Notification
    public function createNotificationEnvoiConvocationMembre(Membre $membre, Proposition $proposition): Notification
    {
        $doctorant = $proposition->getThese()->getDoctorant();
        $these = $proposition->getThese();
        $pdcData = $this->getTheseService()->fetchInformationsPageDeCouverture($these);

        if ($email === null or $email === '') {
            throw new RuntimeException("Aucune adresse électronique pour le membre [" . $membre->getDenomination() . "]");
        $email = $membre->getEmail();
        if ($email === null) {
            throw new RuntimeException("Aucun mail pour la notification [" . MailTemplates::SOUTENANCE_CONVOCATION_DOCTORANT . "]");
        }
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new RuntimeException("L'adresse électronique est mal formée pour le membre [" . $membre->getDenomination() . "]");
        $validation = $this->getValidationService()->getRepository()->findValidationByCodeAndThese(TypeValidation::CODE_VALIDATION_PROPOSITION_BDD, $proposition->getThese());
        if (empty($validation)) {
            throw new RuntimeException("Aucune validation de trouvée");
        }

        $vars = ['soutenance' => $proposition, 'these' => $proposition->getThese(), 'membre' => $membre, 'validation' => $validation[0], 'etablissement' => $proposition->getThese()->getEtablissement()];
        $url = $this->getUrlService()->setVariables($vars);
        $vars['Url'] = $url;

        $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SOUTENANCE_CONVOCATION_MEMBRE, $vars);

        $notif = new Notification();
        $notif
            ->setSubject("Convocation pour la soutenance de thèse de  " . $doctorant->getNomComplet())
            ->setSubject($rendu->getSujet())
            ->setTo($email)
            ->setTemplatePath('soutenance/notification/convocation-membre')
            ->setTemplateVariables([
                'these' => $these,
                'proposition' => $proposition,
                'informations' => $pdcData,
                'date' => $date,
                'membre' => $membre,
                'url' => $url,

                'avisArray' => $avisArray,
            ]);

            ->setBody($rendu->getCorps());
        return $notif;
    }

+0 −112
Changes for module/Soutenance/view/soutenance/notification/convocation-membre.phtml: 0 added lines, 112 removed lines.
Original line number Diff line number Diff line
<?php

use These\Entity\Db\These;
use These\Service\FichierThese\PdcData;
use Soutenance\Entity\Avis;
use Soutenance\Entity\Membre;
use Soutenance\Entity\Proposition;

/**
 * @see \Soutenance\Service\Notification\SoutenanceNotificationFactory::createNotificationEnvoiConvocationMembre()
 * @var These $these
 * @var Proposition $proposition
 * @var Membre $membre
 * @var DateTime $date
 * @var PdcData $informations
 * @var string $url
 * @var array $avisArray $avisArray[Denomination] = lien_de_telechargement
 */
$civilite = ($membre->getGenre() !== "H")?"Madame":"Monsieur";
if ($membre->getIndividu()) $civilite = ($membre->getIndividu()->estUneFemme())?"Madame":"Monsieur";

$justification = true;
?>
<p>
    <?php echo $civilite ?>, <br/>
</p>

<p>
Par décision en date du
<?php if ($date): ?>
    <?php echo $date->format('d/m/Y'); ?>,
<?php else: ?>
    <span style='background-color:red;'>
                Date manquante,
        </span>
<?php endif; ?>
le chef de l'établissement <?php echo  $these->getEtablissement()->getStructure()->getLibelle(); ?> vous a désigné<?php if($civilite==="Madame") echo "e"; ?>
pour participer au jury devant examiner les travaux de <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(true); ?>
en vue de l'obtention du diplôme : <br/>
Doctorat en <?php echo $these->getLibelleDiscipline(); ?>.
</p>

<p>
    Le titre des travaux est : <?php echo $these->getTitre(); ?>
</p>

<?php
$encadrement = array_merge($informations->getDirecteurs(), $informations->getCodirecteurs());
$texte_directeur = implode(" et ", $encadrement);
?>

<p>
    Les travaux sont dirigées par <?php echo $texte_directeur; ?>.
</p>

<p>
    La soutenance aura lieu le
    <?php if ($proposition->getDate() !== null): ?>
        <?php echo $proposition->getDate()->format('d/m/Y à H:i'); ?>
    <?php else : ?>
        <span style='background-color:red;'>
                Date manquante
        </span>
    <?php endif; ?> à l'adresse suivante : <br/>
    <?php if ($proposition->getAdresse() !== null): ?>
        <?php echo $proposition->getAdresse(); ?>
    <?php else : ?>
        <span style='background-color:red;'>
                    Adresse manquante
            </span>
        <br/>
    <?php endif; ?>
</p>

<p>
    La soutenance <?php if ($proposition && $proposition->isHuitClos() !== null): ?>
        <?php if ($proposition->isHuitClos()) : ?>
            se déroulera en huis clos.
        <?php else : ?>
            sera publique.
        <?php endif ; ?>
    <?php else: ?>
        <span style='background-color:red;'> information sur l'aspect public manquante </span>
    <?php endif; ?>
</p>

<p>
    Vous pouvez accéder aux rapports de présoutenance grâce aux liens suivants :
<ul>
    <?php /** @var Avis $avis */?>
    <?php foreach ($avisArray as $denomination => $lien) : ?>
        <li>
            Avis de soutenance de <?php echo $denomination; ?> :
            <a href="<?php echo $lien; ?>"> Télécharger le pré-rapport de soutenance</a>
        </li>
    <?php endforeach; ?>
</ul>
</p>

<p>
    Je vous prie d'agréer, <?php echo $civilite; ?>, l'expression de mes salutations distinguées.
</p>

<p> P.S.: Vous pouvez obtenir une version imprimable de cette convocation à l'adresse suivante : <a href="<?php echo $url; ?>">convocation au format PDF</a> </p>

<?php if ($justification) : ?>
    Vous avez reçu ce mail car :
    <ol>
        <li> la proposition de soutenance de <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(); ?> a été validé;  </li>
        <li> vous avez été désigné comme membre du jury pour la thèse de <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(); ?>. </li>
    </ol>
<?php endif; ?>
Loading