Commit 9935a801 authored by Johnny Leveneur's avatar Johnny Leveneur
Browse files

gestion des listes : principale et d'attente

parent 4d5db891
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -216,6 +216,9 @@ update evenementiel_inscription
set nombre_places_demandees = 1
where nombre_places_demandees is null;

alter table evenementiel_inscription
    add column liste varchar(64) ;

create unique index evenementiel_inscription_id_uindex
    on evenementiel_inscription (id);

+42 −1
Original line number Diff line number Diff line
@@ -80,7 +80,8 @@ return [
                [
                    'controller' => InscriptionController::class,
                    'action' => [
                        'modifier', 'pointer', 'depointer', 'pointer-msg'
                        'modifier', 'pointer', 'depointer', 'pointer-msg', 'classer'
                        ,'envoyer-liste-principale','envoyer-liste-attente'
                    ],
                    'privileges' => [
                        EvenementielinscriptionPrivileges::MODIFIER,
@@ -136,6 +137,7 @@ return [
                'options' => [
                    'route' => 'evenementiel',
                    'defaults' => [
                        /** @see InscriptionController::indexAction() */
                        'controller' => InscriptionController::class,
                        'action' => 'index',
                    ],
@@ -147,6 +149,7 @@ return [
                        'options' => [
                            'route' => '/inscription',
                            'defaults' => [
                                /** @see InscriptionController::indexAction() */
                                'controller' => InscriptionController::class,
                                'action' => 'index',
                            ],
@@ -158,6 +161,7 @@ return [
                                'options' => [
                                    'route' => '/afficher/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::afficherAction() */
                                        'action' => 'afficher',
                                    ],
                                ],
@@ -177,6 +181,7 @@ return [
                                'options' => [
                                    'route' => '/modifier/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::modifierAction() */
                                        'action' => 'modifier',
                                    ],
                                ],
@@ -186,6 +191,7 @@ return [
                                'options' => [
                                    'route' => '/historiser/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::historiserAction() */
                                        'action' => 'historiser',
                                    ],
                                ],
@@ -195,15 +201,47 @@ return [
                                'options' => [
                                    'route' => '/restaurer/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::restaurerAction() */
                                        'action' => 'restaurer',
                                    ],
                                ],
                            ],
                            'classer' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/classer/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::classerAction() */
                                        'action' => 'classer',
                                    ],
                                ],
                            ],
                            'envoyer-liste-principale' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/envoyer-liste-principale/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::envoyerListePrincipaleAction() */
                                        'action' => 'envoyer-liste-principale',
                                    ],
                                ],
                            ],
                            'envoyer-liste-attente' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/envoyer-liste-attente/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::envoyerListePrincipaleAction() */
                                        'action' => 'envoyer-liste-attente',
                                    ],
                                ],
                            ],
                           'pointer' => [
                                'type' => Segment::class,
                                'options' => [
                                    'route' => '/pointer/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::pointerAction() */
                                        'action' => 'pointer',
                                    ],
                                ],
@@ -213,6 +251,7 @@ return [
                                'options' => [
                                    'route' => '/depointer/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::depointerAction() */
                                        'action' => 'depointer',
                                    ],
                                ],
@@ -222,6 +261,7 @@ return [
                                'options' => [
                                    'route' => '/pointer-msg/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::pointerMsgAction() */
                                        'action' => 'pointer-msg',
                                    ],
                                ],
@@ -232,6 +272,7 @@ return [
                                'options' => [
                                    'route' => '/supprimer/:entity',
                                    'defaults' => [
                                        /** @see InscriptionController::supprimerAction() */
                                        'action' => 'supprimer',
                                    ],
                                ],
+7 −7
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ class EvenementController extends AbstractActionController
            $form->setData($data);
            if ($form->isValid()) {
                if ($inscription->getParticipant() !== null and $inscription->getEvenement() !== null) {
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_VALIDEE);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_VALIDER);
                    $this->getInscriptionService()->create($inscription);
                }
            }
@@ -415,7 +415,7 @@ class EvenementController extends AbstractActionController
                    if ($existingInscription === null) {
                        $inscription->setParticipant($participant);
                        $this->getInscriptionService()->create($inscription);
                        $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_VALIDEE);
                        $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_VALIDER);
                    } else {
                        $this->flashMessenger()->addErrorMessage("L'étudiant·e <strong>" . $participant->getDenomination() . "</strong> est déjà inscrit·e.");
                    }
@@ -470,7 +470,7 @@ class EvenementController extends AbstractActionController
                    if ($existingInscription === null) {
                        $inscription->setParticipant($participant);
                        $this->getInscriptionService()->create($inscription);
                        $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_VALIDEE);
                        $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_VALIDER);
                    } else {
                        $this->flashMessenger()->addErrorMessage("Le personnel<strong>" . $participant->getDenomination() . "</strong> est déjà inscrit·e.");
                    }
@@ -526,9 +526,9 @@ class EvenementController extends AbstractActionController
                        $inscription->setParticipant($participant);
                    }
                    $this->getInscriptionService()->create($inscription);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_DEMANDEE);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_DEMANDE);
                    $this->getNotificationService()->triggerInscription($inscription);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_VALIDEE);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_VALIDER);
                    $this->getNotificationService()->triggerValidation($inscription);
                    $this->flashMessenger()->addSuccessMessage("Inscription faite.");
                }
@@ -616,9 +616,9 @@ class EvenementController extends AbstractActionController
                        $inscription->setParticipant($participant);
                    }
                    $this->getInscriptionService()->create($inscription);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_DEMANDEE);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_DEMANDE);
                    $this->getNotificationService()->triggerInscription($inscription);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::ETAT_INSCRIPTION_VALIDEE);
                    $this->getEtatInstanceService()->setEtatActif($inscription, InscriptionEtats::INSCRIPTION_VALIDER);
                    $this->getNotificationService()->triggerValidation($inscription);
                    $this->flashMessenger()->addSuccessMessage("Inscription faite.");
                }
+89 −24
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Evenementiel\Entity\Db\Inscription;
use Evenementiel\Provider\Etat\EvenementEtats;
use Evenementiel\Provider\Etat\InscriptionEtats;
use Evenementiel\Service\Evenement\EvenementServiceAwareTrait;
use Evenementiel\Service\Notification\NotificationServiceAwareTrait;
use Evenementiel\Service\Participant\ParticipantServiceAwareTrait;
use Laminas\Http\Request;
use Laminas\Mvc\Controller\AbstractActionController;
@@ -29,6 +30,7 @@ class InscriptionController extends AbstractActionController
    use EtudiantServiceAwareTrait;
    use UserServiceAwareTrait;
    use EvenementServiceAwareTrait;
    use NotificationServiceAwareTrait;

    /**
     * Afficher la liste des entités
@@ -222,41 +224,71 @@ class InscriptionController extends AbstractActionController
        return $vm;
    }


    /** GESTION PAR LES PARTICIPANT·ES ***********************************************************************************/
    public function autoInscriptionAction(): ViewModel
    /** Gestion des listes ********************************************************************************************/
    public function envoyerListePrincipaleAction(): Response
    {
        $participant = $this->getParticipantService()->getParticipantUsager();
        $evenements = $this->getEvenementService()->getEvenementsByEtat(EvenementEtats::ETAT_INSCRIPTION_OUVERTE);
        $inscription = $this->getInscriptionService()->getRequestedEntity($this);
        $evenement = $inscription->getEvenement();
        if($inscription->getNombrePlacesDemandees() <= $evenement->getPlaceDisponible() ) {
            $inscription->setListe(Inscription::PRINCIPALE);
            $this->getInscriptionService()->update($inscription);
            $this->getNotificationService()->triggerValidation($inscription);
            $this->flashMessenger()->addSuccessMessage("<strong>" . $inscription->getParticipantDenomination() . "</strong> vient d'être ajouté&middot;e en liste principale.");
        }
        else
        {
            $this->flashMessenger()->addSuccessMessage("<strong>" . $inscription->getParticipantDenomination() . "</strong> ne peut être ajouté&middot;e en liste principale car il n'y a pas assez de places disponibles");
        }

        return new ViewModel([
            'participant' => $participant,
            'evenements' => $evenements,
        ]);
        $retour = $this->params()->fromRoute('retour');
        if ($retour) $this->redirect()->toUrl($retour);
        $evenement = $inscription->getEvenement();
        return $this->redirect()->toRoute('evenementiel/evenement/afficher', ['entity' => $evenement->getId()], [], true);
    }

    public function inscriptionEnCoursAction(): ViewModel
    public function envoyerListeAttenteAction(): Response
    {
        $participant = $this->getParticipantService()->getParticipantUsager();
        $allInscriptions = $this->getInscriptionService()->getInscriptionsByParticipant($participant);
        $inscription = $this->getInscriptionService()->getRequestedEntity($this);

        //filtrer les évènements par etats
        $inscriptions = [];
        foreach ($allInscriptions as $inscription) {
            /** @var Inscription $inscription */
        $inscription->setListe(Inscription::ATTENTE);
        $this->getInscriptionService()->update($inscription);

//      $this->getNotificationService()->triggerInscription($inscription);

        $this->flashMessenger()->addSuccessMessage("<strong>" . $inscription->getParticipantDenomination() . "</strong> vient d'être ajouté&middot;e en liste d'attente.");

        $retour = $this->params()->fromRoute('retour');
        if ($retour) $this->redirect()->toUrl($retour);
        $evenement = $inscription->getEvenement();
            if (in_array($evenement->getEtatActif()->getType()->getCode(), [EvenementEtats::ETAT_INSCRIPTION_OUVERTE, EvenementEtats::ETAT_INSCRIPTION_FERMEE])) {
                $inscriptions[] = $inscription;
            }
        return $this->redirect()->toRoute('evenementiel/evenement/afficher', ['entity' => $evenement->getId()], [], true);
    }

        return new ViewModel([
            'participant' => $participant,
            'inscriptions' => $inscriptions,
        ]);
    public function classerAction(): Response
    {
        $inscription = $this->getInscriptionService()->getRequestedEntity($this);

        $this->getEvenementService()->classerInscription($inscription);

        switch ($inscription->getListe()) {
            case Inscription::PRINCIPALE :
                $this->getNotificationService()->triggerValidation($inscription);
                $this->flashMessenger()->addSuccessMessage("Classement de l'inscription en liste principale.");
                break;
            case Inscription::ATTENTE :
                $this->flashMessenger()->addWarningMessage("Liste principale complète. <br/> Classement de l'inscription en liste d'attente.");
                break;
            default :
                $this->flashMessenger()->addErrorMessage("Échec du classement de l'inscription.");
                break;
        }

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);

        $evenement = $inscription->getEvenement();
        /** @see EvenementController::afficherAction() */
        return $this->redirect()->toRoute('evenementiel/evenement/afficher', ['entity' => $evenement->getId()], ['fragment' => 'inscriptions'], true);
    }
    public function desinscriptionAction(): ViewModel
    {
        $inscription = $this->getInscriptionService()->getRequestedEntity($this);
@@ -280,6 +312,39 @@ class InscriptionController extends AbstractActionController
        return $vm;
    }

    /** GESTION PAR LES PARTICIPANT·ES ***********************************************************************************/
    public function autoInscriptionAction(): ViewModel
    {
        $participant = $this->getParticipantService()->getParticipantUsager();
        $evenements = $this->getEvenementService()->getEvenementsByEtat(EvenementEtats::ETAT_INSCRIPTION_OUVERTE);

        return new ViewModel([
            'participant' => $participant,
            'evenements' => $evenements,
        ]);
    }

    public function inscriptionEnCoursAction(): ViewModel
    {
        $participant = $this->getParticipantService()->getParticipantUsager();
        $allInscriptions = $this->getInscriptionService()->getInscriptionsByParticipant($participant);

        //filtrer les évènements par etats
        $inscriptions = [];
        foreach ($allInscriptions as $inscription) {
            /** @var Inscription $inscription */
            $evenement = $inscription->getEvenement();
            if (in_array($evenement->getEtatActif()->getType()->getCode(), [EvenementEtats::ETAT_INSCRIPTION_OUVERTE, EvenementEtats::ETAT_INSCRIPTION_FERMEE])) {
                $inscriptions[] = $inscription;
            }
        }

        return new ViewModel([
            'participant' => $participant,
            'inscriptions' => $inscriptions,
        ]);
    }

    /** VALIDATION DES INSCRIPTIONS ********************************************************************************* */
