Commit 935e8bdf authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Nouvelle index EPro

parent d9d3778e
Loading
Loading
Loading
Loading
+8 −20
Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Controller/EntretienProfessionnelController.php: 8 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -60,29 +60,17 @@ class EntretienProfessionnelController extends AbstractActionController

    public function indexAction() : ViewModel
    {
        $fromQueries  = $this->params()->fromQuery();
        $agent        = $this->getAgentService()->getAgent($fromQueries['agent']);
        $responsable  = $this->getAgentService()->getAgent($fromQueries['responsable']);
        $structure    = $this->getStructureService()->getStructure($fromQueries['structure']);
        $campagne     = $this->getCampagneService()->getCampagne((trim($fromQueries['campagne']) !== '')?trim($fromQueries['campagne']):null);
        $etat         = $this->getEtatService()->getEtat((trim($fromQueries['etat'])!=='')?trim($fromQueries['etat']):null);
        $entretiens = $this->getEntretienProfessionnelService()->getEntretiensProfessionnels($agent, $responsable, $structure, $campagne, $etat);

        $campagnes = $this->getCampagneService()->getCampagnes();
        $etats = $this->getEtatService()->getEtatsByTypeCode('ENTRETIEN_PROFESSIONNEL');
        $params  = $this->params()->fromQuery();
        $entretiens = [];
        if ($params !== null AND !empty($params)) {
            $entretiens = $this->getEntretienProfessionnelService()->getEntretiensProfessionnelsWithFiltre($params);
        }

        return new ViewModel([
            'entretiens' => $entretiens,
            'campagnes' => $campagnes,
            'etats' => $etats,

            'params' => [
                'campagneId' => ($campagne)?$campagne->getId():null,
                'etatId' => ($etat)?$etat->getId():null,
                'agent' => $agent,
                'responsable' => $responsable,
                'structure' => $structure,
            ],
            'params' => $params,
            'campagnes' => $this->getCampagneService()->getCampagnes(),
            'etats' => $this->getEtatService()->getEtatsByTypeCode('ENTRETIEN_PROFESSIONNEL'),
        ]);
    }

