diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php similarity index 78% rename from src/Bundle/ChillPersonBundle/Export/Filter/ReferrerFilter.php rename to src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index 7d2a3dbb9..89b306678 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -1,6 +1,6 @@ getDQLPart('where'); - - switch ($qb->getRootAlias()) { - - case 'acp': - $clause = $qb->expr()->in('acp.user', ':referrers'); - break; - - case 'acpw': - $qb->join('acpw.referrers', 'r'); - $clause = $qb->expr()->in('r', ':referrers'); - break; - - default: - throw new \Exception("Does not apply on that base entity"); - } + $clause = $qb->expr()->in('acp.user', ':referrers'); if ($where instanceof Andx) { $where->add($clause); @@ -107,6 +93,6 @@ class ReferrerFilter implements FilterInterface */ public function applyOn(): string { - return Declarations::ACP_SHARED; + return Declarations::ACP_TYPE; } } \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php new file mode 100644 index 000000000..1ca1d39d2 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php @@ -0,0 +1,100 @@ +userRender = $userRender; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_agents', EntityType::class, [ + 'class' => User::class, + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => true, + 'expanded' => true + ]); + + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Filter by treating agent'; + } + + /** + * @inheritDoc + */ + public function describeAction($data, $format = 'string'): array + { + $users = []; + + foreach ($data['accepted_agents'] as $r) { + $users[] = $r; + } + + return [ + 'Filtered by treating agent: only %agents%', [ + '%agents' => implode(", ou ", $users) + ]]; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + $qb->join('acpw.referrers', 'u'); + + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->in('u', ':agents'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('agents', $data['accepted_agents']); + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_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 592df7573..a48081d21 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -136,7 +136,7 @@ services: - { name: chill.export_filter, alias: accompanyingcourse_activeonedaybetweendates_filter } chill.person.export.filter_referrer: - class: Chill\PersonBundle\Export\Filter\ReferrerFilter + class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter autowire: true autoconfigure: true tags: diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index 266b8db75..08b3893da 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -29,6 +29,13 @@ services: autoconfigure: true tags: - { name: chill.export_filter, alias: social_work_actions_job_filter } + + chill.person.export.filter_treating_agent: + class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ReferrerFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_actions_referrer_filter } ## AGGREGATORS chill.person.export.aggregator_action_type: diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 3d899719e..9812a9293 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -508,11 +508,16 @@ On date: Actifs à cette date Filter 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 referrers: Filtrer par référent +Filter by referrers: Filtrer par référent Accepted referrers: Référents "Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%" Group by referrers: Grouper par référent +Filter by treating agent: Filtrer par agent traitant +Accepted agents: Agent traitant +"Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%" +Group by treating agent: Grouper par agent traitant + Filter by opened between dates: Filtrer les parcours ouverts entre deux dates Date from: Date de début Date to: Date de fin