Commit 4174a5a9 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Virage des trucs de agent/index

parent 272de5e9
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -73,16 +73,16 @@ class AgentController extends AbstractActionController
    public function indexAction()
    {
        $fromQueries = $this->params()->fromQuery();
        $filtres = [];
        $clefs = ['titulaire', 'cdi', 'cdd', 'administratif', 'chercheur', 'enseignant', 'vacataire'];
        foreach ($clefs as $clef) {
            if (empty($fromQueries) or $fromQueries[$clef] === 'on') $filtres[$clef] = true;
        }

        $agents = $this->getAgentService()->getAgents($filtres);
//        $filtres = [];
//        $clefs = ['titulaire', 'cdi', 'cdd', 'administratif', 'chercheur', 'enseignant', 'vacataire'];
//        foreach ($clefs as $clef) {
//            if (empty($fromQueries) or $fromQueries[$clef] === 'on') $filtres[$clef] = true;
//        }
//        $agents = $this->getAgentService()->getAgents($filtres);
        $agents = $this->getAgentService()->getAgents();
        return new ViewModel([
            'agents' => $agents,
            'filtres' => $filtres,
//            'filtres' => $filtres,
        ]);
    }

+10 −9
Original line number Diff line number Diff line
@@ -109,20 +109,21 @@ class AgentService {
        $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent')
            ->andWhere('agent.delete IS NULL')
            ->addSelect('affectation')->join('agent.affectations', 'affectation')
            ->addSelect('statut')->leftJoin('agent.statuts', 'statut')
            ->addSelect('utilisateur')->leftjoin('agent.utilisateur', 'utilisateur')
//            ->addSelect('statut')->leftJoin('agent.statuts', 'statut')
            ->andWhere('affectation.dateDebut <= :NOW')
            ->andWhere('affectation.dateFin >= :NOW OR affectation.dateFin IS NULL')
            ->setParameter('NOW', $this->getDateTime())
        ;

        $tmp = ['statut IS NULL'];
        foreach ($temoins as $temoin => $value) {
            if ($value) $tmp[] = 'statut.'. $temoin .' = :TRUE';
        }
        if (!empty($tmp)) {
            $qb = $qb->andWhere(implode(" OR ",$tmp))
                ->setParameter('TRUE', 'O');
        }
//        $tmp = ['statut IS NULL'];
//        foreach ($temoins as $temoin => $value) {
//            if ($value) $tmp[] = 'statut.'. $temoin .' = :TRUE';
//        }
//        if (!empty($tmp)) {
//            $qb = $qb->andWhere(implode(" OR ",$tmp))
//                ->setParameter('TRUE', 'O');
//        }

        if ($order !== null) {
            $qb = $qb->orderBy('agent.' . $order);
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ $this->headTitle("Index des agents")

<div class="main">

    <?php echo $this->partial('partial/filtre_statut', ['url' => $this->url('agent'), 'filtres' => $filtres]); ?>
<!--    --><?php //echo $this->partial('partial/filtre_statut', ['url' => $this->url('agent'), 'filtres' => $filtres]); ?>

    <?php if (count($agents) > 0) : ?>
        <table id="agents" class="datatable table table-condensed">