diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php new file mode 100644 index 000000000..7069a1d80 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HavingAnAccompanyingPeriodInfoWithinDatesFilter.php @@ -0,0 +1,91 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.having_info_within_interval.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.course.having_info_within_interval.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.course.having_info_within_interval.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.having_info_within_interval.Only course with events between %startDate% and %endDate%', + [ + '%startDate%' => $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y'), + '%endDate%' => $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y'), + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $ai = 'having_ai_within_interval_acc_info'; + $as = 'having_ai_within_interval_start_date'; + $ae = 'having_ai_within_interval_end_date'; + + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM ' . AccompanyingPeriodInfo::class . " {$ai} WHERE {$ai}.infoDate BETWEEN :{$as} AND :{$ae} AND IDENTITY({$ai}.accompanyingPeriod) = acp.id" + ) + ) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date']), Types::DATETIME_IMMUTABLE) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date']), Types::DATETIME_IMMUTABLE); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php new file mode 100644 index 000000000..586bb645d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -0,0 +1,88 @@ +add('users', PickUserDynamicType::class, [ + 'multiple' => true, + ]); + } + + public function getTitle(): string + { + return 'export.filter.course.by_user_working.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [ + '%users%' => implode( + ', ', + array_map( + fn (User $u) => $this->userRender->renderString($u, []), + $data['users'] + ) + ), + ], + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $qb + ->andWhere( + $qb->expr()->exists( + "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " . + "WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id" + ) + ) + ->setParameter(self::AI_USERS, $data['users']) + ; + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index bb2cfa556..adde8d336 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -128,6 +128,13 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_creator_job_filter } + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserWorkingOnCourseFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_user_working_on_filter } + + Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HavingAnAccompanyingPeriodInfoWithinDatesFilter: + tags: + - { name: chill.export_filter, alias: accompanyingcourse_info_within_filter } ## Aggregators chill.person.export.aggregator_referrer_scope: diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 0cdc9e601..9b9f1fde2 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1076,6 +1076,14 @@ export: Status: Statut course: + having_info_within_interval: + title: Filter les parcours ayant reçu une intervention entre deux dates + start_date: Début de la période + end_date: Fin de la période + Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate% + by_user_working: + title: Filter les parcours par intervenant + 'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%' by_step: date_calc: Date de prise en compte du statut by_user_scope: