diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php new file mode 100644 index 000000000..ec15be45f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -0,0 +1,82 @@ +maritalStatusRepository = $maritalStatusRepository; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb->join('person.maritalStatus', 'ms'); + $qb->addSelect('ms.id as marital_status_aggregator'); + + $groupBy = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('marital_status_aggregator'); + } else { + $qb->groupBy('marital_status_aggregator'); + } + } + + public function applyOn() + { + return Declarations::PERSON_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Marital status'; + } + + $g = $this->maritalStatusRepository->find($value); + + return $g->getName()['fr']; + }; + } + + public function getQueryKeys($data) + { + return ['marital_status_aggregator']; + } + + public function getTitle() + { + return 'Group people by marital status'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ProfessionalSitutaionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ProfessionalSitutaionAggregator.php new file mode 100644 index 000000000..0ee31d4fe --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ProfessionalSitutaionAggregator.php @@ -0,0 +1,86 @@ +professionalSituationRepository = $professionalSituationRepository; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $qb->resetDQLPart('from'); + $qb->from('App:VendeePerson', 'vp'); + $qb->join('vp.person', 'person'); + $qb->join('person.center', 'center'); + + $qb->join('vp.situationProfessionelle', 'sp'); + $qb->addSelect('sp.id as professional_situation_aggregator'); + + $groupBy = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('professional_situation_aggregator'); + } else { + $qb->groupBy('professional_situation_aggregator'); + } + } + + public function applyOn() + { + return Declarations::PERSON_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + } + + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Professional situation'; + } + + $g = $this->professionalSituationRepository->find($value); + + return $g->getName()['fr']; + }; + } + + public function getQueryKeys($data) + { + return ['professional_situation_aggregator']; + } + + public function getTitle() + { + return 'Group people by their professional situation'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/EntrustedChildFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/EntrustedChildFilter.php index 8d886f146..ce09901b7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/EntrustedChildFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/EntrustedChildFilter.php @@ -1,5 +1,5 @@