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

WIP

parent dbed44c8
Loading
Loading
Loading
Loading
+42 −31
Original line number Diff line number Diff line
@@ -2,11 +2,10 @@

namespace Application\Controller;

use Application\Entity\Db\Agent;
use Application\Entity\Db\AgentAutorite;
use Application\Entity\Db\AgentSuperieur;
use Application\Provider\Privilege\AgentPrivileges;
use Application\Provider\Role\RoleProvider as AppRoleProvider;
use Application\Entity\Db\Agent;
use Application\Provider\Template\TexteTemplate;
use Application\Service\Agent\AgentServiceAwareTrait;
use Application\Service\AgentAutorite\AgentAutoriteServiceAwareTrait;
@@ -16,8 +15,10 @@ use EntretienProfessionnel\Entity\Db\Campagne;
use EntretienProfessionnel\Service\Campagne\CampagneServiceAwareTrait;
use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelServiceAwareTrait;
use Formation\Service\DemandeExterne\DemandeExterneServiceAwareTrait;
use Formation\Service\FormationInstanceInscrit\FormationInstanceInscritServiceAwareTrait;
use Formation\Service\Inscription\InscriptionServiceAwareTrait;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use Structure\Controller\StructureController;
use Structure\Entity\Db\StructureAgentForce;
use Structure\Provider\Parametre\StructureParametres;
@@ -30,8 +31,6 @@ use UnicaenUtilisateur\Entity\Db\Role;
use UnicaenUtilisateur\Entity\Db\User;
use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
@@ -48,7 +47,7 @@ class IndexController extends AbstractActionController

    use FichePosteServiceAwareTrait;
    use EntretienProfessionnelServiceAwareTrait;
    use FormationInstanceInscritServiceAwareTrait;
    use InscriptionServiceAwareTrait;
    use DemandeExterneServiceAwareTrait;

    public function indexAction(): ViewModel|Response
@@ -118,16 +117,22 @@ class IndexController extends AbstractActionController
        $user = $this->getUserService()->getConnectedUser();
        $agent = $this->getAgentService()->getAgentByUser($user);

        $agents = array_map(function (AgentSuperieur $a) { return $a->getAgent(); },$this->getAgentSuperieurService()->getAgentsSuperieursBySuperieur($agent));
        $agents = array_map(function (AgentSuperieur $a) {
            return $a->getAgent();
        }, $this->getAgentSuperieurService()->getAgentsSuperieursBySuperieur($agent));
        $agents = $this->getAgentService()->filtrerWithStatutTemoin($agents, $this->getParametreService()->getParametreByCode(StructureParametres::TYPE, StructureParametres::AGENT_TEMOIN_STATUT));
        $agents = $this->getAgentService()->filtrerWithAffectationTemoin($agents, $this->getParametreService()->getParametreByCode(StructureParametres::TYPE, StructureParametres::AGENT_TEMOIN_AFFECTATION));
        usort($agents, function (Agent $a, Agent $b) { return $a->getNomUsuel()." ".$a->getPrenom() > $b->getNomUsuel()." ".$b->getPrenom();});
        usort($agents, function (Agent $a, Agent $b) {
            return $a->getNomUsuel() . " " . $a->getPrenom() > $b->getNomUsuel() . " " . $b->getPrenom();
        });

        /** Campagne d'entretien professionnel ************************************************************************/
        $last = $this->getCampagneService()->getLastCampagne();
        $campagnes = $this->getCampagneService()->getCampagnesActives();
        if ($last !== null) $campagnes[] = $last;
        usort($campagnes, function (Campagne $a, Campagne $b) { return $a->getDateDebut() > $b->getDateDebut();});
        usort($campagnes, function (Campagne $a, Campagne $b) {
            return $a->getDateDebut() > $b->getDateDebut();
        });

        /** Récuperation des eps **************************************************************************************/
        $entretiens = [];