+27 −5
Changes for module/EntretienProfessionnel/src/EntretienProfessionnel/Service/EntretienProfessionnel/EntretienProfessionnelService.php: 27 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -121,13 +121,13 @@ class EntretienProfessionnelService {
    /**
     * @return QueryBuilder
     */
    public function createQueryBuilder() : QueryBuilder
    public function createQueryBuilder(bool $withAffectation = true) : QueryBuilder
    {
        $qb = $this->getEntityManager()->getRepository(EntretienProfessionnel::class)->createQueryBuilder('entretien')
            ->addSelect('agent')->join('entretien.agent', 'agent')
            ->addSelect('fichesa')->leftjoin('agent.fiches', 'fichesa')
            ->addSelect('affectation')->join('agent.affectations', 'affectation')
            ->addSelect('astructure')->join('affectation.structure', 'astructure')
            ->addSelect('affectation')->leftjoin('agent.affectations', 'affectation')
            ->addSelect('astructure')->leftjoin('affectation.structure', 'astructure')

            ->addSelect('responsable')->join('entretien.responsable', 'responsable')
            ->addSelect('fichesr')->leftjoin('responsable.fiches', 'fichesr')
@@ -137,7 +137,7 @@ class EntretienProfessionnelService {
        ;

        $qb = EntretienProfessionnel::decorateWithEtat($qb, 'entretien');
        $qb = AgentAffectation::decorateWithActif($qb, 'affectation');
        if ($withAffectation) $qb = AgentAffectation::decorateWithActif($qb, 'affectation');
        return $qb;
    }

@@ -255,7 +255,7 @@ class EntretienProfessionnelService {
     */
    public function getEntretienProfessionnel(?int $id) : ?EntretienProfessionnel
    {
        $qb = $this->createQueryBuilder()
        $qb = $this->createQueryBuilder(false)
            ->addSelect('formulaireInstance')->leftJoin('entretien.formulaireInstance', 'formulaireInstance')
            ->addSelect('reponse')->leftJoin('formulaireInstance.reponses', 'reponse')
            ->addSelect('champ')->leftJoin('reponse.champ', 'champ')
@@ -526,4 +526,26 @@ class EntretienProfessionnelService {
        $this->update($entretien);
        return $validation;
    }

    /**
     * @param array $params
     * @return EntretienProfessionnel[]
     */
    public function getEntretiensProfessionnelsWithFiltre(array $params) : array
    {
        $qb = $this->getEntityManager()->getRepository(EntretienProfessionnel::class)->createQueryBuilder('entretien')
            ->join('entretien.campagne', 'campagne')->addSelect('campagne')
            ->join('entretien.agent', 'agent')->addSelect('agent')
        ;

        $result = $qb->getQuery()->getResult();
        return $result;

//        $agent        = $this->getAgentService()->getAgent($fromQueries['agent']);
//        $responsable  = $this->getAgentService()->getAgent($fromQueries['responsable']);
//        $structure    = $this->getStructureService()->getStructure($fromQueries['structure']);
//        $campagne     = $this->getCampagneService()->getCampagne((trim($fromQueries['campagne']) !== '')?trim($fromQueries['campagne']):null);
//        $etat         = $this->getEtatService()->getEtat((trim($fromQueries['etat'])!=='')?trim($fromQueries['etat']):null);
//        $entretiens = $this->getEntretienProfessionnelService()->getEntretiensProfessionnels($agent, $responsable, $structure, $campagne, $etat);
    }
}
+72 −9
Changes for module/EntretienProfessionnel/view/entretien-professionnel/entretien-professionnel/index.phtml: 72 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -41,14 +41,77 @@ $canDetruire = $this->isAllowed(EntretienproPrivileges::getResourceId(Entreti

<?php echo $this->messenger()->addMessagesFromFlashMessenger(); ?>

<?php echo $this->partial('partial/filtre', ['etats' => $etats, 'campagnes' => $campagnes, 'params' => $params], [], true); ?>
<?php echo $this->partial('partial/filtre', ['etats' => $etats, 'campagnes' => $campagnes, 'params' => []], [], true); ?>

<?php echo $this->entretienProfessionnelArray($entretiens,
    [
        'affichages' => ['lieu' => false],
        'droits' => []
    ]
); ?>
<?php if ($params === null or $params === []) : ?>
    <div class="alert alert-info">
        <span class="icon icon-information"></span>
        Aucun critère de recherche.
    </div>
<?php else : ?>
    <?php if (empty($entretiens)) : ?>
    <div class="alert alert-warning">
        <span class="icon icon-information"></span>
        Aucun entretien professionnel pour les critères de recherche.
    </div>
<?php else : ?>
<table class="table table-condensed">
    <thead>
    <tr>
        <th> Année </th>
        <th> Structure </th>
        <th> Agent </th>
        <th> Responsable </th>
        <th> Date </th>
        <th id="etat"> État </th>
        <th id="action"> Action </th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($entretiens as $entretien) : ?>
        <tr class=" <?php if ($entretien->estHistorise()) echo " historise "; ?> ">
            <td> <?php echo $entretien->getCampagne()->getAnnee(); ?> </td>
            <td>
                <ul>
                    <?php $affectations = $entretien->getAgent()->getAffectations($entretien->getDateEntretien()); ?>
                    <?php foreach ($affectations as $affectation) : ?>
                        <li> <?php echo $affectation->getStructure()->getLibelleCourt(); ?></li>
                    <?php endforeach; ?>
                </ul>
            </td>
            <td> <?php echo $entretien->getAgent()->getDenomination(); ?> </td>
            <td> <?php echo $entretien->getResponsable()->getDenomination(); ?> </td>
            <td> <?php echo $entretien->getDateEntretien()->format('d/m/Y à H:i'); ?> </td>
            <td> <?php echo $this->etatbadge($entretien->getEtat()); ?> </td>
            <td>
                <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::accederAction() */ ?>
                <a href="<?php echo $this->url('entretien-professionnel/acceder', ['entretien-professionnel' => $entretien->getId()], [], true); ?>">
                    <span class="icon icon-voir"></span></a>
                <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::modifierAction() */ ?>
                <a href="<?php echo $this->url('entretien-professionnel/modifier', ['entretien' => $entretien->getId()], [], true); ?>">
                    <span class="icon gerer"></span></a>
                <?php if ($entretien->estNonHistorise()) : ?>
                    <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::historiserAction() */ ?>
                    <a href="<?php echo $this->url('entretien-professionnel/historiser', ['entretien' => $entretien->getId()], [], true); ?>">
                        <span class="icon icon-historiser"></span></a>
                <?php else : ?>
                    <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::restaurerAction() */ ?>
                    <a href="<?php echo $this->url('entretien-professionnel/restaurer', ['entretien' => $entretien->getId()], [], true); ?>">
                        <span class="icon icon-restaurer"></span></a>
                <?php endif; ?>
                <?php if ($entretien->estHistorise()) : ?>
                <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::detruireAction() */ ?>
                <a href="<?php echo $this->url('entretien-professionnel/detruire', ['entretien' => $entretien->getId()], [], true); ?>"
                   class="ajax-modal" data-event="modification">
                    <span class="icon icon-retirer text-danger"></span></a>
                <?php endif; ?>
            </td>
        </tr>
    <?php endforeach; ?>
    </tbody>
</table>
<?php endif; ?>
<?php endif; ?>


<style>
@@ -58,8 +121,8 @@ $canDetruire = $this->isAllowed(EntretienproPrivileges::getResourceId(Entreti
    }

    th#action {
        width:11rem;
        min-width: 6rem;
        width:9rem;
        min-width: 9rem;
    }

    @media (min-width: 0) and (max-width: 768px) {