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

Debut : entity service controller (non fini)

parent e5e78112
Loading
Loading
Loading
Loading
+94
Changes for documentation/release/3.1.9.md: 94 added lines, 0 removed lines.
Original line number Diff line number Diff line
**CHANGES version 3.1.8**
===

Changements
---

* "Nouvelle" interface de gestion des structures 
* Nouveau paramètre 'Adresse d'assistance'
* Affichage des témoins des affectations soumis à privilège
* Retrait de la notion de délégué·e pour une compagne d'entretien professionnel
* Possibilité de changer la couleur de EMC2 via le nouveau fichier public/css/local.css
* [FIX] : correction du téléversement de fiches de poste au format PDF
* [FIX] EP : correction de la recherche des responsables d'entretien pour les agents sans obligation d'EP


Configurations
---

Renommage de `logos.css` en `local.css` qui contiendra les logos mais aussi la couleur de l'instance.

Ajout dans local.css
```css
:root {
    /** EMC2 **/
    --color-dark: rgb(46,139,87); /** seagreen **/

    /** MES FORMATIONS **/
    --color-main-formation: rgb(106,90,205); /** slateblue **/
}
```

Modification de la base de données
---

```postgresql

-- ---------------------------------------------------
-- TABLE DES AUTORITES ET DES SUPERIEURS -------------
-- ---------------------------------------------------

create table agent_autorite
(
    id                    serial                  not null
        constraint agent_autorite_pk primary key,
    agent_id              varchar(40)             not null
        constraint agent_autorite_agent_c_individu_fk references agent,
    autorite_id          varchar(40)             not null
        constraint agent_autorite_agent_c_individu_fk2 references agent,
    histo_creation        timestamp default now() not null,
    histo_createur_id     integer   default 0     not null
        constraint agent_autorite_unicaen_utilisateur_user_id_fk0 references unicaen_utilisateur_user,
    histo_modification    timestamp,
    histo_modificateur_id integer
        constraint agent_autorite_unicaen_utilisateur_user_id_fk1 references unicaen_utilisateur_user,
    histo_destruction     timestamp,
    histo_destructeur_id  integer
        constraint agent_autorite_unicaen_utilisateur_user_id_fk2 references unicaen_utilisateur_user
);
create index agent_autorite_agent_id_index on agent_autorite (agent_id);
create index agent_autorite_autorite_id_index on agent_autorite (autorite_id);

create table agent_superieur
(
    id                    serial                  not null
        constraint agent_superieur_pk primary key,
    agent_id              varchar(40)             not null
        constraint agent_superieur_agent_c_individu_fk references agent,
    superieur_id          varchar(40)             not null
        constraint agent_superieur_agent_c_individu_fk2 references agent,
    histo_creation        timestamp default now() not null,
    histo_createur_id     integer   default 0     not null
        constraint agent_superieur_unicaen_utilisateur_user_id_fk1 references unicaen_utilisateur_user,
    histo_modification    timestamp,
    histo_modificateur_id integer
        constraint agent_superieur_unicaen_utilisateur_user_id_fk1 references unicaen_utilisateur_user,
    histo_destruction     timestamp,
    histo_destructeur_id  integer
        constraint agent_superieur_unicaen_utilisateur_user_id_fk2 references unicaen_utilisateur_user
);

create index agent_superieur_agent_id_index
    on agent_superieur (agent_id);

create index agent_superieur_superieur_id_index
    on agent_superieur (superieur_id);


```


Mise à jour de bibliothèque
---

RAS
 No newline at end of file
+85
Changes for module/Application/config/merged/hierarchie.config.php: 85 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Controller\AgentHierarchieController;
use Application\Controller\AgentHierarchieControllerFactory;
use Application\Provider\Privilege\AgentPrivileges;
use Application\Service\AgentAutorite\AgentAutoriteService;
use Application\Service\AgentAutorite\AgentAutoriteServiceFactory;
use Application\Service\AgentSuperieur\AgentSuperieurService;
use Application\Service\AgentSuperieur\AgentSuperieurServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;

return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => AgentHierarchieController::class,
                    'action' => [
                        'index',
                        'afficher',
                    ],
                    'privileges' => [
                        AgentPrivileges::AGENT_INDEX, //todo "Faites mieux !!!"
                    ],
                ],
            ],
        ],
    ],

    'router'          => [
        'routes' => [
            'agent' => [
                'child_routes' => [
                    'hierachie' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/hierarchie',
                            'defaults' => [
                                'controller' => AgentHierarchieController::class,
                                'action'     => 'index',
                            ],
                        ],
                        'may_terminate' => true,
                        'child_routes' => [
                            'afficher' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/afficher/:agent',
                                    'defaults' => [
                                        'controller' => AgentHierarchieController::class,
                                        'action'     => 'afficher',
                                    ],
                                ],
                                'may_terminate' => true,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            AgentAutoriteService::class => AgentAutoriteServiceFactory::class,
            AgentSuperieurService::class => AgentSuperieurServiceFactory::class,
        ],
    ],
    'controllers'     => [
        'factories' => [
            AgentHierarchieController::class => AgentHierarchieControllerFactory::class
        ],
    ],
    'form_elements' => [
        'factories' => [],
    ],
    'hydrators' => [
        'factories' => [],
    ]

];
 No newline at end of file