//    public function validerAction(): ViewModel
//    {
+4 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Etudiant\Service\Etudiant\EtudiantService;
use Evenementiel\Form\Inscription\InscriptionParticipantForm;
use Evenementiel\Service\Evenement\EvenementService;
use Evenementiel\Service\Inscription\InscriptionService;
use Evenementiel\Service\Notification\NotificationService;
use Evenementiel\Service\Participant\ParticipantService;
use Psr\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
@@ -33,6 +34,7 @@ class InscriptionControllerFactory
         * @var ParticipantService $participantService
         * @var EtudiantService $etudiantService
         * @var UserService $userService
         * @var NotificationService $notificationService
         */
        $inscriptionService = $container->get(InscriptionService::class);
        $inscriptionForm = $container->get("FormElementManager")->get(InscriptionParticipantForm::class);
@@ -42,6 +44,7 @@ class InscriptionControllerFactory
        $etudiantService = $container->get(EtudiantService::class);
        $userService = $container->get(UserService::class);
        $evenementService = $container->get(EvenementService::class);
        $notificationService = $container->get(NotificationService::class);

        $controller = new InscriptionController();
        $controller->setInscriptionService($inscriptionService);
@@ -52,6 +55,7 @@ class InscriptionControllerFactory
        $controller->setEtudiantService($etudiantService);
        $controller->setUserService($userService);
        $controller->setEvenementService($evenementService);
        $controller->setNotificationService($notificationService);

        return $controller;
    }
Loading