diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 71fe3250f..c8b7ccc55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -13,9 +13,9 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Repository\UserJobRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -25,10 +25,14 @@ class CreatorJobFilter implements FilterInterface { private TranslatableStringHelper $translatableStringHelper; + private UserJobRepositoryInterface $userJobRepository; + public function __construct( - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + UserJobRepositoryInterface $userJobRepository ) { $this->translatableStringHelper = $translatableStringHelper; + $this->userJobRepository = $userJobRepository; } public function addRole(): ?string @@ -42,17 +46,9 @@ class CreatorJobFilter implements FilterInterface $qb->join('acp.createdBy', 'acp_creator'); } - $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('acp_creator.userJob', ':creator_job'); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('creator_job', $data['creator_job']); + $qb + ->andWhere($qb->expr()->in('acp_creator.userJob', ':creator_job')) + ->setParameter('creator_job', $data['creator_job']); } public function applyOn(): string @@ -64,6 +60,7 @@ class CreatorJobFilter implements FilterInterface { $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, + 'choices' => $this->userJobRepository->findAllActive(), 'choice_label' => function (UserJob $j) { return $this->translatableStringHelper->localize( $j->getLabel() @@ -84,7 +81,7 @@ class CreatorJobFilter implements FilterInterface ); } - return ['Filtered by creator job: only %jobs%', [ + return ['export.filter.course.creator_job.Filtered by creator job: only %jobs%', [ '%jobs%' => implode(', ', $creatorJobs), ]]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index a48d5ea46..3821253ed 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1023,6 +1023,8 @@ export: Having a temporarily location: Ayant une localisation temporaire Having a person's location: Ayant une localisation auprès d'un usager Calculation date: Date de la localisation + creator_job: + 'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%' list: person_with_acp: List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement