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

Déclaration de CorrespondanceType

parent 78af8c87
Loading
Loading
Loading
Loading
+101 −0
Original line number Diff line number Diff line
**CHANGES version 3.0.1**

-----------


**Changements**

* Ajout des types de correspondance
* 

**Modifications de la base de donnée**

Afin de modéliser les différents types de correspondances il est nécessaire de proposer dans la source de données des données ressamblant à la vue suivante (V_CORRESPONDANCE_TYPE).
Ces données seront importées et référencées dans les correspondances.

| column        | type          | contrainte |
|---------------|---------------|------------|
| ID            | bigint        | PK         |
| CODE          | varchar(64)   | not null   |
| LIBELLE_COURT | varchar(256)  | not null   |
| LIBELLE_LONG  | varchar(1024) | not null   |
| DESCRIPTION   | text          |            |
| D_OUVERTURE   | timestamp     |            |
| D_FERMETURE   | timestamp     |            |


Préparation des données sources
```sql
create or replace View V_PREECOG_CORRESPONDANCE_TYPE AS
    select
        1 AS ID,
        'BAP' AS CODE,
        'BAP' AS LIBELLE_COURT,
        'Branche d''activités professionnelles' AS LIBELLE_LONG,
        null AS DESCRIPTION,
        null AS D_OUVERTURE,
        null AS D_FERMETURE
    FROM DUAL
;
```

Modification de la base de données côté EMC2
```sql

-- creation de la table de stockage des types de correspondance
create table carriere_correspondance_type
(
    id                    bigint   constraint carriere_correspondance_type_pk primary key,
    code                  varchar(64)                            not null,
    libelle_court         varchar(256)                           not null,
    libelle_long          varchar(1024)                          not null,
    description           text,
    d_ouverture           timestamp,
    d_fermeture           timestamp,
    created_on            timestamp(0) default LOCALTIMESTAMP(0) not null,
    updated_on            timestamp(0),
    deleted_on            timestamp(0),
    histo_createur_id     bigint                                 not null,
    histo_modificateur_id bigint,
    histo_destructeur_id  bigint,
    source_id             bigint                                 not null,
    id_orig               varchar(100)
);

-- Ajout de la colonne type_id 
alter table carriere_correspondance add type_id bigint;
alter table carriere_correspondance add constraint carriere_correspondance_carriere_correspondance_type_null_fk foreign key (type_id) references carriere_correspondance_type (id);
```

Nouvelle synchro
```php 
'synchros' => [
    [
        'name' => 'CARRIERE_CORRESPONDANCE_TYPE',
        'order' => 1000,
        'source' => [
            'name' => 'octopus',
            'code' => 'OCTOPUS',
            'select'             => "
                SELECT ID AS ID_ORIG, CODE, LIBELLE_COURT, LIBELLE_LONG, DESCRIPTION, D_OUVERTURE, D_FERMETURE
                FROM V_PREECOG_CORRESPONDANCE_TYPE CT 
            ",
            'connection' => 'octopus',
            'source_code_column' => 'ID_ORIG',
        ],
        'destination' => [
            'name' => 'Listing des types de correspondances (BAP, CNU, BIB, ...)',
            'table' => 'carriere_correspondance_type',
            'connection' => 'default',
            'source_code_column' => 'id_orig',
            'intermediate_table_auto_drop' => true,
            'preserved_id' => true,
        ],
    ],
    ...
],
```
**Évolution des bibliothèques**

```
```
 No newline at end of file
+52 −0
Original line number Diff line number Diff line
@@ -4,9 +4,13 @@ namespace Carriere;

use Carriere\Controller\CorrespondanceController;
use Carriere\Controller\CorrespondanceControllerFactory;
use Carriere\Controller\CorrespondanceTypeController;
use Carriere\Controller\CorrespondanceTypeControllerFactory;
use Carriere\Provider\Privilege\CorrespondancePrivileges;
use Carriere\Service\Correspondance\CorrespondanceService;
use Carriere\Service\Correspondance\CorrespondanceServiceFactory;
use Carriere\Service\CorrespondanceType\CorrespondanceTypeService;
use Carriere\Service\CorrespondanceType\CorrespondanceTypeServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
@@ -25,6 +29,16 @@ return [
                        CorrespondancePrivileges::CORRESPONDANCE_INDEX,
                    ],
                ],
                [
                    'controller' => CorrespondanceTypeController::class,
                    'action' => [
                        'index',
                        'afficher',
                    ],
                    'privileges' => [
                        CorrespondancePrivileges::CORRESPONDANCE_INDEX,
                    ],
                ],
            ],
        ],

