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

Debut de plan de formation

parent 54fc11b7
Loading
Loading
Loading
Loading
+22 −1
Changes for module/Formation/config/merged/administration.config.php: 22 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenRenderer\Controller\IndexController;
use UnicaenRenderer\Provider\Privilege\DocumenttemplatePrivileges;

return [
    'bjyauthorize' => [
@@ -25,6 +26,15 @@ return [
                        ParametrecategoriePrivileges::PARAMETRECATEGORIE_INDEX,
                    ],
                ],
                [
                    'controller' => AdministrationController::class,
                    'action' => [
                        'template',
                    ],
                    'privileges' => [
                        DocumenttemplatePrivileges::DOCUMENTTEMPLATE_INDEX,
                    ],
                ],
            ],
        ],
    ],
@@ -52,7 +62,7 @@ return [
                            'template' => [
                                'order' => 2000,
                                'label' => 'Templates et macros',
                                'route' => 'contenu/template',
                                'route' => 'formation/administration/template',
                                'resource' => PrivilegeController::getResourceId(IndexController::class, 'index'),
                                'icon' => 'fas fa-angle-right',
                            ],
@@ -88,6 +98,17 @@ return [
                                    ],
                                ],
                            ],
                            'template' => [
                                'type'  => Segment::class,
                                'options' => [
                                    /** @see AdministrationController::templateAction() */
                                    'route'    => '/template',
                                    'defaults' => [
                                        'controller' => AdministrationController::class,
                                        'action'     => 'template',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
+5 −1
Changes for module/Formation/config/merged/plan-formartion.config.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ use Formation\Controller\FormationInstanceController;
use Formation\Controller\PlanFormationController;
use Formation\Controller\PlanFormationControllerFactory;
use Formation\Provider\Privilege\PlanformationPrivileges;
use Formation\Service\PlanDeFormation\PlanDeFormationService;
use Formation\Service\PlanDeFormation\PlanDeFormationServiceFactory;
use Laminas\Router\Http\Segment;
use UnicaenPrivilege\Guard\PrivilegeController;

@@ -78,7 +80,9 @@ return [
    ],

    'service_manager' => [
        'factories' => [],
        'factories' => [
            PlanDeFormationService::class => PlanDeFormationServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
+13 −0
Changes for module/Formation/src/Formation/Controller/AdministrationController.php: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,11 +6,13 @@ use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
use UnicaenParametre\Service\Parametre\ParametreServiceAwareTrait;
use UnicaenRenderer\Service\Template\TemplateServiceAwareTrait;

class AdministrationController extends AbstractActionController
{
    use CategorieServiceAwareTrait;
    use ParametreServiceAwareTrait;
    use TemplateServiceAwareTrait;

    public function parametreAction() : ViewModel
    {
@@ -25,4 +27,15 @@ class AdministrationController extends AbstractActionController
        $vm->setTemplate('unicaen-parametre/categorie/index');
        return $vm;
    }

    public function templateAction() : ViewModel
    {
        $templates = $this->getTemplateService()->getTemplatesByNamespace('Formation\Provider\Template');

        $vm =  new ViewModel([
            'templates' => $templates,
        ]);
        $vm->setTemplate('unicaen-renderer/template/index');
        return $vm;
    }
}
 No newline at end of file
+4 −0
Changes for module/Formation/src/Formation/Controller/AdministrationControllerFactory.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenParametre\Service\Categorie\CategorieService;
use UnicaenParametre\Service\Parametre\ParametreService;
use UnicaenRenderer\Service\Template\TemplateService;

class AdministrationControllerFactory {

@@ -21,13 +22,16 @@ class AdministrationControllerFactory {
        /**
         * @var CategorieService $categorieService
         * @var ParametreService $parametreService
         * @var TemplateService $templateService
         */
        $categorieService = $container->get(CategorieService::class);
        $parametreService = $container->get(ParametreService::class);
        $templateService = $container->get(TemplateService::class);

        $controller = new AdministrationController();
        $controller->setCategorieService($categorieService);
        $controller->setParametreService($parametreService);
        $controller->setTemplateService($templateService);
        return $controller;
    }
}
 No newline at end of file
+22 −23
Changes for module/Formation/src/Formation/Controller/PlanFormationController.php: 22 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Formation\Service\Abonnement\AbonnementServiceAwareTrait;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\FormationGroupe\FormationGroupeServiceAwareTrait;
use Formation\Service\FormationInstance\FormationInstanceServiceAwareTrait;
use Formation\Service\PlanDeFormation\PlanDeFormationServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

@@ -17,42 +18,40 @@ class PlanFormationController extends AbstractActionController {
    use AgentServiceAwareTrait;
    use FormationGroupeServiceAwareTrait;
    use FormationServiceAwareTrait;
    use PlanDeFormationServiceAwareTrait;

    use FormationInstanceServiceAwareTrait;

    public function afficherAction() : ViewModel
    {
        $groupes = $this->getFormationGroupeService()->getFormationsGroupes('libelle');
        $groupes = array_filter($groupes, function (FormationGroupe $a) {
            $formationsListes = $a->getFormations();
            $formationsListes = array_filter($formationsListes, function (Formation $a) {
                return $a->getAffichage() and $a->estNonHistorise();
            });
            return !empty($formationsListes);
        });
        $formations = [];
        $sessions = [];
        foreach ($groupes as $groupe) {
            $formationsListes = $this->getFormationService()->getFormationsByGroupe($groupe);
            $formationsListes = array_filter($formationsListes, function (Formation $a) { return $a->getAffichage();});

            $formations[$groupe->getId()] = $formationsListes;
            foreach ($formations[$groupe->getId()] as $formation) {
                $sessions[$formation->getId()] = $this->getFormationInstanceService()->getFormationsInstancesByFormation($formation);
        $planDeFormation = $this->getPlanDeFormationService()->getPlanDeFormationByAnnee();


        $formations = $planDeFormation->getFormations();

        $groupes = [];
        $formationsArrayByGroupe = [];
        foreach ($formations as $formation) {
            $groupes[$formation->getGroupe()->getId()] = $formation->getGroupe();
            $formationsArrayByGroupe[$formation->getGroupe()->getId()][] = $formation;
        }

        $sessionsArrayByFormation = [];
        foreach ($formations as $formation) {
            //todo recupérer par lot
            $sessionsArrayByFormation[$formation->getId()] = $this->getFormationInstanceService()->getFormationsInstancesOuvertesByFormation($formation);
        }

        $abonnements = [];
        $agent = $this->getAgentService()->getAgentByConnectedUser();
        if ($agent !== null) $abonnements = $this->getAbonnementService()->getAbonnementsByAgent($agent);


        $annee = Formation::getAnnee();

        return new ViewModel([
            'groupes' => $groupes,
            'planDeFormation' => $planDeFormation,
            'formations' => $formations,
            'sessions' => $sessions,
            'annee' => $annee ."/" . ($annee+1),
            'groupes' => $groupes,
            'formationsArrayByGroupe' => $formationsArrayByGroupe,
            'sessionsArrayByFormation' => $sessionsArrayByFormation,
            'abonnements' => $abonnements,
        ]);
    }
Loading