+31
Changes for module/Application/src/Application/Controller/AgentHierarchieController.php: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\AgentAutorite\AgentAutoriteServiceAwareTrait;
use Application\Service\AgentSuperieur\AgentSuperieurServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class AgentHierarchieController extends AbstractActionController
{
    use AgentServiceAwareTrait;
    use AgentAutoriteServiceAwareTrait;
    use AgentSuperieurServiceAwareTrait;

    public function afficherAction() : ViewModel
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
        $superieurs = $this->getAgentSuperieurService()->getAgentsSuperieursByAgent($agent);
        $autorites = $this->getAgentAutoriteService()->getAgentsAutoritesByAgent($agent);

        return new ViewModel([
            'title' => "Chaîne hiérarchique de [".$agent->getDenomination()."]",
            'agent' => $agent,
            'superieurs' => $superieurs,
            'autorites' => $autorites,
        ]);
    }

}
 No newline at end of file
+40
Changes for module/Application/src/Application/Controller/AgentHierarchieControllerFactory.php: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Entity\Db\AgentAutorite;
use Application\Service\Agent\AgentService;
use Application\Service\AgentAutorite\AgentAutoriteService;
use Application\Service\AgentSuperieur\AgentSuperieurService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;

class AgentHierarchieControllerFactory
{

    /**
     * @param ContainerInterface $container
     * @return AgentHierarchieController
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __invoke(ContainerInterface $container) : AgentHierarchieController
    {
        /**
         * @var AgentService $agentService
         * @var AgentAutoriteService $agentAutoriteService
         * @var AgentSuperieurService $agentSuperieurService
         */
        $agentService = $container->get(AgentService::class);
        $agentAutoriteService = $container->get(AgentAutoriteService::class);
        $agentSuperieurService = $container->get(AgentSuperieurService::class);

        $controller = new AgentHierarchieController();
        $controller->setAgentService($agentService);
        $controller->setAgentAutoriteService($agentAutoriteService);
        $controller->setAgentSuperieurService($agentSuperieurService);
        return $controller;
    }

}
 No newline at end of file
+40
Changes for module/Application/src/Application/Entity/Db/Agent.php: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Entity\Db;

use Application\Provider\Etat\FichePosteEtats;
use Carriere\Entity\Db\NiveauEnveloppe;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Comparable;
use Element\Entity\Db\Interfaces\HasApplicationCollectionInterface;
use Element\Entity\Db\Interfaces\HasCompetenceCollectionInterface;
@@ -98,6 +99,9 @@ class Agent implements
    /** @var ArrayCollection (StructureAgentForce) */
    private $structuresForcees;

    private Collection $autorites;
    private Collection $superieurs;

    public function __construct()
    {
        $this->fiches = new ArrayCollection();
@@ -107,6 +111,9 @@ class Agent implements
        $this->echelons = new ArrayCollection();
        $this->grades = new ArrayCollection();
        $this->structuresForcees = new ArrayCollection();

        $this->autorites = new ArrayCollection();
        $this->superieurs = new ArrayCollection();
    }

    /**
@@ -670,6 +677,32 @@ class Agent implements
        return null;
    }



    /** AUTORITES ET SUPERIEURS *****************************************************************************/

    /** @return AgentAutorite[] */
    public function getAutorites(bool $histo = false): array
    {
        /** @var AgentAutorite[] $result */
        $result = $this->autorites->toArray();
        if ($histo === false) {
            $result = array_filter($result, function (AgentAutorite $a) { return $a->estNonHistorise();});
        }
        return $result;
    }

    /** @return AgentSuperieur[] */
    public function getSuperieurs(bool $histo = false): array
    {
        /** @var AgentSuperieur[] $result */
        $result = $this->superieurs->toArray();
        if ($histo === false) {
            $result = array_filter($result, function (AgentSuperieur $a) { return $a->estNonHistorise();});
        }
        return $result;
    }

    /** STRUCTURE AGENT FORCE *****************************************************************************************/

    /**
@@ -814,4 +847,11 @@ class Agent implements

        return $result;
    }

    public function isAdministratif(?DateTime $date = null)
    {
        $statuts =  $this->getStatutsActifs($date);
        foreach ($statuts as $statut) if ($statut->isAdministratif()) return true;
        return false;
    }
}
 No newline at end of file
Loading