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

WIP plan de formation

parent db891cc8
Loading
Loading
Loading
Loading
+10 −10
Changes for composer.json: 10 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -10,22 +10,22 @@
  "minimum-stability": "dev",
  "require": {
    "unicaen/app": "^5",
    "unicaen/authentification": "^5",
    "unicaen/utilisateur": "5.0.3",
    "unicaen/privilege": "^5",
    "unicaen/renderer": "^5",
    "unicaen/pdf": "^5",
    "unicaen/mail": "^5",
    "unicaen/parametre": "^5",
    "unicaen/authentification": "^5.0",
    "unicaen/utilisateur": "^5.0.5",
    "unicaen/privilege": "^5.0",
    "unicaen/renderer": "5.0.5",
    "unicaen/pdf": "5.0.1",
    "unicaen/mail": "5.0.3",
    "unicaen/parametre": "^5.0",
    "unicaen/bjy-authorize": "^4",
    "unicaen/ldap": "^4",
    "unicaen/octopus": "^4",
    "unicaen/evenement": "^5",
    "unicaen/autoform": "^5",
    "unicaen/evenement": "^5.0",
    "unicaen/autoform": "^5.0",
    "unicaen/aide": "dev-master",
    "ext-json": "*",
    "unicaen/db-import": "dev-utilisateur",
    "unicaen/indicateur": "^0.0.5"
    "unicaen/indicateur": "^0.0"
  },
  "require-dev": {
    "laminas/laminas-developer-tools": ">=1.0"

composer.lock.old

0 → 100644
+10048 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −1
Changes for config/application.config.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ $modules = [
    'UnicaenValidation',
    'UnicaenEvenement',
    'UnicaenAide',
    'UnicaenAlerte',
//    'UnicaenAlerte',
    'UnicaenIndicateur',

    'EntretienProfessionnel',
+57 −3
Changes for module/Formation/config/merged/plan-de-formation.config.php: 57 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,9 +4,14 @@ namespace Formation;

use Formation\Controller\PlanDeFormationController;
use Formation\Controller\PlanDeFormationControllerFactory;
use Formation\Form\PlanDeFormation\PlanDeFormationForm;
use Formation\Form\PlanDeFormation\PlanDeFormationFormFactory;
use Formation\Form\PlanDeFormation\PlanDeFormationHydrator;
use Formation\Form\PlanDeFormation\PlanDeFormationHydratorFactory;
use Formation\Provider\Privilege\PlanformationPrivileges;
use Formation\Service\PlanDeFormation\PlanDeFormationService;
use Formation\Service\PlanDeFormation\PlanDeFormationServiceFactory;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenPrivilege\Guard\PrivilegeController;

@@ -92,7 +97,7 @@ return [
                'may_terminate' => true,
                'child_routes' => [
                    'courant' => [
                        'type'  => Segment::class,
                        'type'  => Literal::class,
                        'options' => [
                            /** @see PlanDeFormationController::courantAction() */
                            'route'    => '/courant',
@@ -102,6 +107,51 @@ return [
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'  => Literal::class,
                        'options' => [
                            /** @see PlanDeFormationController::ajouterAction() */
                            'route'    => '/ajouter',
                            'defaults' => [
                                'controller' => PlanDeFormationController::class,
                                'action'     => 'ajouter',
                            ],
                        ],
                    ],
                    'afficher' => [
                        'type'  => Segment::class,
                        'options' => [
                            /** @see PlanDeFormationController::afficherAction() */
                            'route'    => '/afficher/:plan-de-formation',
                            'defaults' => [
                                'controller' => PlanDeFormationController::class,
                                'action'     => 'afficher',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type'  => Segment::class,
                        'options' => [
                            /** @see PlanDeFormationController::modifierAction() */
                            'route'    => '/modifier/:plan-de-formation',
                            'defaults' => [
                                'controller' => PlanDeFormationController::class,
                                'action'     => 'modifier',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type'  => Segment::class,
                        'options' => [
                            /** @see PlanDeFormationController::supprimer() */
                            'route'    => '/supprimer/:plan-de-formation',
                            'defaults' => [
                                'controller' => PlanDeFormationController::class,
                                'action'     => 'supprimer',
                            ],
                        ],
                    ],

                ],
            ],
        ],
@@ -118,10 +168,14 @@ return [
        ],
    ],
    'form_elements' => [
        'factories' => [],
        'factories' => [
            PlanDeFormationForm::class => PlanDeFormationFormFactory::class,
        ],
    ],
    'hydrators' => [
        'factories' => [],
        'factories' => [
            PlanDeFormationHydrator::class => PlanDeFormationHydratorFactory::class,
        ],
    ]

];
 No newline at end of file
+107 −1
Changes for module/Formation/src/Formation/Controller/PlanDeFormationController.php: 107 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ namespace Formation\Controller;
use Application\Service\Agent\AgentServiceAwareTrait;
use Formation\Entity\Db\Formation;
use Formation\Entity\Db\FormationGroupe;
use Formation\Entity\Db\PlanDeFormation;
use Formation\Form\PlanDeFormation\PlanDeFormationFormAwareTrait;
use Formation\Service\Abonnement\AbonnementServiceAwareTrait;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\FormationGroupe\FormationGroupeServiceAwareTrait;
@@ -19,9 +21,10 @@ class PlanDeFormationController extends AbstractActionController {
    use FormationGroupeServiceAwareTrait;
    use FormationServiceAwareTrait;
    use PlanDeFormationServiceAwareTrait;

    use FormationInstanceServiceAwareTrait;

    use PlanDeFormationFormAwareTrait;

    public function indexAction() : ViewModel
    {
        $plans = $this->getPlanDeFormationService()->getPlansDeFormation();
@@ -63,4 +66,107 @@ class PlanDeFormationController extends AbstractActionController {
            'abonnements' => $abonnements,
        ]);
    }

    public function afficherAction() : ViewModel
    {
        $plan = $this->getPlanDeFormationService()->getRequestedPlanDeFormation($this);

        $formations = $plan->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()->getFormationsInstancesByFormationAndPlan($formation, $plan);
        }

        return new ViewModel([
            'plan' => $plan,
            'formations' => $formations,
            'groupes' => $groupes,
            'formationsArrayByGroupe' => $formationsArrayByGroupe,
            'sessionsArrayByFormation' => $sessionsArrayByFormation,
        ]);
    }

    public function ajouterAction() : ViewModel
    {
        $plan = new PlanDeFormation();

        $form = $this->getPlanDeFormationForm();
        $form->setAttribute('action', $this->url()->fromRoute('plan-de-formation/ajouter', [], [], true));
        $form->bind($plan);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getPlanDeFormationService()->create($plan);
                exit();
            }
        }

        $vm = new ViewModel([
            'title' => "Ajouter un plan de formation",
            'form' => $form,
            ]);
        $vm->setTemplate('application/default/default-form');
        return $vm;
    }

    public function modifierAction() : ViewModel
    {
        $plan = $this->getPlanDeFormationService()->getRequestedPlanDeFormation($this);

        $form = $this->getPlanDeFormationForm();
        $form->setAttribute('action', $this->url()->fromRoute('plan-de-formation/modifier', ['plan-de-formation' => $plan->getId()], [], true));
        $form->bind($plan);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            $form->setData($data);
            if ($form->isValid()) {
                $this->getPlanDeFormationService()->update($plan);
                exit();
            }
        }

        $vm = new ViewModel([
            'title' => "Modifier le plan de formation",
            'form' => $form,
        ]);
        $vm->setTemplate('application/default/default-form');
        return $vm;
    }

    public function supprimerAction() : ViewModel
    {
        $plan = $this->getPlanDeFormationService()->getRequestedPlanDeFormation($this);

        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getPlanDeFormationService()->delete($plan);
            exit();
        }

        $vm = new ViewModel();
        if ($plan !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression du plan de formation " . $plan->getAnnee(),
                'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('plan-de-formation/supprimer', ["plan-de-formation" => $plan->getId()], [], true),
            ]);
        }
        return $vm;
    }
}
 No newline at end of file
Loading