From a0fc9d4de5996b497c231f7d52d1b6fc6afcb0b3 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 31 Oct 2022 11:43:41 +0100 Subject: [PATCH] SocialWork: Current actions filter + aggregator --- .../CurrentActionAggregator.php | 17 ++++++++++++++++- .../SocialWorkFilters/CurrentActionFilter.php | 11 +++-------- .../translations/messages.fr.yml | 3 +++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php index 9a9c56afc..219aaf9cd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CurrentActionAggregator.php @@ -25,7 +25,11 @@ class CurrentActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->addSelect('AS acpw_current_action_aggregator') + $qb + ->addSelect(' + (CASE true WHEN acpw.startDate IS NULL ELSE false END) + AS acpw_current_action_aggregator + ') ->addGroupBy('acpw_current_action_aggregator'); } @@ -45,6 +49,17 @@ class CurrentActionAggregator implements AggregatorInterface if ('_header' === $value) { return ''; } + switch ($value) { + case true: + return 'Current action'; + + case false: + return 'Not current action'; + + default: + throw new \LogicException(sprintf('The value %s is not valid', $value)); + } + }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php index c77f9c662..ecbe6086a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CurrentActionFilter.php @@ -25,11 +25,7 @@ class CurrentActionFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb - ->andWhere( - $qb->expr()->in('', ':') - ) - ->setParameter('', $data[]); + $qb->andWhere('acpw.startDate IS NULL'); } public function applyOn(): string @@ -39,13 +35,12 @@ class CurrentActionFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add(); + //no form } public function describeAction($data, $format = 'string'): array { - return ['', [ - ]]; + return ['Filtered by current action']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index be47a06c2..1be565938 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -562,7 +562,10 @@ Filter by creator job: Filtrer les parcours par métier du créateur Group by creator job: Grouper les parcours par métier du créateur Filter by current actions: Filtrer les actions en cours +Filtered by current action: Filtré les actions en cours Group by current actions: Grouper les actions en cours +Current action: Actions en cours +Not current action: Actions terminées Filter by start date evaluations: Filtrer les évaluations par date de début Filter by end date evaluations: Filtrer les évaluations par date de fin Filter by max date evaluations: Filtrer les évaluations par date d'échéance