From a3cae28613e16fd6b6f2020b3cb82a28fca53426 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 9 Aug 2022 16:14:01 +0200 Subject: [PATCH] residential address at thirdparty filter : not done! --- .../ResidentialAddressAtThirdpartyFilter.php | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php new file mode 100644 index 000000000..83f09bb0d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -0,0 +1,87 @@ +add('thirdparty_type', EntityType::class, [ + 'class' => ThirdPartyCategory::class, + 'choice_label' => function (ThirdPartyCategory $tpc) { + return $this->translatableStringHelper->localize($tpc->getName()); + }, + 'multiple' => true, + 'expanded' => true + ]); + + $builder->add('date_calc', ChillDateType::class, [ + 'label' => 'Date during which residential address was valid', + 'data' => new DateTime('now'), + ]); + } + + public function alterQuery(QueryBuilder $qb, $data) + { + + //TODO: Query is not finished... not clear what 'catégorie' corresponds with. Cannot get values to appear in table thirdparty_category + $qb->resetDQLPart('from'); + $qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra'); + + $qb->join('ra.person', 'person'); + $qb->join('person.center', 'center'); + $qb->join('ra.hostThirdparty', 'thirdparty'); + + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->andX( + $qb->expr()->isNotNull('ra.hostThirdparty'), + // $qb->expr()->in('thirdparty.categories') + ); + + if ($where instanceof Expr\Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + } + + public function applyOn() + { + return Declarations::PERSON_TYPE; + } + + + public function describeAction($data, $format = 'string') + { + return ['Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%']; + } + + public function getTitle() + { + return 'Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%'; + } +} \ No newline at end of file