@@ -52,6 +66,42 @@ return [

    'router'          => [
        'routes' => [
            'carriere' => [
                'type'  => Literal::class,
                'options' => [
                    'route'    => '/carriere',
                    'defaults' => [
                        'controller' => CorrespondanceController::class,
                    ],
                ],
                'may_terminate' => false,
                'child_routes' => [
                    'correspondance-type' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/correspondance-type',
                            'defaults' => [
                                'controller' => CorrespondanceTypeController::class,
                                'action'     => 'index',
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => [
                            'afficher' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/afficher/:type',
                                    'defaults' => [
                                        'controller' => CorrespondanceTypeController::class,
                                        'action'     => 'afficher',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                        ],
                    ],
                ],
            ],
            'correspondance' => [
                'type'  => Literal::class,
                'options' => [
@@ -82,11 +132,13 @@ return [
    'service_manager' => [
        'factories' => [
            CorrespondanceService::class => CorrespondanceServiceFactory::class,
            CorrespondanceTypeService::class => CorrespondanceTypeServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
            CorrespondanceController::class => CorrespondanceControllerFactory::class,
            CorrespondanceTypeController::class => CorrespondanceTypeControllerFactory::class,
        ],
    ],
    'form_elements' => [
+34 −0
Original line number Diff line number Diff line
<?php

namespace Carriere\Controller;

use Carriere\Service\Correspondance\CorrespondanceServiceAwareTrait;
use Carriere\Service\CorrespondanceType\CorrespondanceTypeServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class CorrespondanceTypeController extends AbstractActionController {
    use CorrespondanceServiceAwareTrait;
    use CorrespondanceTypeServiceAwareTrait;

    public function indexAction() : ViewModel
    {
        $types = $this->getCorrespondanceTypeService()->getCorrespondancesTypes();

        return new ViewModel([
            'types' => $types
        ]);
    }

    public function afficherAction() : ViewModel
    {
        $type = $this->getCorrespondanceTypeService()->getRequestedCorrespondanceType($this);
        $correspondances = $this->getCorrespondanceService()->getCorrespondancesByType($type);

        return new ViewModel([
            'title' => "Affichage du type de correspondance [".$type->getCode()."]",
            'type' => $type,
            'correspondances' => $correspondances,
        ]);
    }
}
 No newline at end of file
+33 −0
Original line number Diff line number Diff line
<?php

namespace Carriere\Controller;

use Carriere\Service\Correspondance\CorrespondanceService;
use Carriere\Service\CorrespondanceType\CorrespondanceTypeService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;

class CorrespondanceTypeControllerFactory {

    /**
     * @param ContainerInterface $container
     * @return CorrespondanceTypeController
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __invoke(ContainerInterface $container) : CorrespondanceTypeController
    {
        /**
         * @var CorrespondanceService $correspondaceService
         * @var CorrespondanceTypeService $typeService
         */
        $correspondaceService = $container->get(CorrespondanceService::class);
        $typeService = $container->get(CorrespondanceTypeService::class);

        $controller = new CorrespondanceTypeController();
        $controller->setCorrespondanceService($correspondaceService);
        $controller->setCorrespondanceTypeService($typeService);
        return $controller;
    }
}
 No newline at end of file
+18 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Carriere\Entity\Db;

use Application\Entity\Db\AgentGrade;
use Application\Entity\Db\Traits\DbImportableAwareTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
@@ -21,7 +22,7 @@ class Correspondance {
    private $histo;
    /** @var ArrayCollection (AgentGrade) */
    private $agentGrades;

    private ?CorrespondanceType $type = null;
    /**
     * @return int
     */
@@ -103,6 +104,16 @@ class Correspondance {
        return $this;
    }

    public function getType(): ?CorrespondanceType
    {
        return $this->type;
    }

    public function setType(?CorrespondanceType $type): void
    {
        $this->type = $type;
    }

    /**
     * @return DateTime
     */
@@ -149,4 +160,10 @@ class Correspondance {
        return $text;
    }

    public function isHisto(?DateTime $date = null) : bool
    {
        if ($date === null) $date = new DateTime();
        return ($this->histo !== null AND $date < $this->histo);
    }

}
 No newline at end of file
Loading