Loading module/Evenementiel/config/merged/Inscription.config.php +11 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ return [ [ 'controller' => InscriptionController::class, 'action' => [ 'supprimer', 'supprimer', "supprimer-place" ], 'privileges' => [ EvenementielinscriptionPrivileges::SUPPRIMER, Loading Loading @@ -264,6 +264,16 @@ return [ ], ], ], 'supprimer-place' => [ 'type' => Segment::class, 'options' => [ 'route' => '/supprimer-place/:entity[/:place]', 'defaults' => [ /** @see InscriptionController::supprimerPlaceAction() */ 'action' => 'supprimer-place', ], ], ], 'pointer-msg' => [ 'type' => Segment::class, 'options' => [ Loading module/Evenementiel/src/Controller/InscriptionController.php +27 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,33 @@ class InscriptionController extends AbstractActionController return $this->redirect()->toRoute("evenementiel/inscription", [], [], true); } public function supprimerPlaceAction(): ViewModel { $inscription = $this->getInscriptionService()->getRequestedEntity($this); $inscriptionPlace = $this->getInscriptionService()->getRequestedInscriptionPlace($this, $inscription); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if ($data["reponse"] === "oui") { if ($this->getInscriptionService()->deleteInscriptionPlace($inscription, $inscriptionPlace)) { $this->flashMessenger()->addSuccessMessage("La place a été supprimé."); } else { $this->flashMessenger()->addWarningMessage("La place n'a pas été supprimé."); } } exit(); } $vm = new ViewModel(); $vm->setTemplate("default/confirmation"); $vm->setVariables([ "title" => "Supprimer une place", "text" => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?", "action" => $this->url()->fromRoute("evenementiel/inscription/supprimer-place", ['entity' => $inscription->getId(), 'place' => $inscriptionPlace->getId()]), ]); return $vm; } /** * Supprimer une entité * Loading module/Evenementiel/src/Service/Inscription/InscriptionService.php +16 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,22 @@ class InscriptionService return $place; } public function deleteInscriptionPlace(Inscription $inscription, InscriptionPlace $inscriptionPlace): bool { if($inscriptionPlace === null) return false ; $places = $inscription->getPlaces(); if($places->removeElement($inscriptionPlace)) { $inscription->setNombrePlacesDemandees($inscription->getNombrePlacesDemandees() - 1); $this->update($inscription); return true; } return false ; } /** * Get entities as options for a select input * Loading module/Evenementiel/src/View/Helper/InscriptionPlaces.php +16 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ class InscriptionPlaces extends AbstractHelper ) ); $canSupprimerInscription = $isAllowedHelper( EvenementielinscriptionPrivileges::getResourceId( EvenementielinscriptionPrivileges::SUPPRIMER ) ); /** @var Inscription $inscription */ $emptyText = $options['empty_text'] ?? 'Les places ne sont pas renseignées'; Loading Loading @@ -101,6 +107,16 @@ class InscriptionPlaces extends AbstractHelper . '"><span class="icon icon-unchecked" title="Dépointer"> Dépointer</span></a>'; } } if ($canPointerInscription and !$place->isPointee()) { $html .= '<a class="btn btn-danger ajax-modal" href="' . $this->getView()->url('evenementiel/inscription/supprimer-place', [ 'entity' => $inscription->getId(), 'place' => $place->getId() ], true) . '" data-event="modification"> <span class="icon icon-delete" title="Supprimer"></span></a>'; } $html .= "</li>\n"; } $html .= "</ul>\n"; Loading Loading
module/Evenementiel/config/merged/Inscription.config.php +11 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ return [ [ 'controller' => InscriptionController::class, 'action' => [ 'supprimer', 'supprimer', "supprimer-place" ], 'privileges' => [ EvenementielinscriptionPrivileges::SUPPRIMER, Loading Loading @@ -264,6 +264,16 @@ return [ ], ], ], 'supprimer-place' => [ 'type' => Segment::class, 'options' => [ 'route' => '/supprimer-place/:entity[/:place]', 'defaults' => [ /** @see InscriptionController::supprimerPlaceAction() */ 'action' => 'supprimer-place', ], ], ], 'pointer-msg' => [ 'type' => Segment::class, 'options' => [ Loading
module/Evenementiel/src/Controller/InscriptionController.php +27 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,33 @@ class InscriptionController extends AbstractActionController return $this->redirect()->toRoute("evenementiel/inscription", [], [], true); } public function supprimerPlaceAction(): ViewModel { $inscription = $this->getInscriptionService()->getRequestedEntity($this); $inscriptionPlace = $this->getInscriptionService()->getRequestedInscriptionPlace($this, $inscription); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if ($data["reponse"] === "oui") { if ($this->getInscriptionService()->deleteInscriptionPlace($inscription, $inscriptionPlace)) { $this->flashMessenger()->addSuccessMessage("La place a été supprimé."); } else { $this->flashMessenger()->addWarningMessage("La place n'a pas été supprimé."); } } exit(); } $vm = new ViewModel(); $vm->setTemplate("default/confirmation"); $vm->setVariables([ "title" => "Supprimer une place", "text" => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?", "action" => $this->url()->fromRoute("evenementiel/inscription/supprimer-place", ['entity' => $inscription->getId(), 'place' => $inscriptionPlace->getId()]), ]); return $vm; } /** * Supprimer une entité * Loading
module/Evenementiel/src/Service/Inscription/InscriptionService.php +16 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,22 @@ class InscriptionService return $place; } public function deleteInscriptionPlace(Inscription $inscription, InscriptionPlace $inscriptionPlace): bool { if($inscriptionPlace === null) return false ; $places = $inscription->getPlaces(); if($places->removeElement($inscriptionPlace)) { $inscription->setNombrePlacesDemandees($inscription->getNombrePlacesDemandees() - 1); $this->update($inscription); return true; } return false ; } /** * Get entities as options for a select input * Loading
module/Evenementiel/src/View/Helper/InscriptionPlaces.php +16 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ class InscriptionPlaces extends AbstractHelper ) ); $canSupprimerInscription = $isAllowedHelper( EvenementielinscriptionPrivileges::getResourceId( EvenementielinscriptionPrivileges::SUPPRIMER ) ); /** @var Inscription $inscription */ $emptyText = $options['empty_text'] ?? 'Les places ne sont pas renseignées'; Loading Loading @@ -101,6 +107,16 @@ class InscriptionPlaces extends AbstractHelper . '"><span class="icon icon-unchecked" title="Dépointer"> Dépointer</span></a>'; } } if ($canPointerInscription and !$place->isPointee()) { $html .= '<a class="btn btn-danger ajax-modal" href="' . $this->getView()->url('evenementiel/inscription/supprimer-place', [ 'entity' => $inscription->getId(), 'place' => $place->getId() ], true) . '" data-event="modification"> <span class="icon icon-delete" title="Supprimer"></span></a>'; } $html .= "</li>\n"; } $html .= "</ul>\n"; Loading