diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOnDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOnDateFilter.php new file mode 100644 index 000000000..0d83bce13 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOnDateFilter.php @@ -0,0 +1,87 @@ +add('on_date', ChillDateType::class, [ + 'data' => new DateTime(), + ]) + ; + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Filtered by active on date'; + } + + /** + * @inheritDoc + */ + public function describeAction($data, $format = 'string'): array + { + return ['Filtered by actives courses: active on %ondate%', [ + '%ondate%' => $data['on_date']->format('d-m-Y') + ]]; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + + $clause = $qb->expr()->andX( + $qb->expr()->lte('acp.openingDate', ':ondate'), + $qb->expr()->orX( + $qb->expr()->gt('acp.closingDate', ':ondate'), + $qb->expr()->isNull('acp.closingDate') + ) + ); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOneDayBetweenDatesFilter.php index 6f6ef1197..0054018d1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ActiveOneDayBetweenDatesFilter.php @@ -40,7 +40,7 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface /** * @inheritDoc */ - public function describeAction($data, $format = 'string') + public function describeAction($data, $format = 'string'): array { return ['Filtered by actives courses: at least one day between %datefrom% and %dateto%', [ '%datefrom%' => $data['date_from']->format('d-m-Y'), diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/OpenBetweenDatesFilter.php index ef829bdfa..2c3514f92 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/OpenBetweenDatesFilter.php @@ -40,7 +40,7 @@ class OpenBetweenDatesFilter implements FilterInterface /** * @inheritDoc */ - public function describeAction($data, $format = 'string') + public function describeAction($data, $format = 'string'): array { return ['Filtered by opening dates: between %datefrom% and %dateto%', [ '%datefrom%' => $data['date_from']->format('d-m-Y'), diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index 20131dc59..fb10e775f 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -95,6 +95,13 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_intensity_filter } + chill.person.export.filter_activeondate: + class: Chill\PersonBundle\Export\Filter\ActiveOnDateFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_activeondate_filter } + chill.person.export.filter_activeonedaybetweendates: class: Chill\PersonBundle\Export\Filter\ActiveOneDayBetweenDatesFilter autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index f047a6804..0f65dcf6c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -428,6 +428,10 @@ Date to: Date de fin Filtered by active at least one day between dates: Filtrer les parcours actifs au moins un jour dans la période "Filtered by actives courses: at least one day between %datefrom% and %dateto%": "Filtrer les parcours actifs: au moins un jour entre le %datefrom% et le %dateto%" +Filtered by active on date: Filtrer les parcours actifs à une date +On date: Actifs à cette date +"Filtered by actives courses: active on %ondate%": "Filtrer les parcours actifs: actifs le %ondate%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau