diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php deleted file mode 100644 index 3c2befd75..000000000 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/FamilySituationFilter.php +++ /dev/null @@ -1,53 +0,0 @@ -add('date_calc', DateType::class, [ - 'label' => 'Family composition(s) at this time', - 'data' => new DateTime(), - ]); - } - - public function describeAction($data, $format = 'string') - { - return ['Filtered by person\'s family situation']; - } - - public function getTitle() - { - return 'Filter by person\'s family situation'; - } -} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php new file mode 100644 index 000000000..7a72179a8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php @@ -0,0 +1,98 @@ +translatableStringHelper = $translatableStringHelper; + } + + public function addRole() + { + return null; + } + + public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + + $clause = $qb->expr()->andX( + $qb->expr()->in('person.maritalStatus', ':maritalStatus'), + $qb->expr()->orX( + $qb->expr()->eq('person.maritalStatusDate', ':calc_date'), + $qb->expr()->isNull('person.maritalStatusDate') + ) + ); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('maritalStatus', $data['maritalStatus']); + $qb->setParameter('calc_date', $data['calc_date']); + } + + public function applyOn() + { + return Declarations::PERSON_TYPE; + } + + public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder) + { + $builder->add('maritalStatus', EntityType::class, [ + 'class' => MaritalStatus::class, + 'choice_label' => function (MaritalStatus $ms) { + return $this->translatableStringHelper->localize( + $ms->getName() + ); + }, + 'multiple' => true, + 'expanded' => true + ]); + + $builder->add('calc_date', ChillDateType::class, [ + 'label' => 'Marital status at this time', + 'data' => new DateTime(), + ]); + } + + public function describeAction($data, $format = 'string') + { + return ['Filtered by person\'s marital status']; + } + + public function getTitle() + { + return 'Filter by person\'s marital status'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml index ae8f90b78..fa1c8df8d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_person.yaml @@ -14,7 +14,7 @@ services: autoconfigure: true tags: - { name: chill.export, alias: count_person_with_accompanying_course } - + chill.person.export.list_person: class: Chill\PersonBundle\Export\Export\ListPerson autowire: true @@ -39,24 +39,24 @@ services: autoconfigure: true tags: - { name: chill.export_filter, alias: person_gender_filter } - + chill.person.export.filter_age: class: Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter autowire: true autoconfigure: true tags: - { name: chill.export_filter, alias: person_age_filter } - + chill.person.export.filter_birthdate: class: Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter tags: - { name: chill.export_filter, alias: person_birthdate_filter } - + chill.person.export.filter_deathdate: class: Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter tags: - { name: chill.export_filter, alias: person_deathdate_filter } - + chill.person.export.filter_dead_or_alive: class: Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter tags: @@ -68,7 +68,7 @@ services: autoconfigure: true tags: - { name: chill.export_filter, alias: person_nationality_filter } - + chill.person.export.filter_residential_address_at_user: class: Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter autowire: true @@ -83,6 +83,13 @@ services: tags: - { name: chill.export_filter, alias: person_residential_address_at_thirdparty_filter } + chill.person.export.filter_marital_status: + class: Chill\PersonBundle\Export\Filter\PersonFilters\MaritalStatusFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: person_marital_status_filter } + ## Aggregators chill.person.export.aggregator_nationality: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator @@ -90,35 +97,35 @@ services: autoconfigure: true tags: - { name: chill.export_aggregator, alias: person_nationality_aggregator } - + chill.person.export.aggregator_country_of_birth: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\CountryOfBirthAggregator autowire: true autoconfigure: true tags: - { name: chill.export_aggregator, alias: person_country_of_birth_aggregator } - + chill.person.export.aggregator_gender: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator autowire: true autoconfigure: true tags: - { name: chill.export_aggregator, alias: person_gender_aggregator } - + chill.person.export.aggregator_age: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator autowire: true autoconfigure: true tags: - { name: chill.export_aggregator, alias: person_age_aggregator } - + chill.person.export.aggregator_marital_status: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\MaritalStatusAggregator autowire: true autoconfigure: true tags: - { name: chill.export_aggregator, alias: person_marital_status_aggregator } - + chill.person.export.aggregator_household_position: class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\HouseholdPositionAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 511bb791f..dc32a2cae 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -400,6 +400,10 @@ Filtered by person\'s who have a residential address located at a thirdparty of Family composition: Composition familiale Family composition at this time: Composition familiale à cette date. +Filtered by person's marital status: Filtré par état matrimonial +Filter by person's marital status: Filtrer par état matrimonial +Marital status at this time: État matrimonial par rapport à cette date + Filter by entrusted child status: Filtrer les usagers qui sont "enfant confié" Filtered by entrusted child status: Uniquement les usagers qui sont "enfant confié"