diff --git a/database/migration/1.0.5.sql b/database/migration/1.0.5.sql new file mode 100644 index 0000000000000000000000000000000000000000..d036622e58a1fd6c0dde58defa5c44550c12bb85 --- /dev/null +++ b/database/migration/1.0.5.sql @@ -0,0 +1,3 @@ +INSERT INTO unicaen_renderer_template (code, description, document_type, document_sujet, document_corps, document_css, namespace) VALUES ('FORMATION_SESSION_RAPPEL_DEMANDE_VALIDATION', '<p>Courrier de rappel de la demande de validation d''une inscription à une formation du plan de formation</p>', 'mail', 'RAPPEL Vous n''avez pas encore validé la demande de formation de VAR[AGENT#Denomination]', e'<p>Bonjour,</p> +<p>Vous n\'avez pas encore validé la demande de formation de VAR[AGENT#Denomination] pour la session VAR[SESSION#libelle] du VAR[SESSION#periode].<br>Veuillez vous rendre dans votre tableau de bord en tant que Valideur·euse sur l\'application VAR[Macro#AppName] (VAR[Url#AppLink]) afin de statuer sur cette demande.</p> +<p>Bonne journée,<br>L\'application VAR[Macro#AppName]</p>', null, 'Formation\Provider\Template'); diff --git a/module/Formation/config/merged/session.config.php b/module/Formation/config/merged/session.config.php index 3f597a60fd86d805e5a5302da6f892dc3677a68e..3aefc05f148efd3d5cc3487536659bbd44ef3ba4 100644 --- a/module/Formation/config/merged/session.config.php +++ b/module/Formation/config/merged/session.config.php @@ -110,6 +110,8 @@ return [ 'demander-retour', 'cloturer', 'changer-etat', + + 'notifier-responsable-pour-validation', ], 'privileges' => [ FormationinstancePrivileges::FORMATIONINSTANCE_GERER_INSCRIPTION, @@ -383,6 +385,17 @@ return [ ], ], ], + /** notification **********************************************************/ + 'notifier-responsable-pour-validation' => [ + 'type' => Segment::class, + 'options' => [ + 'route' => '/notifier-responsable-pour-validation/:session', + 'defaults' => [ + /** @see SessionController::notifierResponsablePourValidationAction() */ + 'action' => 'notifier-responsable-pour-validation', + ], + ], + ], /** gestion des formateurs ************************************************/ 'ajouter-formateur' => [ 'type' => Segment::class, diff --git a/module/Formation/src/Formation/Controller/InscriptionController.php b/module/Formation/src/Formation/Controller/InscriptionController.php index 8b028e96ee7b97cc837fc0930028d867ed100748..484f1615f4951772c10e0ce461b7b377a9f75897 100644 --- a/module/Formation/src/Formation/Controller/InscriptionController.php +++ b/module/Formation/src/Formation/Controller/InscriptionController.php @@ -618,7 +618,7 @@ class InscriptionController extends AbstractActionController $form->setData($data); if ($form->isValid()) { $plafond = $this->getParametreService()->getValeurForParametre(FormationParametres::TYPE, FormationParametres::INSCRIPTION_PLAFOND_ANNUEL); - $volumeAnnuel = $this->getInscriptionService()->getVolumeAnnuelByAgent($agent, $session->getDebut(true)->format("Y")) + $session->getDuree(true); + $volumeAnnuel = $this->getInscriptionService()->getVolumeAnnuelByAgent($agent, ($session->getDebut(true))?$session->getDebut(true)->format("Y"):0) + $session->getDuree(true); $justification = (isset($data['justification']) && trim($data['justification']) !== '') ? trim($data['justification']) : null; if ($justification === null) { diff --git a/module/Formation/src/Formation/Controller/SessionController.php b/module/Formation/src/Formation/Controller/SessionController.php index e49ac282520592531cc2b407de526227aab8bed3..6308b78cfe65059edf6798c192d3dfc4d00ddc55 100644 --- a/module/Formation/src/Formation/Controller/SessionController.php +++ b/module/Formation/src/Formation/Controller/SessionController.php @@ -8,6 +8,7 @@ use Formation\Form\Annulation\AnnulationFormAwareTrait; use Formation\Form\SelectionFormateur\SelectionFormateurFormAwareTrait; use Formation\Form\SelectionGestionnaire\SelectionGestionnaireFormAwareTrait; use Formation\Form\Session\SessionFormAwareTrait; +use Formation\Provider\Etat\InscriptionEtats; use Formation\Provider\Etat\SessionEtats; use Formation\Provider\Parametre\AutreParametres; use Formation\Provider\Role\FormationRoles; @@ -569,6 +570,45 @@ class SessionController extends AbstractActionController ]); } + + public function notifierResponsablePourValidationAction(): ViewModel + { + $session = $this->getSessionService()->getRequestedSession($this); + $inscriptions = $this->getInscriptionService()->getInscriptionsBySession($session); + $inscriptions = array_filter($inscriptions, function (Inscription $inscription) { + return $inscription->estNonHistorise() AND $inscription->isEtatActif(InscriptionEtats::ETAT_DEMANDE); + }); + + $mails = []; + /** @var Inscription $inscription */ + foreach ($inscriptions as $inscription) + { + $mails[$inscription->getIndividu()->getDenomination()] = $this->getNotificationService()->triggerRappelDemandeValidationValideur($inscription); + } + + $success = []; $probleme = []; + foreach ($mails as $individu => $mail) { + if ($mail === null) $probleme[] = $individu; else $success[] = $individu; + } + if (!empty($success)) { + $successTexte = " Les valideur·deuses ont été notifié·es (".count($success)." courrier·s envoyé·s)."; + } + if (!empty($probleme)) { + $problemeTexte = "L'opération n'a pas pu être faite pour les inscriptions de : <ul>"; + foreach ($probleme as $individu) $problemeTexte .= "<li>" . $individu . "</li>"; + $problemeTexte .= "</ul>"; + } + + $vm = new ViewModel([ + 'title' => "Courrier de rappel de demande de validation", + 'reponse' => "Opération effectuée", + 'success' => $successTexte??null, + 'error' => $problemeTexte??null, + ]); + $vm->setTemplate('default/reponse'); + return $vm; + } + public function resultatEnqueteAction(): ViewModel { $session = $this->getSessionService()->getRequestedSession($this); diff --git a/module/Formation/src/Formation/Provider/Template/MailTemplates.php b/module/Formation/src/Formation/Provider/Template/MailTemplates.php index 95c4f29ba8cf9f16bc82aec539e69e96eb103158..36a6aa1103103dfb06f0c1aa2efc905ef5ddb769 100644 --- a/module/Formation/src/Formation/Provider/Template/MailTemplates.php +++ b/module/Formation/src/Formation/Provider/Template/MailTemplates.php @@ -26,6 +26,8 @@ class MailTemplates { const SESSION_DEMANDE_RETOUR = "FORMATION_SESSION_DEMANDE_RETOUR"; const SESSION_ANNULEE = "FORMATION_SESSION_ANNULEE"; + //notification de rappel ou de precision + const SESSION_RAPPEL_DEMANDE_VALIDATION = "FORMATION_SESSION_RAPPEL_DEMANDE_VALIDATION"; //rappel const FORMATION_RAPPEL_AVANT_FORMATION = "FORMATION_NOTIFICATION_SESSION_IMMINENTE"; const FORMATION_INSCRIPTION_OUVERTE = "FORMATION_NOTIFICATION_ABONNEMENT_FORMATION"; diff --git a/module/Formation/src/Formation/Service/Notification/NotificationService.php b/module/Formation/src/Formation/Service/Notification/NotificationService.php index bc1fb17d5b85eb496e50f194ad1cd2f3678dfc06..25aeeeff1f47e4f881efba1b4b0883097ad0169a 100644 --- a/module/Formation/src/Formation/Service/Notification/NotificationService.php +++ b/module/Formation/src/Formation/Service/Notification/NotificationService.php @@ -411,6 +411,30 @@ class NotificationService return null; } + public function triggerRappelDemandeValidationValideur(Inscription $inscription): ?Mail + { + $valideurs = $this->getAgentValidateurService()->getAgentsValidateursByAgent($inscription->getAgent()); + if (empty($valideurs)) return null; + + $adresses = []; + foreach ($valideurs as $valideur) { + if ($valideur->getAgent()->getEmail()) $adresses[] = $valideur->getValidateur()->getEmail(); + } + if (empty($adresses)) return null; + + $session = $inscription->getSession(); + + $vars = $this->generateVariableArray($inscription); + $rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_RAPPEL_DEMANDE_VALIDATION, $vars); + $mail = $this->getMailService()->sendMail($adresses, $rendu->getSujet(), $rendu->getCorps(), 'Formation'); + $mail->setMotsClefs([$session->generateTag(), $inscription->generateTag(), $rendu->getTemplate()->generateTag()]); + $this->getMailService()->update($mail); + $session->addMail($mail); + $this->getObjectManager()->flush($session); + return $mail; + + } + /** Mails de rappel ***********************************************************************************************/ public function triggerRappelAgentAvantFormation(Session $session): ?array diff --git a/module/Formation/view/formation/session/partial/inscrits.phtml b/module/Formation/view/formation/session/partial/inscrits.phtml index abfa131b21c1f1677d286381909af22736abedcd..24160402731e1d9708adde79771d1fe1b445b46f 100644 --- a/module/Formation/view/formation/session/partial/inscrits.phtml +++ b/module/Formation/view/formation/session/partial/inscrits.phtml @@ -34,6 +34,7 @@ $canSupprimerInscription = $this->isAllowed(FormationinstancePrivileges::getReso $urlRetour = $this->url('session/afficher', ['session' => $instance->getId()], ['fragment' => 'inscriptions'], true); +$canNotifierValideur = $this->isAllowed(FormationinstancePrivileges::getResourceId(FormationinstancePrivileges::FORMATIONINSTANCE_GERER_INSCRIPTION)); $liste = $instance->getListeDisponible(); $principaleComplete = $instance->isListePrincipaleComplete(); @@ -43,6 +44,14 @@ $inscriptions = $instance->getInscriptions() ?> +<?php /** @see \Formation\Controller\SessionController::notifierResponsablePourValidationAction() */ ?> +<a href="<?php echo $this->url('session/notifier-responsable-pour-validation', ['session' => $instance->getId()], []); ?>" + class="btn btn-primary ajax-modal" data-event="modification" +> + <span class="icon icon-notifier"></span> + Rappel de la demande de validation aux valideur·euses +</a> + <div class="row"> <div class="col-md-6"> <h2>