diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilter.php new file mode 100644 index 000000000..337b27e8a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilter.php @@ -0,0 +1,87 @@ +add('steps', ChoiceType::class, [ + 'choices' => array_combine( + array_map(static fn (string $step): string => 'accompanying_period.'.$step, $steps), + $steps + ), + 'label' => 'export.filter.step_history.by_step.pick_steps', + 'multiple' => true, + 'expanded' => true, + ]); + } + + public function getFormDefaultData(): array + { + return [ + 'steps' => [], + ]; + } + + public function describeAction($data, $format = 'string') + { + return [ + 'export.filter.step_history.by_step.description', + [ + '%steps%' => implode(', ', array_map(fn (string $step) => $this->translator->trans('accompanying_period.'.$step), $data['steps'])), + ], + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb + ->andWhere('acpstephistory.step IN (:acpstephistory_by_step_filter_steps)') + ->setParameter('acpstephistory_by_step_filter_steps', $data['steps']); + } + + public function applyOn() + { + return Declarations::ACP_STEP_HISTORY; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php new file mode 100644 index 000000000..a603bd219 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilterTest.php @@ -0,0 +1,66 @@ + [AccompanyingPeriod::STEP_CONFIRMED, AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG], + ], + [ + 'steps' => [AccompanyingPeriod::STEP_CLOSED], + ], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $qb = $em->createQueryBuilder() + ->select('COUNT(DISTINCT acpstephistory.id) As export_result') + ->from(AccompanyingPeriodStepHistory::class, 'acpstephistory') + ->join('acpstephistory.period', 'acp'); + + return [ + $qb, + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 206664b63..e865cab76 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -786,6 +786,8 @@ accompanying_period: DRAFT: Brouillon CONFIRMED: Confirmé CLOSED: Clotûré + CONFIRMED_INACTIVE_SHORT: Hors file active + CONFIRMED_INACTIVE_LONG: Pré-archivé emergency: Urgent occasional: ponctuel regular: régulier @@ -1132,7 +1134,10 @@ export: Filtered by person's geographical unit (based on address) computed at %datecalc%, only %units%: Filtré par unité géographique (sur base de l'adresse), calculé le %datecalc%, seulement %units% step_history: - by_closing_motive + by_step: + title: Filtrer les changements de statut du parcours par étape + pick_steps: Nouvelles étapes + description: "Filtré par étape: seulement %steps%" by_date: title: Filtrer les changements de statut du parcours par date start_date_label: Changements après le