Commit 4667d596 authored by Alexandre Zvenigorosky's avatar Alexandre Zvenigorosky
Browse files

Merge branches 'Centres-cout' and 'master' of git.unicaen.fr:open-source/OSE into Centres-cout

# Conflicts:
#	composer.json
#	composer.lock
parent aa116d0a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -98,12 +98,12 @@ return [
                [
                    'controller' => 'Application\Controller\CentreCout',
                    'action'     => ['index'],
                    'privileges' => Privileges::DROIT_PRIVILEGE_EDITION,
                    'privileges' => Privileges::CENTRES_COUTS_ADMINISTRATION_VISUALISATION,
                ],
                [
                    'controller' => 'Application\Controller\CentreCout',
                    'action'     => ['saisie', 'delete','saisie-structure','delete-structure'],
                    'privileges' => Privileges::ODF_CENTRES_COUT_EDITION,
                    'privileges' => Privileges::CENTRES_COUTS_ADMINISTRATION_EDITION,
                ],
            ],
        ],
+0 −130
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;

return [
    'router'          => [
        'routes' => [
            'groupe-type-formation' => [
                'type'          => 'Literal',
                'options'       => [
                    'route'    => '/groupe-type-formation',
                    'defaults' => [
                        'controller' => 'Application\Controller\GroupeTypeFormation',
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes'  => [
                    'delete'                => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/delete/:groupe-type-formation',
                            'constraints' => [
                                'groupe-type-formation' => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'delete',
                            ],
                        ],
                    ],
                    'saisie'                => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/saisie/[:groupe-type-formation]',
                            'constraints' => [
                                'groupe-type-formation' => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'saisie',
                            ],
                        ],
                    ],
                    'type-formation-delete' => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/type-formation-delete/:type-formation',
                            'constraints' => [
                                'type-formation' => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'type-formation-delete',
                            ],
                        ],
                    ],
                    'type-formation-saisie' => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/type-formation-saisie/:groupe-type-formation[/:type-formation]',
                            'constraints' => [
                                'groupe-type-formation' => '[0-9]*',
                                'type-formation'        => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'type-formation-saisie',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
    'navigation'      => [
        'default' => [
            'home' => [
                'pages' => [
                    'administration' => [
                        'pages' => [
                            'groupe-type-formation' => [
                                'label'        => 'Diplômes',
                                'icon'         => 'fa fa-graduation-cap',
                                'route'        => 'groupe-type-formation',
                                'resource'     => PrivilegeController::getResourceId('Application\Controller\GroupeTypeFormation', 'index'),
                                'order'        => 80,
                                'border-color' => '#BBCF55',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
    'bjyauthorize'    => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => 'Application\Controller\GroupeTypeFormation',
                    'action'     => ['index'],
                    'privileges' => Privileges::DROIT_PRIVILEGE_EDITION,
                ],
                [
                    'controller' => 'Application\Controller\GroupeTypeFormation',
                    'action'     => ['saisie', 'delete', 'type-formation-saisie', 'type-formation-delete'],
                    'privileges' => Privileges::DROIT_PRIVILEGE_VISUALISATION,
                ],
            ],
        ],
    ],
    'controllers'     => [
        'invokables' => [
            'Application\Controller\GroupeTypeFormation' => Controller\GroupeTypeFormationController::class,
        ],
    ],
    'service_manager' => [
        'invokables' => [
            Service\GroupeTypeFormationService::class => Service\GroupeTypeFormationService::class,
            Service\GroupeTypeFormationService::class => Service\TypeFormationService::class,
        ],
    ],
    'view_helpers'    => [
    ],
    'form_elements'   => [
        'invokables' => [
            Form\GroupeTypeFormation\TypeFormationSaisieForm::class     => Form\GroupeTypeFormation\TypeFormationSaisieForm::class,
            Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm::class => Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm::class,
        ],
    ],
];
+0 −132
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Entity\Db\GroupeTypeFormation;
use Application\Service\Traits\GroupeTypeFormationServiceAwareTrait;
use Application\Entity\Db\TypeFormation;
use Application\Service\Traits\TypeFormationServiceAwareTrait;
use Application\Exception\DbException;
use Application\Form\GroupeTypeFormation\Traits\GroupeTypeFormationSaisieFormAwareTrait;
use Application\Form\GroupeTypeFormation\Traits\TypeFormationSaisieFormAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;

class GroupeTypeFormationController extends AbstractController
{
    use GroupeTypeFormationServiceAwareTrait;
    use TypeFormationServiceAwareTrait;
    use GroupeTypeFormationSaisieFormAwareTrait;
    use TypeFormationSaisieFormAwareTrait;


    public function indexAction()
    {
        $this->em()->getFilters()->enable('historique')->init([
            GroupeTypeFormation::class,
        ]);

        $this->em()->getFilters()->enable('historique')->init([
            TypeFormation::class,
        ]);

        $groupeTypeFormations = $this->getServiceGroupeTypeFormation()->getList();
        $typeFormations       = $this->getServiceTypeFormation()->getList();

        return compact('groupeTypeFormations', 'typeFormations');
    }



    public function saisieAction()
    {
        /* @var $groupeTypeFormation GroupeTypeFormation */

        $groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');

        $form = $this->getFormGroupeTypeFormationSaisie();
        if (empty($groupeTypeFormation)) {
            $title               = 'Création d\'une nouvelle GroupeTypeFormation';
            $groupeTypeFormation = $this->getServiceGroupeTypeFormation()->newEntity();
        } else {
            $title = 'Édition d\'une GroupeTypeFormation';
        }

        $form->bindRequestSave($groupeTypeFormation, $this->getRequest(), function (GroupeTypeFormation $fr) {
            try {
                $this->getServiceGroupeTypeFormation()->save($fr);
                $this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
            } catch (\Exception $e) {
                $e = DbException::translate($e);
                $this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $fr->getId());
            }
        });

        return compact('form', 'title');
    }



    public function deleteAction()
    {
        $groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');

        try {
            $this->getServiceGroupeTypeFormation()->delete($groupeTypeFormation);
            $this->flashMessenger()->addSuccessMessage("GroupeTypeFormation supprimée avec succès.");
        } catch (\Exception $e) {
            $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
        }

        return new MessengerViewModel(compact('groupeTypeFormation'));
    }



    public function typeFormationSaisieAction()
    {
        /* @var $groupeTypeFormation GroupeTypeFormation */
        /* @var $typeFormation TypeFormation */

        $groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');
        $typeFormation       = $this->getEvent()->getParam('type-formation');

        $form = $this->getFormTypeFormationSaisie();
        if (empty($typeFormation)) {
            $title         = 'Création d\'un nouveau type de formation';
            $typeFormation = $this->getServiceTypeFormation()->newEntity()
                ->setGroupe($groupeTypeFormation);
            $typeFormation->setServiceStatutaire(true);
        } else {
            $title = 'Édition d\'un Type de Formation';
        }

        $form->bindRequestSave($typeFormation, $this->getRequest(), function (TypeFormation $tf) {
            try {
                $this->getServiceTypeFormation()->save($tf);
                $this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
            } catch (\Exception $e) {
                $e = DbException::translate($e);
                $this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $tf->getId());
            }
        });

        return compact('form', 'title');
    }



    public function typeFormationDeleteAction()
    {
        /* @var $typeFormation TypeFormation */
        $typeFormation = $this->getEvent()->getParam('type-formation');

        try {
            $this->getServiceTypeFormation()->delete($typeFormation);
            $this->flashMessenger()->addSuccessMessage("Type de Formation supprimée avec succès.");
        } catch (\Exception $e) {
            $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
        }

        return new MessengerViewModel(compact('type de formation'));
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ class CentreCoutStructureHydrator implements HydratorInterface
            $object->setStructure($this->getServiceStructure()->get($data['structure']));
        }
        $object->setSourceCode($data['code']);
        $object->setCentreCout($this->getServiceCentreCout()->getById($data['centre-cout']));
        $object->setCentreCout($this->getServiceCentreCout()->get($data['centre-cout']));
        $object->setSource($this->getServiceSource()->getOse());
        $object->setUniteBudgetaire($data['unite-budgetaire']);

+0 −48
Original line number Diff line number Diff line
<?php

namespace Application\Form\GroupeTypeFormation\Traits;

use Application\Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm;

/**
 * Description of GroupeTypeFormationSaisieFormAwareTrait
 *
 * @author UnicaenCode
 */
trait GroupeTypeFormationSaisieFormAwareTrait
{
    /**
     * @var GroupeTypeFormationSaisieForm
     */
    private $formGroupeTypeFormationSaisie;



    /**
     * @param GroupeTypeFormationSaisieForm $formGroupeTypeFormationSaisie
     *
     * @return self
     */
    public function setFormGroupeTypeFormationSaisie(GroupeTypeFormationSaisieForm $formGroupeTypeFormationSaisie)
    {
        $this->formGroupeTypeFormationSaisie = $formGroupeTypeFormationSaisie;

        return $this;
    }



    /**
     * Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
     *
     * @return GroupeTypeFormationSaisieForm
     */
    public function getFormGroupeTypeFormationSaisie()
    {
        if (!empty($this->formGroupeTypeFormationSaisie)) {
            return $this->formGroupeTypeFormationSaisie;
        }

        return \Application::$container->get('FormElementManager')->get(GroupeTypeFormationSaisieForm::class);
    }
}
Loading