Skip to content
Snippets Groups Projects
Commit b73ccb90 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

...

parent 76585996
No related branches found
No related tags found
No related merge requests found
......@@ -317,12 +317,34 @@ class SessionController extends AbstractActionController
return $this->redirect()->toRoute('session/afficher', ['session' => $instance->getId()], [], true);
}
public function envoyerConvocationAction(): Response
public function envoyerConvocationAction(): ViewModel
{
$session = $this->getSessionService()->getRequestedSession($this);
$this->getSessionService()->envoyerConvocation($session);
$probleme = [];
foreach ($mails as $individu => $mail) {
if ($mail === null) {
$probleme[] = $individu;
}
}
if (!empty($probleme)) {
$problemeTexte = "Les stagiaire·s suivant·es n'ont pas pu être convoqué·es : <ul>";
foreach ($probleme as $individu) $problemeTexte .= "<li>" . $individu . "</li>";
$problemeTexte .= "</ul>";
}
$this->getSessionService()->envoyerEmargement($session);
return $this->redirect()->toRoute('session/afficher', ['session' => $session->getId()], [], true);
$vm = new ViewModel([
'title' => "Envoi des convocations",
'reponse' => "Opération effectuée",
'error' => $problemeTexte??null,
]);
$vm->setTemplate('default/reponse');
return $vm;
}
public function demanderRetourAction(): ViewModel
......
......@@ -277,6 +277,7 @@ class NotificationService
foreach ($superieurs as $superieur) $copie[] = $superieur->getValidateur()->getEmail();
}
if ($inscrit->getIndividu() !== null AND $inscrit->getIndividu()->getEmail() !== null) {
$rendu = $this->getRenduService()->generateRenduByTemplateCode(MailTemplates::SESSION_CONVOCATION, $vars);
$mail = $this->getMailService()->sendMail($agent->getEmail(), $rendu->getSujet(), $rendu->getCorps(), 'Formation', null, $copie);
$mail->setMotsClefs([$session->generateTag(), $inscrit->generateTag(), $rendu->getTemplate()->generateTag()]);
......@@ -285,6 +286,8 @@ class NotificationService
$this->getObjectManager()->flush($session);
return $mail;
}
return null;
}
/** Notification envoyée vers les stagaires pour leur demander leurs retours */
public function triggerDemandeRetour(Inscription $inscrit): ?Mail
......
......@@ -400,8 +400,10 @@ class SessionService
return $instance;
}
public function envoyerConvocation(Session $session, ?Inscription $inscription = null): Session
/** @return Mail[] $mails */
public function envoyerConvocation(Session $session, ?Inscription $inscription = null): array
{
$mails = [];
if ($inscription === null) {
$this->getEtatInstanceService()->setEtatActif($session, SessionEtats::ETAT_FORMATION_CONVOCATION);
$this->update($session);
......@@ -413,11 +415,11 @@ class SessionService
if ($configuration === null OR $configuration->isActive()) {
foreach ($liste as $inscrit) {
if ($inscrit->estNonHistorise()) {
$this->getNotificationService()->triggerConvocation($inscrit);
$mails[$inscrit->getIndividu()->getDenomination()] = $this->getNotificationService()->triggerConvocation($inscrit);
}
}
}
return $session;
return $mails;
}
/** @return Mail[] $mails */
......@@ -463,9 +465,6 @@ class SessionService
return $session;
}
/**
* @param Session $instance
* @return Session
......
......@@ -145,7 +145,7 @@ $canMesSessions = $this->isAllowed(FormateurPrivileges::getResourceId(FormateurP
<br/>
<a <?php /** @see SessionController::envoyerConvocationAction() */ ?>
href="<?php echo $this->url('session/envoyer-convocation', ['session' => $session->getId()], [], true); ?>"
class="btn btn-primary">
class="btn btn-primary ajax-modal">
Convoquer les inscrits
</a>
<?php endif; ?>
......@@ -153,7 +153,7 @@ $canMesSessions = $this->isAllowed(FormateurPrivileges::getResourceId(FormateurP
<br/>
<a <?php /** @see SessionController::demanderRetourAction() */ ?>
href="<?php echo $this->url('session/demander-retour', ['session' => $session->getId()], [], true); ?>"
class="btn btn-primary ajax-modal" data-event="modification">
class="btn btn-primary ajax-modal">
Demander les retours
</a>
<?php endif; ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment