diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php new file mode 100644 index 000000000..b13c49e9a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkEndDateBetweenDateFilter.php @@ -0,0 +1,114 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.end_between_dates.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.end_between_dates.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('keep_null', CheckboxType::class, [ + 'label' => 'export.filter.work.end_between_dates.keep_null', + 'help' => 'export.filter.work.end_between_dates.keep_null_help', + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.work.end_between_dates.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.work.end_between_dates.Only where end date is between %endDate% and %endDate%', + [ + '%startDate%' => null !== $data['start_date'] ? $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y') : '', + '%endDate%' => null !== $data['end_date'] ? $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y') : '', + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $as = 'acc_pe_work_end_between_filter_start'; + $ae = 'acc_pe_work_end_between_filter_end'; + + $start = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->lte('acpw.endDate', ':'.$ae), + $qb->expr()->isNull('acpw.endDate') + ), + false => $qb->expr()->andX( + $qb->expr()->lte('acpw.endDate', ':'.$ae), + $qb->expr()->isNotNull('acpw.endDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + $end = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->gt('acpw.endDate', ':'.$as), + $qb->expr()->isNull('acpw.endDate') + ), + false => $qb->expr()->andX( + $qb->expr()->gt('acpw.endDate', ':'.$as), + $qb->expr()->isNotNull('acpw.endDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + + if (null !== $data['start_date']) { + $qb + ->andWhere($start) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date'])); + } + + if (null !== $data['end_date']) { + $qb + ->andWhere($end) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date'])); + } + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php new file mode 100644 index 000000000..e9526a9a5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/AccompanyingPeriodWorkStartDateBetweenDateFilter.php @@ -0,0 +1,114 @@ +add('start_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.start_between_dates.start_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('end_date', PickRollingDateType::class, [ + 'label' => 'export.filter.work.start_between_dates.end_date', + 'data' => new RollingDate(RollingDate::T_TODAY), + ]) + ->add('keep_null', CheckboxType::class, [ + 'label' => 'export.filter.work.start_between_dates.keep_null', + 'help' => 'export.filter.work.start_between_dates.keep_null_help', + ]) + ; + } + + public function getTitle(): string + { + return 'export.filter.work.start_between_dates.title'; + } + + public function describeAction($data, $format = 'string'): array + { + return [ + 'export.filter.work.start_between_dates.Only where start date is between %startDate% and %endDate%', + [ + '%startDate%' => null !== $data['start_date'] ? $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y') : '', + '%endDate%' => null !== $data['end_date'] ? $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y') : '', + ] + ]; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data): void + { + $as = 'acc_pe_work_start_between_filter_start'; + $ae = 'acc_pe_work_start_between_filter_end'; + + $start = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->lte('acpw.startDate', ':'.$ae), + $qb->expr()->isNull('acpw.startDate') + ), + false => $qb->expr()->andX( + $qb->expr()->lte('acpw.startDate', ':'.$ae), + $qb->expr()->isNotNull('acpw.startDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + $end = match ($data['keep_null']) { + true => $qb->expr()->orX( + $qb->expr()->gt('acpw.startDate', ':'.$as), + $qb->expr()->isNull('acpw.startDate') + ), + false => $qb->expr()->andX( + $qb->expr()->gt('acpw.startDate', ':'.$as), + $qb->expr()->isNotNull('acpw.startDate') + ), + default => throw new \LogicException("This value is not supported"), + }; + + if (null !== $data['start_date']) { + $qb + ->andWhere($start) + ->setParameter($as, $this->rollingDateConverter->convert($data['start_date'])); + } + + if (null !== $data['end_date']) { + $qb + ->andWhere($end) + ->setParameter($ae, $this->rollingDateConverter->convert($data['end_date'])); + } + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index ecf0ec399..5f6c2690d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -48,7 +48,19 @@ services: tags: - { name: chill.export_filter, alias: social_work_actions_current_filter } - ## AGGREGATORS + Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkStartDateBetweenDateFilter: + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_actions_start_btw_dates_filter } + + Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkEndDateBetweenDateFilter: + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_actions_end_btw_dates_filter } + + ## AGGREGATORS chill.person.export.aggregator_action_type: class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 9b9f1fde2..341136f65 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1097,6 +1097,21 @@ export: Calculation date: Date de la localisation creator_job: 'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%' + work: + start_between_dates: + title: Filtre les actions d'accompagnement dont la date d'ouverture est entre deux dates + start_date: Date de début + end_date: Date de fin + keep_null: Conserver les actions dont la date de début n'est pas indiquée + keep_null_help: Si coché, les actions dont la date de début est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée. + Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de début est entre le %startDate% et le %endDate% + end_between_dates: + title: Filtre les actions d'accompagnement dont la date de clotûre est entre deux dates (ou l'action est toujours ouverte) + start_date: Date de début + end_date: Date de fin + keep_null: Conserver les actions dont la date de fin n'est pas indiquée (actions en cours) + keep_null_help: Si coché, les actions dont la date de fin est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée. + Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de fin est entre le %startDate% et le %endDate% list: person_with_acp: List peoples having an accompanying period: Liste des usagers ayant un parcours d'accompagnement