Commit 9c8d98f1 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Premier filtre

parent eb9af45d
Loading
Loading
Loading
Loading
+18 −19
Changes for module/Formation/config/others/presence.config.php: 18 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Formation;

use Formation\Controller\FormationInstancePresenceController;
use Formation\Controller\PresenceController;
use Formation\Controller\PresenceControllerFactory;
use Formation\Provider\Privilege\SeancePrivileges;
@@ -48,24 +47,24 @@ return [
        ],
    ],

    'navigation' => [
        'default' => [
            'home' => [
                'pages' => [
                    'formation' => [
                        'pages' => [
                            'presence' => [
                                'label'    => 'Presences',
                                'route'    => 'formation/presence',
                                'resource' => PrivilegeController::getResourceId(PresenceController::class, 'index') ,
                                'order'    => 500,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
//    'navigation' => [
//        'default' => [
//            'home' => [
//                'pages' => [
//                    'formation' => [
//                        'pages' => [
//                            'presence' => [
//                                'label'    => 'Presences',
//                                'route'    => 'formation/presence',
//                                'resource' => PrivilegeController::getResourceId(PresenceController::class, 'index') ,
//                                'order'    => 500,
//                            ],
//                        ],
//                    ],
//                ],
//            ],
//        ],
//    ],

    'router'          => [
        'routes' => [
+18 −18
Changes for module/Formation/config/others/seance.config.php: 18 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -79,24 +79,24 @@ return [
        ],
    ],

    'navigation' => [
        'default' => [
            'home' => [
                'pages' => [
                    'formation' => [
                        'pages' => [
                            'seance' => [
                                'label'    => 'Seances',
                                'route'    => 'formation/seance',
                                'resource' => PrivilegeController::getResourceId(SeanceController::class, 'index') ,
                                'order'    => 300,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
//    'navigation' => [
//        'default' => [
//            'home' => [
//                'pages' => [
//                    'formation' => [
//                        'pages' => [
//                            'seance' => [
//                                'label'    => 'Seances',
//                                'route'    => 'formation/seance',
//                                'resource' => PrivilegeController::getResourceId(SeanceController::class, 'index') ,
//                                'order'    => 300,
//                            ],
//                        ],
//                    ],
//                ],
//            ],
//        ],
//    ],

    'router'          => [
        'routes' => [
+6 −3
Changes for module/Formation/src/Formation/Controller/IndexController.php: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Entity\Db\Doctorant;
use Application\Service\Doctorant\DoctorantServiceAwareTrait;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Session;
use UnicaenApp\Service\EntityManagerAwareTrait;
@@ -33,16 +32,20 @@ class IndexController extends AbstractController
        if($doctorant) {
            /** @var Session[] $session */
            $sessions = $this->getEntityManager()->getRepository(Session::class)->findSessionsDisponiblesByDoctorant($doctorant);
            $ouvertes = array_filter($sessions, function(Session $a) { return $a->getEtat()->getCode() === Session::ETAT_INSCRIPTION;});
            $preparations = array_filter($sessions, function(Session $a) { return $a->getEtat()->getCode() === Session::ETAT_PREPARATION;});
            /** @var Inscription[] $inscription */
            $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->findInscriptionsByDoctorant($doctorant);
        } else {
            $sessions = [];
            $ouvertes = [];
            $preparations = [];
            $inscriptions = [];
        }

        return new ViewModel([
            'doctorant' => $doctorant,
            'sessions' => $sessions,
            'ouvertes' => $ouvertes,
            'preparations' => $preparations,
            'inscriptions' => $inscriptions,
        ]);
    }
+32 −2
Changes for module/Formation/src/Formation/Controller/ModuleController.php: 32 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Formation\Entity\Db\Module;
use Formation\Form\Module\ModuleFormAwareTrait;
use Formation\Service\Module\ModuleServiceAwareTrait;
@@ -15,13 +16,42 @@ class ModuleController extends AbstractController
    use ModuleServiceAwareTrait;
    use ModuleFormAwareTrait;

    public function indexAction()
    use EtablissementServiceAwareTrait;

    public function indexAction() : ViewModel
    {
        /** @var Module[] $formations */
        /** Recupération des paramètres du filtres */
        $site = $this->params()->fromQuery('site');
        $libelle = $this->params()->fromQuery('libelle');
        $responsable = $this->params()->fromQuery('responsable');
        $modalite = $this->params()->fromQuery('modalite');
        $structure = $this->params()->fromQuery('structure');

        /** Listing pour les filtres */
        $sites = $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions();
        $responsables = $this->getEntityManager()->getRepository(Module::class)->fetchListeResponsable();
        $structures = $this->getEntityManager()->getRepository(Module::class)->fetchListeStructures();

        /** @var Module[] $formations */ //todo appliquer les filtre dans le repository
        $modules = $this->getEntityManager()->getRepository(Module::class)->findAll();
        if ($site !== null AND $site !== '') $modules = array_filter($modules, function(Module $a) use ($site) { return $a->getSite()->getCode() === $site;});
        if ($libelle !== null AND $libelle !== '') $modules = array_filter($modules, function(Module $a) use ($libelle) { return str_contains(strtolower($a->getLibelle()), strtolower($libelle));});
        if ($responsable !== null AND $responsable !== '') $modules = array_filter($modules, function(Module $a) use ($responsable) { return $a->getResponsable()->getId() == $responsable;});
        if ($structure !== null AND $structure !== '') $modules = array_filter($modules, function(Module $a) use ($structure) { return ($a->getTypeStructure() === null OR $a->getTypeStructure()->getId() == $structure);});
        if ($modalite !== null AND $modalite !== '') $modules = array_filter($modules, function(Module $a) use ($modalite) { return ($a->getModalite() === null OR $a->getModalite() === $modalite);});

        return new ViewModel([
            'modules' => $modules,
            //valeurs sélectionnées
            'site' => $site,
            'libelle' => $libelle,
            'responsable' => $responsable,
            'modalite' => $modalite,
            'structure' => $structure,
            //données pour le filtre
            'sites' => $sites,
            'responsables' => $responsables,
            'structures' => $structures,
        ]);
    }

+4
Changes for module/Formation/src/Formation/Controller/ModuleControllerFactory.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Formation\Controller;

use Application\Service\Etablissement\EtablissementService;
use Doctrine\ORM\EntityManager;
use Formation\Form\Module\ModuleForm;
use Formation\Service\Module\ModuleService;
@@ -17,9 +18,11 @@ class ModuleControllerFactory {
    {
        /**
         * @var EntityManager $entityManager
         * @var EtablissementService $etablissementService
         * @var ModuleService $moduleService
         */
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $etablissementService = $container->get(EtablissementService::class);
        $moduleService = $container->get(ModuleService::class);

        /**
@@ -29,6 +32,7 @@ class ModuleControllerFactory {

        $controller = new ModuleController();
        $controller->setEntityManager($entityManager);
        $controller->setEtablissementService($etablissementService);
        $controller->setModuleService($moduleService);
        $controller->setModuleForm($moduleForm);
        return $controller;
Loading