From 436f1d6c61fdd80863e75fed9f0a833ebf04ce1c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 9 Aug 2022 12:12:52 +0200 Subject: [PATCH] exports: add new requestor aggregator --- .../RequestorAggregator.php | 122 ++++++++++++++++++ .../services/exports_accompanying_course.yaml | 7 + .../translations/messages.fr.yml | 1 + 3 files changed, 130 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php new file mode 100644 index 000000000..8d8b7029c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -0,0 +1,122 @@ +translator = $translator; + } + + /** + * @inheritDoc + */ + public function getLabels($key, array $values, $data) + { + return function ($value): string { + switch ($value) { + + case '_header': + return 'Requestor'; + + case 'participation': + return $this->translator->trans('is person concerned'); + + case 'other_person': + return $this->translator->trans('is other person'); + + case 'thirdparty': + return $this->translator->trans('is thirdparty'); + + case 'no_requestor': + return $this->translator->trans('no requestor'); + + default: + throw new \LogicException(sprintf('The value %s is not valid', $value)); + } + }; + } + + /** + * @inheritDoc + */ + public function getQueryKeys($data): array + { + return ['requestor_aggregator']; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + // no form + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Group by requestor'; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + /* + La requête va être différente par chaque regroupement. comment faire ? + + $qb + ->join('acp.requestorPerson','rp') + ->join('acp.requestorThirdParty','rt') + ->join('acp.participations', 'part') + ; + + $qb->addSelect('rp.id AS requestor_aggregator'); + */ + + $groupBy = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('requestor_aggregator'); + } else { + $qb->groupBy('requestor_aggregator'); + } + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index 2b578b4f9..1e313d59d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -213,6 +213,13 @@ services: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_administrative_location_aggregator } + chill.person.export.aggregator_requestor: + class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_requestor_aggregator } + chill.person.export.aggregator_confidential: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e105dd45f..e71db1a31 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -485,6 +485,7 @@ is other person: Le demandeur est un autre usager is thirdparty: Le demandeur est un tiers no requestor: Il n'y a pas de demandeur "Filtered by requestor: only %choice%": "Filtré par présence du demandeur au sein des usagers concernés: uniquement si %choice%" +Group by requestor: Grouper selon la nature du demandeur Filter by confidential: Filtrer les parcours par confidentialité Accepted confidentials: ''