Loading module/Evenementiel/config/merged/Evenement.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ return [ 'controller' => EvenementController::class, 'action' => [ 'changer-etat', 'notifier-inscrit' ], 'privileges' => [ EvenementPrivileges::EVENEMENT_GERER_ETAT, Loading Loading @@ -338,6 +339,16 @@ return [ ], ], ], 'notifier-inscrit' => [ 'type' => Segment::class, 'options' => [ /** @see EvenementController::notifierInscritAction() */ 'route' => '/notifier-inscrit/:entity', 'defaults' => [ 'action' => 'notifier-inscrit', ], ], ], ], ], ], Loading module/Evenementiel/config/module.config.php +9 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,17 @@ use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Evenementiel\Form\Notification\NotificationForm; use Evenementiel\Form\Notification\NotificationFormFactory; use Evenementiel\Form\Notification\NotificationHydrator; use Evenementiel\Form\Notification\NotificationHydratorFactory; use Evenementiel\Service\Macro\MacroService; use Evenementiel\Service\Macro\MacroServiceFactory; use Evenementiel\Service\Notification\NotificationService; use Evenementiel\Service\Notification\NotificationServiceFactory; use Evenementiel\Service\Url\UrlService; use Evenementiel\Service\Url\UrlServiceFactory; use Evenementiel\View\Helper\InscriptionButtonHelper; return array( 'doctrine' => [ Loading Loading @@ -47,10 +52,12 @@ return array( ], 'form_elements' => [ 'factories' => [ NotificationForm::class => NotificationFormFactory::class, ], ], 'hydrators' => [ 'invokables' => [ 'factories' => [ NotificationHydrator::class => NotificationHydratorFactory::class, ], ], 'controllers' => [ Loading @@ -59,7 +66,7 @@ return array( ], 'view_helpers' => [ 'invokables' => [ 'inscriptionButton' => \Evenementiel\View\Helper\InscriptionButtonHelper::class, 'inscriptionButton' => InscriptionButtonHelper::class, ], ], Loading module/Evenementiel/src/Controller/EvenementController.php +67 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Evenementiel\Controller; use Etudiant\Provider\Role\RolesProvider as EtudiantRolesProvider; use Evenementiel\Form\Inscription\InscriptionPersonnelFormAwareTrait; use Evenementiel\Form\Notification\NotificationFormAwareTrait; use Personnel\Provider\Role\RolesProvider as PersonnelRolesProvider; use Etudiant\Service\Etudiant\EtudiantServiceAwareTrait; use Evenementiel\Entity\Db\Evenement; Loading Loading @@ -52,6 +53,7 @@ class EvenementController extends AbstractActionController use MailServiceAwareTrait; use PersonnelServiceAwareTrait; use InscriptionPersonnelFormAwareTrait; use NotificationFormAwareTrait; /** * Afficher la liste des entités Loading Loading @@ -648,5 +650,69 @@ class EvenementController extends AbstractActionController } public function notifierInscritAction(): ViewModel { $evenement = $this->getEvenementService()->getRequestedEntity($this); $form = $this->getNotificationForm(); $form->setAttribute('action', $this->url()->fromRoute('evenementiel/evenement/notifier-inscrit', ['entity' => $evenement->getId()], [], true)); $form->bind($evenement); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $inscriptions = match ($data['liste']) { Inscription::PRINCIPALE => $evenement->getListePrincipale(), Inscription::ATTENTE => $evenement->getListeAttente(), 'tous' => $evenement->getListeValide(), default => [], }; $sujet = trim($data['sujet']); $corps = trim($data['corps']); foreach ($inscriptions as $inscription) { $adresse = $inscription->getParticipant()->getEmail(); $mails[$inscription->getParticipant()->getDenomination()] = ($adresse) ? $this->getMailService()->sendMail($adresse, $sujet, $corps) : null; if ($mails[$inscription->getParticipant()->getDenomination()]) { $mails[$inscription->getParticipant()->getDenomination()]->setMotsClefs([$evenement->generateTag(), $inscription->generateTag(), 'Notification interne']); $this->getMailService()->update($mails[$inscription->getParticipant()->getDenomination()]); } } $this->getEvenementService()->update($evenement); $success = []; $probleme = []; foreach ($mails as $individu => $mail) { if ($mail === null) $probleme[] = $individu; else $success[] = $individu; } if (!empty($success)) { $successTexte = " Les inscrits 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' => "Notification des inscrits", 'reponse' => "Opération effectuée", 'success' => $successTexte ?? null, 'error' => $problemeTexte ?? null, ]); $vm->setTemplate('default/reponse'); return $vm; } } $vm = new ViewModel([ 'title' => "Notification des inscrits", 'form' => $form, ]); $vm->setTemplate('default/default-form'); return $vm; } } module/Evenementiel/src/Controller/EvenementControllerFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Evenementiel\Form\Evenement\EvenementForm; use Evenementiel\Form\Inscription\InscriptionEtudiantForm; use Evenementiel\Form\Inscription\InscriptionParticipantForm; use Evenementiel\Form\Inscription\InscriptionPersonnelForm; use Evenementiel\Form\Notification\NotificationForm; use Evenementiel\Service\Evenement\EvenementService; use Evenementiel\Service\Inscription\InscriptionService; use Evenementiel\Service\Notification\NotificationService; Loading Loading @@ -50,6 +51,7 @@ class EvenementControllerFactory * @var NotificationService $notificationService * @var MailService $mailService * @var PersonnelService $personnelService * @var NotificationForm $notificationForm */ $evenementService = $container->get(EvenementService::class); $evenementForm = $container->get("FormElementManager")->get(EvenementForm::class); Loading @@ -68,6 +70,7 @@ class EvenementControllerFactory $notificationService = $container->get(NotificationService::class); $mailService = $container->get(MailService::class); $personnelService = $container->get(PersonnelService::class); $notificationForm = $container->get('FormElementManager')->get(NotificationForm::class); $controller = new EvenementController(); $controller->setEvenementService($evenementService); Loading @@ -87,6 +90,7 @@ class EvenementControllerFactory $controller->setNotificationService($notificationService); $controller->setMailService($mailService); $controller->setPersonnelService($personnelService); $controller->setNotificationForm($notificationForm); return $controller; } Loading module/Evenementiel/src/Form/Notification/NotificationForm.php 0 → 100644 +87 −0 Original line number Diff line number Diff line <?php namespace Evenementiel\Form\Notification; use Evenementiel\Entity\Db\Inscription; use Laminas\Form\Element\Button; use Laminas\Form\Element\Select; use Laminas\Form\Element\Text; use Laminas\Form\Element\Textarea; use Laminas\Form\Form; use Laminas\InputFilter\Factory; class NotificationForm extends Form { public function init(): void { // liste $this->add([ 'type' => Select::class, 'name' => 'liste', 'options' => [ 'label' => "Liste à notifier <span class='icon icon-obligatoire' title='Obligatoire'></span> :", 'label_options' => [ 'disable_html_escape' => true, ], 'empty_option' => "Sélectionner une liste d'inscrit·e ...", 'value_options' => [ Inscription::PRINCIPALE => 'Liste principale', Inscription::ATTENTE => "Liste d'attente", 'tous' => 'Tou·tes les inscrit·es', ], ], 'attributes' => [ 'id' => 'liste', 'class' => 'bootstrap-selectpicker show-tick', 'data-live-search' => 'true', ], ]); // libelle $this->add([ 'type' => Text::class, 'name' => 'sujet', 'options' => [ 'label' => "Sujet du courrier <span class='icon icon-obligatoire' title='Champ obligatoire'></span>:", 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'id' => 'sujet', ], ]); // corps $this->add([ 'name' => 'corps', 'type' => Textarea::class, 'options' => [ 'label' => "Corps du courrier <span class='icon icon-obligatoire' title='Champ obligatoire'></span>:", 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'id' => 'corps', 'class' => 'tinymce', ], ]); //bouton $this->add([ 'type' => Button::class, 'name' => 'creer', 'options' => [ 'label' => '<span class="icon icon-notifier"></span> Notifier ', 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'type' => 'submit', 'class' => 'btn btn-success', ], ]); //input filter $this->setInputFilter((new Factory())->createInputFilter([ 'liste' => ['required' => true,], 'sujet' => ['required' => true,], 'corps' => ['required' => true,], ])); } } No newline at end of file Loading
module/Evenementiel/config/merged/Evenement.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ return [ 'controller' => EvenementController::class, 'action' => [ 'changer-etat', 'notifier-inscrit' ], 'privileges' => [ EvenementPrivileges::EVENEMENT_GERER_ETAT, Loading Loading @@ -338,6 +339,16 @@ return [ ], ], ], 'notifier-inscrit' => [ 'type' => Segment::class, 'options' => [ /** @see EvenementController::notifierInscritAction() */ 'route' => '/notifier-inscrit/:entity', 'defaults' => [ 'action' => 'notifier-inscrit', ], ], ], ], ], ], Loading
module/Evenementiel/config/module.config.php +9 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,17 @@ use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Evenementiel\Form\Notification\NotificationForm; use Evenementiel\Form\Notification\NotificationFormFactory; use Evenementiel\Form\Notification\NotificationHydrator; use Evenementiel\Form\Notification\NotificationHydratorFactory; use Evenementiel\Service\Macro\MacroService; use Evenementiel\Service\Macro\MacroServiceFactory; use Evenementiel\Service\Notification\NotificationService; use Evenementiel\Service\Notification\NotificationServiceFactory; use Evenementiel\Service\Url\UrlService; use Evenementiel\Service\Url\UrlServiceFactory; use Evenementiel\View\Helper\InscriptionButtonHelper; return array( 'doctrine' => [ Loading Loading @@ -47,10 +52,12 @@ return array( ], 'form_elements' => [ 'factories' => [ NotificationForm::class => NotificationFormFactory::class, ], ], 'hydrators' => [ 'invokables' => [ 'factories' => [ NotificationHydrator::class => NotificationHydratorFactory::class, ], ], 'controllers' => [ Loading @@ -59,7 +66,7 @@ return array( ], 'view_helpers' => [ 'invokables' => [ 'inscriptionButton' => \Evenementiel\View\Helper\InscriptionButtonHelper::class, 'inscriptionButton' => InscriptionButtonHelper::class, ], ], Loading
module/Evenementiel/src/Controller/EvenementController.php +67 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Evenementiel\Controller; use Etudiant\Provider\Role\RolesProvider as EtudiantRolesProvider; use Evenementiel\Form\Inscription\InscriptionPersonnelFormAwareTrait; use Evenementiel\Form\Notification\NotificationFormAwareTrait; use Personnel\Provider\Role\RolesProvider as PersonnelRolesProvider; use Etudiant\Service\Etudiant\EtudiantServiceAwareTrait; use Evenementiel\Entity\Db\Evenement; Loading Loading @@ -52,6 +53,7 @@ class EvenementController extends AbstractActionController use MailServiceAwareTrait; use PersonnelServiceAwareTrait; use InscriptionPersonnelFormAwareTrait; use NotificationFormAwareTrait; /** * Afficher la liste des entités Loading Loading @@ -648,5 +650,69 @@ class EvenementController extends AbstractActionController } public function notifierInscritAction(): ViewModel { $evenement = $this->getEvenementService()->getRequestedEntity($this); $form = $this->getNotificationForm(); $form->setAttribute('action', $this->url()->fromRoute('evenementiel/evenement/notifier-inscrit', ['entity' => $evenement->getId()], [], true)); $form->bind($evenement); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $inscriptions = match ($data['liste']) { Inscription::PRINCIPALE => $evenement->getListePrincipale(), Inscription::ATTENTE => $evenement->getListeAttente(), 'tous' => $evenement->getListeValide(), default => [], }; $sujet = trim($data['sujet']); $corps = trim($data['corps']); foreach ($inscriptions as $inscription) { $adresse = $inscription->getParticipant()->getEmail(); $mails[$inscription->getParticipant()->getDenomination()] = ($adresse) ? $this->getMailService()->sendMail($adresse, $sujet, $corps) : null; if ($mails[$inscription->getParticipant()->getDenomination()]) { $mails[$inscription->getParticipant()->getDenomination()]->setMotsClefs([$evenement->generateTag(), $inscription->generateTag(), 'Notification interne']); $this->getMailService()->update($mails[$inscription->getParticipant()->getDenomination()]); } } $this->getEvenementService()->update($evenement); $success = []; $probleme = []; foreach ($mails as $individu => $mail) { if ($mail === null) $probleme[] = $individu; else $success[] = $individu; } if (!empty($success)) { $successTexte = " Les inscrits 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' => "Notification des inscrits", 'reponse' => "Opération effectuée", 'success' => $successTexte ?? null, 'error' => $problemeTexte ?? null, ]); $vm->setTemplate('default/reponse'); return $vm; } } $vm = new ViewModel([ 'title' => "Notification des inscrits", 'form' => $form, ]); $vm->setTemplate('default/default-form'); return $vm; } }
module/Evenementiel/src/Controller/EvenementControllerFactory.php +4 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Evenementiel\Form\Evenement\EvenementForm; use Evenementiel\Form\Inscription\InscriptionEtudiantForm; use Evenementiel\Form\Inscription\InscriptionParticipantForm; use Evenementiel\Form\Inscription\InscriptionPersonnelForm; use Evenementiel\Form\Notification\NotificationForm; use Evenementiel\Service\Evenement\EvenementService; use Evenementiel\Service\Inscription\InscriptionService; use Evenementiel\Service\Notification\NotificationService; Loading Loading @@ -50,6 +51,7 @@ class EvenementControllerFactory * @var NotificationService $notificationService * @var MailService $mailService * @var PersonnelService $personnelService * @var NotificationForm $notificationForm */ $evenementService = $container->get(EvenementService::class); $evenementForm = $container->get("FormElementManager")->get(EvenementForm::class); Loading @@ -68,6 +70,7 @@ class EvenementControllerFactory $notificationService = $container->get(NotificationService::class); $mailService = $container->get(MailService::class); $personnelService = $container->get(PersonnelService::class); $notificationForm = $container->get('FormElementManager')->get(NotificationForm::class); $controller = new EvenementController(); $controller->setEvenementService($evenementService); Loading @@ -87,6 +90,7 @@ class EvenementControllerFactory $controller->setNotificationService($notificationService); $controller->setMailService($mailService); $controller->setPersonnelService($personnelService); $controller->setNotificationForm($notificationForm); return $controller; } Loading
module/Evenementiel/src/Form/Notification/NotificationForm.php 0 → 100644 +87 −0 Original line number Diff line number Diff line <?php namespace Evenementiel\Form\Notification; use Evenementiel\Entity\Db\Inscription; use Laminas\Form\Element\Button; use Laminas\Form\Element\Select; use Laminas\Form\Element\Text; use Laminas\Form\Element\Textarea; use Laminas\Form\Form; use Laminas\InputFilter\Factory; class NotificationForm extends Form { public function init(): void { // liste $this->add([ 'type' => Select::class, 'name' => 'liste', 'options' => [ 'label' => "Liste à notifier <span class='icon icon-obligatoire' title='Obligatoire'></span> :", 'label_options' => [ 'disable_html_escape' => true, ], 'empty_option' => "Sélectionner une liste d'inscrit·e ...", 'value_options' => [ Inscription::PRINCIPALE => 'Liste principale', Inscription::ATTENTE => "Liste d'attente", 'tous' => 'Tou·tes les inscrit·es', ], ], 'attributes' => [ 'id' => 'liste', 'class' => 'bootstrap-selectpicker show-tick', 'data-live-search' => 'true', ], ]); // libelle $this->add([ 'type' => Text::class, 'name' => 'sujet', 'options' => [ 'label' => "Sujet du courrier <span class='icon icon-obligatoire' title='Champ obligatoire'></span>:", 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'id' => 'sujet', ], ]); // corps $this->add([ 'name' => 'corps', 'type' => Textarea::class, 'options' => [ 'label' => "Corps du courrier <span class='icon icon-obligatoire' title='Champ obligatoire'></span>:", 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'id' => 'corps', 'class' => 'tinymce', ], ]); //bouton $this->add([ 'type' => Button::class, 'name' => 'creer', 'options' => [ 'label' => '<span class="icon icon-notifier"></span> Notifier ', 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'type' => 'submit', 'class' => 'btn btn-success', ], ]); //input filter $this->setInputFilter((new Factory())->createInputFilter([ 'liste' => ['required' => true,], 'sujet' => ['required' => true,], 'corps' => ['required' => true,], ])); } } No newline at end of file