From d3a73ff6e56a6f75482637f3f4924562671a8719 Mon Sep 17 00:00:00 2001
From: Antony Le Courtes <antony.lecourtes@unicaen.fr>
Date: Fri, 29 Apr 2022 16:32:16 +0200
Subject: [PATCH] =?UTF-8?q?Filtre=20sur=20ann=C3=A9e=20pour=20la=20liste?=
 =?UTF-8?q?=20des=20statuts=20dans=20les=20donn=C3=A9es=20personnelles.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Intervenant/src/Service/StatutService.php | 25 +++++++------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/module/Intervenant/src/Service/StatutService.php b/module/Intervenant/src/Service/StatutService.php
index ea452f884a..43954b45ee 100755
--- a/module/Intervenant/src/Service/StatutService.php
+++ b/module/Intervenant/src/Service/StatutService.php
@@ -19,7 +19,6 @@ class StatutService extends AbstractEntityService
     private array $statuts = [];
 
 
-
     /**
      * retourne la classe des entités
      *
@@ -32,7 +31,6 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * Retourne l'alias d'entité courante
      *
@@ -44,7 +42,6 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * @param string $code
      *
@@ -56,7 +53,6 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * @return Statut
      */
@@ -66,14 +62,13 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * @return Statut[]
      */
     public function getStatuts(): array
     {
         if (empty($this->statuts)) {
-            $dql   = "SELECT s FROM " . Statut::class . " s WHERE s.annee = :annee AND s.histoDestruction IS NULL ORDER BY s.ordre";
+            $dql = "SELECT s FROM " . Statut::class . " s WHERE s.annee = :annee AND s.histoDestruction IS NULL ORDER BY s.ordre";
             $query = $this->getEntityManager()->createQuery($dql)->setParameter('annee', $this->getServiceContext()->getAnnee());
 
             $this->statuts = $query->getResult();
@@ -83,15 +78,18 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     public function getStatutSelectable(Statut $statut, QueryBuilder $qb = null, $alias = null)
     {
         [$qb, $alias] = $this->initQuery($qb, $alias);
         $qb->andWhere("$alias.dossierSelectionnable = 1");
+        $qb->andWhere("$alias.annee = " . $this->getServiceContext()->getAnnee()->getId());
+
+        $entities = $qb->getQuery()->execute();
         $qb->addOrderBy("$alias.code");
 
-        $entities    = $qb->getQuery()->execute();
-        $result      = [];
+        var_dump($qb->getQuery()->getSql());
+
+        $result = [];
         $entityClass = $this->getEntityClass();
         foreach ($entities as $entity) {
             if ($entity instanceof $entityClass) {
@@ -110,10 +108,9 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * @param QueryBuilder|null $qb
-     * @param null              $alias
+     * @param null $alias
      *
      * @return QueryBuilder
      */
@@ -126,16 +123,14 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     public function fetchMaxOrdre(): int
     {
-        $sql = 'SELECT MAX(ORDRE) MAX_ORDRE FROM STATUT WHERE HISTO_DESTRUCTION IS NULL';
+        $sql = 'SELECT MAX(ordre) max_ordre FROM statut WHERE histo_destruction IS NULL';
 
         return (int)$this->getEntityManager()->getConnection()->fetchOne($sql);
     }
 
 
-
     /**
      * Retourne une nouvelle entité, initialisée avec les bons paramètres
      *
@@ -151,7 +146,6 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     public function delete($entity, $softDelete = true)
     {
         $this->getSessionContainer()->offsetUnset('privileges' . $entity->getAnnee()->getId());
@@ -160,7 +154,6 @@ class StatutService extends AbstractEntityService
     }
 
 
-
     /**
      * @param Statut $entity
      *
-- 
GitLab