@@ -137,10 +142,10 @@ class IndexController extends AbstractActionController

        /** Récupération des fiches de postes *************************************************************************/
        $fichesDePoste = [];
        foreach ($agents as $agent) {
            if ($agent instanceof StructureAgentForce) $agent = $agent->getAgent();
            $fiches = $this->getFichePosteService()->getFichesPostesByAgent($agent);
            $fichesDePoste[$agent->getId()] = $fiches;
        foreach ($agents as $agent_) {
            if ($agent_ instanceof StructureAgentForce) $agent_ = $agent_->getAgent();
            $fiches = $this->getFichePosteService()->getFichesPostesByAgent($agent_);
            $fichesDePoste[$agent_->getId()] = $fiches;
        }
        $fichesDePostePdf = $this->getAgentService()->getFichesPostesPdfByAgents($agents);

@@ -161,17 +166,23 @@ class IndexController extends AbstractActionController
        $user = $this->getUserService()->getConnectedUser();
        $agent = $this->getAgentService()->getAgentByUser($user);

        $agents = array_map(function (AgentAutorite $a) { return $a->getAgent(); },$this->getAgentAutoriteService()->getAgentsAutoritesByAutorite($agent));
        $agents = array_map(function (AgentAutorite $a) {
            return $a->getAgent();
        }, $this->getAgentAutoriteService()->getAgentsAutoritesByAutorite($agent));
        $agents = $this->getAgentService()->filtrerWithStatutTemoin($agents, $this->getParametreService()->getParametreByCode(StructureParametres::TYPE, StructureParametres::AGENT_TEMOIN_STATUT));
        $agents = $this->getAgentService()->filtrerWithAffectationTemoin($agents, $this->getParametreService()->getParametreByCode(StructureParametres::TYPE, StructureParametres::AGENT_TEMOIN_AFFECTATION));

        usort($agents, function (Agent $a, Agent $b) { return $a->getNomUsuel()." ".$a->getPrenom() > $b->getNomUsuel()." ".$b->getPrenom();});
        usort($agents, function (Agent $a, Agent $b) {
            return $a->getNomUsuel() . " " . $a->getPrenom() > $b->getNomUsuel() . " " . $b->getPrenom();
        });

        /** Campagne d'entretien professionnel ************************************************************************/
        $last = $this->getCampagneService()->getLastCampagne();
        $campagnes = $this->getCampagneService()->getCampagnesActives();
        if ($last !== null) $campagnes[] = $last;
        usort($campagnes, function (Campagne $a, Campagne $b) { return $a->getDateDebut() > $b->getDateDebut();});
        usort($campagnes, function (Campagne $a, Campagne $b) {
            return $a->getDateDebut() > $b->getDateDebut();
        });

        /** Récuperation des eps **************************************************************************************/
        $entretiens = [];
@@ -181,10 +192,10 @@ class IndexController extends AbstractActionController

        /** Récupération des fiches de postes *************************************************************************/
        $fichesDePoste = [];
        foreach ($agents as $agent) {
            if ($agent instanceof StructureAgentForce) $agent = $agent->getAgent();
            $fiches = $this->getFichePosteService()->getFichesPostesByAgent($agent);
            $fichesDePoste[$agent->getId()] = $fiches;
        foreach ($agents as $agent_) {
            if ($agent_ instanceof StructureAgentForce) $agent_ = $agent_->getAgent();
            $fiches = $this->getFichePosteService()->getFichesPostesByAgent($agent_);
            $fichesDePoste[$agent_->getId()] = $fiches;
        }
        $fichesDePostePdf = $this->getAgentService()->getFichesPostesPdfByAgents($agents);

+3 −6
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use Application\Service\FichePoste\FichePosteService;
use EntretienProfessionnel\Service\Campagne\CampagneService;
use EntretienProfessionnel\Service\EntretienProfessionnel\EntretienProfessionnelService;
use Formation\Service\DemandeExterne\DemandeExterneService;
use Formation\Service\FormationInstanceInscrit\FormationInstanceInscritService;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -20,7 +19,8 @@ use UnicaenRenderer\Service\Rendu\RenduService;
use UnicaenUtilisateur\Service\Role\RoleService;
use UnicaenUtilisateur\Service\User\UserService;

class IndexControllerFactory {
class IndexControllerFactory
{

    /**
     * @param ContainerInterface $container
@@ -45,7 +45,6 @@ class IndexControllerFactory {
         *
         * @var FichePosteService $fichePosteService
         * @var EntretienProfessionnelService $entretienProfessionelService
         * @var FormationInstanceInscritService $formationInstanceinscritService
         * @var DemandeExterneService $demandeExterneService
         *
         */
@@ -62,7 +61,6 @@ class IndexControllerFactory {

        $fichePosteService = $container->get(FichePosteService::class);
        $entretienProfessionelService = $container->get(EntretienProfessionnelService::class);
        $formationInstanceinscritService = $container->get(FormationInstanceInscritService::class);
        $demandeExterneService = $container->get(DemandeExterneService::class);

        /** @var IndexController $controller */
@@ -81,7 +79,6 @@ class IndexControllerFactory {

        $controller->setFichePosteService($fichePosteService);
        $controller->setEntretienProfessionnelService($entretienProfessionelService);
        $controller->setFormationInstanceInscritService($formationInstanceinscritService);
        $controller->setDemandeExterneService($demandeExterneService);
        return $controller;
    }
+0 −128
Original line number Diff line number Diff line
<?php
/**
 * @var Agent[] $agents
 * @var FormationInstanceInscrit[] $demandesInternes
 * @var DemandeExterne[] $demandesExternes
 */

use Application\Entity\Db\Agent;
use Formation\Entity\Db\DemandeExterne;
use Formation\Entity\Db\FormationInstanceInscrit;
use Formation\Provider\Etat\DemandeExterneEtats;
use Formation\Provider\Etat\InscriptionEtats;

$canAfficherFormation = true;
$canValiderResponsable = true;
?>

<h2> Demande de formations internes (plan de formation) </h2>

<?php foreach ($agents as $agent) : ?>
    <?php if (isset($demandesInternes[$agent->getId()])) : ?>
        <h3> <?php echo $agent->getDenomination(); ?> </h3>

        <table id="formation" class="table table-condensed table-hover">
            <thead>
            <tr>
                <th>Formation</th>
                <th class="periode">Période</th>
                <th class="etat">Etat</th>
                <th class="action">Action</th>
            </tr>
            </thead>
            <tbody>
                <?php /** @var FormationInstanceInscrit $demande */ ?>
                <?php foreach ($demandesInternes[$agent->getId()] as $demande) : ?>
                <tr>
                    <td> <?php echo $demande->getInstance()->getFormation()->getLibelle() ;?> </td>
                    <td> <?php echo $demande->getInstance()->getPeriode() ;?> </td>
                    <td> <?php echo $this->etatinstance($demande->getEtatActif()) ;?> </td>
                    <td>
                        <?php if ($canAfficherFormation) : ?>
                            <?php /** @see \Formation\Controller\FormationInstanceInscritController::afficherAgentAction() */ ?>
                            <a href="<?php echo $this->url('formation-instance/afficher-agent', ['inscrit' => $demande->getId()], [], true); ?>"
                               class="ajax-modal">
                                <span class="icon icon-voir" title="Examiner l'inscription"></span></a>
                        <?php endif; ?>
                        <?php if ($canValiderResponsable AND $demande->isEtatActif(InscriptionEtats::ETAT_DEMANDE)) : ?>
                            <?php  /** @see \Formation\Controller\FormationInstanceInscritController::validerResponsableAction() */ ?>
                            <a href="<?php echo $this->url('formation-instance/valider-responsable', ['inscrit' => $demande->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon icon-ok text-success"></span></a>
                            <?php  /** @see \Formation\Controller\FormationInstanceInscritController::refuserResponsableAction() */ ?>
                            <a href="<?php echo $this->url('formation-instance/refuser-responsable', ['inscrit' => $demande->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon icon-ko text-danger"></span></a>
                        <?php endif; ?>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    <?php endif; ?>
<?php endforeach; ?>

<h2> Demande de stages externes </h2>

<?php foreach ($agents as $agent) : ?>
    <?php if (isset($demandesInternes[$agent->getId()])) : ?>
        <h3> <?php echo $agent->getDenomination(); ?> </h3>

        <table id="formation" class="table table-condensed table-hover">
            <thead>
            <tr>
                <th>Formation</th>
                <th class="periode">Période</th>
                <th class="etat">Etat</th>
                <th class="action">Action</th>
            </tr>
            </thead>
            <tbody>
            <?php /** @var DemandeExterne $demande */ ?>
            <?php foreach ($demandesExternes[$agent->getId()] as $demande) : ?>
                <tr>
                    <td> <?php echo $demande->getLibelle() ;?> </td>
                    <td> <?php echo $demande->getPeriodeAsString() ;?> </td>
                    <td> <?php echo $this->etatinstance($demande->getEtatActif()) ;?> </td>
                    <td>
                        <?php if ($canAfficherFormation) : ?>
                            <?php /** @see \Formation\Controller\DemandeExterneController::afficherAction() */ ?>
                            <a href="<?php echo $this->url('formation/demande-externe/afficher', ['demande-externe' => $demande->getId()],[], true); ?>"
                            class="ajax-modal">
                            <span class="icon icon-voir"></span></a>
                        <?php endif; ?>
                        <?php if ($canValiderResponsable AND $demande->isEtatActif(DemandeExterneEtats::ETAT_VALIDATION_AGENT)) : ?>
                            <?php /** @see \Formation\Controller\DemandeExterneController::validerDrhAction() */ ?>
                            <a href="<?php echo $this->url('formation/demande-externe/valider-drh', ['demande-externe' => $demande->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon icon-ok text-success"></span></a>
                            <?php /** @see \Formation\Controller\DemandeExterneController::refuserDrhAction() */ ?>
                            <a href="<?php echo $this->url('formation/demande-externe/refuser-drh', ['demande-externe' => $demande->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon icon-ko text-danger"></span></a>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    <?php endif; ?>
<?php endforeach; ?>


<style>
    table#formation .action {
        min-width: 6rem;
        width: 6rem;
    }

    table#formation .etat {
        min-width: 6rem;
        width: 6rem;
    }

    table#formation .periode {
        min-width: 15rem;
        width: 15rem;
    }
</style>
+2 −2
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ return [
                                'type'  => Segment::class,
                                'may_terminate' => true,
                                'options' => [
                                    'route'    => '/repondre-questions/:inscrit',
                                    'route'    => '/repondre-questions/:inscription',
                                    'defaults' => [
                                        'controller' => EnqueteQuestionController::class,
                                        'action'     => 'repondre-questions',
@@ -288,7 +288,7 @@ return [
                                'type'  => Segment::class,
                                'may_terminate' => true,
                                'options' => [
                                    'route'    => '/valider-questions/:inscrit',
                                    'route'    => '/valider-questions/:inscription',
                                    'defaults' => [
                                        'controller' => EnqueteQuestionController::class,
                                        'action'     => 'valider-questions',
+10 −83
Original line number Diff line number Diff line
@@ -6,11 +6,7 @@ use Formation\Controller\FormationInstanceInscritController;
use Formation\Controller\FormationInstanceInscritControllerFactory;
use Formation\Controller\PlanDeFormationController;
use Formation\Controller\ProjetPersonnelController;
use Formation\Provider\Privilege\FormationinstanceinscritPrivileges;
use Formation\Provider\Privilege\FormationinstancePrivileges;
use Formation\Service\FormationInstanceInscrit\FormationInstanceInscritService;
use Formation\Service\FormationInstanceInscrit\FormationInstanceInscritServiceFactory;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenPrivilege\Guard\PrivilegeController;

@@ -29,10 +25,6 @@ return [
                [
                    'controller' => FormationInstanceInscritController::class,
                    'action' => [
                        'inscription-formation',
                        'inscription',
                        'desinscription',

                        'formations',
                        'inscriptions',
                        'inscription-interne',
@@ -42,26 +34,6 @@ return [
                        'Agent',
                    ],
                ],
                [
                    'controller' => FormationInstanceInscritController::class,
                    'action' => [
                        'valider-responsable',
                        'refuser-responsable',
                    ],
                    'privileges' => [
                        FormationinstanceinscritPrivileges::INSCRIPTION_VALIDER_SUPERIEURE,
                    ],
                ],
                [
                    'controller' => FormationInstanceInscritController::class,
                    'action' => [
                        'valider-drh',
                        'refuser-drh',
                    ],
                    'privileges' => [
                        FormationinstanceinscritPrivileges::INSCRIPTION_VALIDER_GESTIONNAIRE,
                    ],
                ],
            ],
        ],
    ],
@@ -177,66 +149,21 @@ return [
                    ],
                ],
            ],
            'inscription-formation' => [
                'type' => Literal::class,
                'options' => [
                    'route' => '/inscription-formation',
                    'defaults' => [
                        'controller' => FormationInstanceInscritController::class,
                        'action' => 'inscription-formation',
                    ],
                ],
            ],
            'formation-instance' => [
                'child_routes' => [
                    'inscription' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/inscription/:formation-instance/:agent',
                            'defaults' => [
                                'controller' => FormationInstanceInscritController::class,
                                'action' => 'inscription',
                            ],
                        ],
                    ],
                    'desinscription' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/desinscription/:inscrit',
                            'defaults' => [
                                'controller' => FormationInstanceInscritController::class,
                                'action' => 'desinscription',
                            ],
                        ],
                    ],
                    'valider-responsable' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/valider-responsable/:inscrit',
                            'defaults' => [
                                'controller' => FormationInstanceInscritController::class,
                                'action' => 'valider-responsable',
                            ],
                        ],
                    ],
                    'refuser-responsable' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/refuser-responsable/:inscrit',
                            'defaults' => [
                                'controller' => FormationInstanceInscritController::class,
                                'action' => 'refuser-responsable',
                            ],
                        ],
                    ],
                ],
            ],
//            'inscription-formation' => [
//                'type' => Literal::class,
//                'options' => [
//                    'route' => '/inscription-formation',
//                    'defaults' => [
//                        'controller' => FormationInstanceInscritController::class,
//                        'action' => 'inscription-formation',
//                    ],
//                ],
//            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            FormationInstanceInscritService::class => FormationInstanceInscritServiceFactory::class,
        ],
    ],
    'controllers' => [
Loading