Commit 18076c2c authored by joriot221's avatar joriot221
Browse files

probleme ID non remplit

parent 2cce508e
Loading
Loading
Loading
Loading
+2 −1
Changes for module/Application/config/administration.config.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ return [
                                'border - color' => '#111',
                            ],
                            'gestion-departement'     => [
                                'label'          => 'Gestion des Pays',
                                'label'          => 'Gestion des Départements',
                                'icon'           => 'fas fa-table-list',
                                'route'          => 'departement',
                                'resource'       => PrivilegeController::getResourceId('Application\Controller\Departement', 'index'),
@@ -271,6 +271,7 @@ return [
                                     'administration-periode',
                                     'administration-etablissement',
                                     'administration-pays',
                                     'administration-departement',
                                     'administration-type-formation',],
                    'privileges' => [
                        Privileges::IMPORT_ECARTS,
+x+73
Changes for module/Application/config/departement.config.php: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application;

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

return [
    'router'          => [
        'routes' => [
            'departement' => [
                'type'          => 'Literal',
                'options'       => [
                    'route'    => '/departement',
                    'defaults' => [
                        'controller' => 'Application\Controller\Departement',
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes'  => [
                    'saisie'    => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'    => '/saisie[/:departement]',
                            'defaults' => [
                                'action' => 'saisie',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                    'supprimer' => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'    => '/supprimer/:departement',
                            'defaults' => [
                                'action' => 'supprimer',
                            ],
                        ],
                        'may_terminate' => true,
                    ],
                ],
            ],
        ],
    ],
    'bjyauthorize'    => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => 'Application\Controller\Departement',
                    'action'     => ['index'],
                    'privileges' => [Privileges::PARAMETRES_DEPARTEMENT_VISUALISATION],
                ],
                [
                    'controller' => 'Application\Controller\Departement',
                    'action'     => ['saisie', 'supprimer'],
                    'privileges' => [Privileges::PARAMETRES_DEPARTEMENT_EDITION],
                ],
            ],
        ],

    ],
    'controllers'     => [
        'invokables' => [
            'Application\Controller\Departement' => Controller\DepartementController::class,
        ],
    ],
    'service_manager' => [
        'invokables' => [
            Service\DepartementService::class => Service\DepartementService::class,
        ],
    ],
];
+x+70
Changes for module/Application/src/Controller/DepartementController.php: 70 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Form\Departement\Traits\DepartementSaisieFormAwareTrait;
use Application\Service\Traits\DepartementServiceAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;

/**
 * Description of DepartementController
 *
 * @author Florian Joriot <florian.joriot at unicaen.fr>
 */
class DepartementController extends AbstractController
{
    use \Application\Service\Traits\ContextServiceAwareTrait;
    use \Application\Service\Traits\DepartementServiceAwareTrait;
    use DepartementSaisieFormAwareTrait;
    use DepartementServiceAwareTrait;


    public function indexAction()
    {
        $query        = $this->em()->createQuery('SELECT d FROM Application\Entity\Db\Departement d WHERE d.histoDestruction is null');
        $departements = $query->getResult();

        return compact('departements');
    }



    public function saisieAction()
    {
        $departement = $this->getEvent()->getParam('departement');
        $form        = $this->getFormDepartementSaisie();

        if (empty($departement)) {
            $title       = "Création d'un nouveau département";
            $departement = $this->getServiceDepartement()->newEntity();
        } else {
            $title = "Edition d'un département";
        }
        $form->bindRequestSave($departement, $this->getRequest(), function () use ($departement, $form) {
            try {
                if ($departement->getSourceCode() == null) {
                    $departement->setSourceCode($departement->getCode());
                }
                $this->getServiceDepartement()->save($departement);
                $this->flashMessenger()->addSuccessMessage(
                    "Ajout réussis"
                );
            } catch (Exception $e) {
                $this->flashMessenger()->addErrorMessage($this->translate($e));
            }
        });


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



    public function supprimerAction()
    {
        $departement = $this->getEvent()->getParam('departement');
        $this->getServiceDepartement()->delete($departement, true);

        return new MessengerViewModel();
    }
}
 No newline at end of file
+7 −19
Changes for module/Application/src/Entity/Db/Departement.php: 7 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -16,19 +16,19 @@ class Departement implements HistoriqueAwareInterface, ImportAwareInterface
    use ImportAwareTrait;

    /**
     * @var int|null
     * @var int
     */
    protected $id;
    protected ?int $id = null;

    /**
     * @var string|null
     */
    protected $code;
    protected ?string $code = null;

    /**
     * @var string|null
     */
    protected $libelle;
    protected ?string $libelle = null;



@@ -44,14 +44,10 @@ class Departement implements HistoriqueAwareInterface, ImportAwareInterface

    /**
     * @param int|null $id
     *
     * @return Departement
     */
    public function setId(?int $id): Departement
    public function setId(?int $id): void
    {
        $this->id = $id;

        return $this;
    }


@@ -68,14 +64,10 @@ class Departement implements HistoriqueAwareInterface, ImportAwareInterface

    /**
     * @param string|null $code
     *
     * @return Departement
     */
    public function setCode(?string $code): Departement
    public function setCode(?string $code): void
    {
        $this->code = $code;

        return $this;
    }


@@ -92,14 +84,10 @@ class Departement implements HistoriqueAwareInterface, ImportAwareInterface

    /**
     * @param string|null $libelle
     *
     * @return Departement
     */
    public function setLibelle(?string $libelle): Departement
    public function setLibelle(?string $libelle): void
    {
        $this->libelle = $libelle;

        return $this;
    }


+33
Changes for module/Application/src/Form/Departement/DepartementSaisieForm.php: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Form\Departement;

use Application\Entity\Db\Departement;
use Application\Form\AbstractForm;
use Application\Service\Traits\GroupeTypeFormationServiceAwareTrait;
use Application\Service\Traits\SourceServiceAwareTrait;
use UnicaenImport\Service\Traits\SchemaServiceAwareTrait;


/**
 * Description of DepartementForm
 *
 * @author Florian JORIOT <florian.joriot at unicaen.fr>
 */
class DepartementSaisieForm extends AbstractForm
{
    use SourceServiceAwareTrait;
    use GroupeTypeFormationServiceAwareTrait;
    use SchemaServiceAwareTrait;


    public function init()
    {
        $this->spec(Departement::class);
        $this->build();

        $this->addSubmit();

        return $this;
    }
}
 No newline at end of file
Loading