marital status filter

This commit is contained in:
Julie Lenaerts 2022-09-06 10:04:59 +02:00
parent 8688e4d502
commit 3295031bcd
3 changed files with 39 additions and 18 deletions

View File

@ -13,6 +13,8 @@ namespace Chill\PersonBundle\Export\Filter\PersonFilters;
use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
@ -20,9 +22,18 @@ use DateTime;
use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\Query\Expr\Andx;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Contracts\Translation\TranslatorInterface;
class MaritalStatusFilter implements FilterInterface class MaritalStatusFilter implements FilterInterface
{ {
private TranslatableStringHelper $translatableStringHelper;
public function __construct(
TranslatableStringHelper $translatableStringHelper
) {
$this->translatableStringHelper = $translatableStringHelper;
}
public function addRole() public function addRole()
{ {
return null; return null;
@ -33,8 +44,11 @@ class MaritalStatusFilter implements FilterInterface
$where = $qb->getDQLPart('where'); $where = $qb->getDQLPart('where');
$clause = $qb->expr()->andX( $clause = $qb->expr()->andX(
$qb->expr()->in('p.maritalStatus', ':maritalStatus'), $qb->expr()->in('person.maritalStatus', ':maritalStatus'),
$qb->expr()->eq('p.maritalStatusDate', ':calc_date') $qb->expr()->orX(
$qb->expr()->eq('person.maritalStatusDate', ':calc_date'),
$qb->expr()->isNull('person.maritalStatusDate')
)
); );
if ($where instanceof Andx) { if ($where instanceof Andx) {
@ -45,7 +59,7 @@ class MaritalStatusFilter implements FilterInterface
$qb->add('where', $where); $qb->add('where', $where);
$qb->setParameter('maritalStatus', $data['maritalStatus']); $qb->setParameter('maritalStatus', $data['maritalStatus']);
$qb->setParameter('maritalStatusDate', $data['calc_date']); $qb->setParameter('calc_date', $data['calc_date']);
} }
public function applyOn() public function applyOn()
@ -59,14 +73,14 @@ class MaritalStatusFilter implements FilterInterface
'class' => MaritalStatus::class, 'class' => MaritalStatus::class,
'choice_label' => function (MaritalStatus $ms) { 'choice_label' => function (MaritalStatus $ms) {
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(
$ms->getLabel() $ms->getName()
); );
}, },
'multiple' => true, 'multiple' => true,
'expanded' => true 'expanded' => true
]); ]);
$builder->add('date_calc', DateType::class, [ $builder->add('calc_date', ChillDateType::class, [
'label' => 'Marital status at this time', 'label' => 'Marital status at this time',
'data' => new DateTime(), 'data' => new DateTime(),
]); ]);

View File

@ -14,7 +14,7 @@ services:
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export, alias: count_person_with_accompanying_course } - { name: chill.export, alias: count_person_with_accompanying_course }
chill.person.export.list_person: chill.person.export.list_person:
class: Chill\PersonBundle\Export\Export\ListPerson class: Chill\PersonBundle\Export\Export\ListPerson
autowire: true autowire: true
@ -39,24 +39,24 @@ services:
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: person_gender_filter } - { name: chill.export_filter, alias: person_gender_filter }
chill.person.export.filter_age: chill.person.export.filter_age:
class: Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter class: Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: person_age_filter } - { name: chill.export_filter, alias: person_age_filter }
chill.person.export.filter_birthdate: chill.person.export.filter_birthdate:
class: Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter class: Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter
tags: tags:
- { name: chill.export_filter, alias: person_birthdate_filter } - { name: chill.export_filter, alias: person_birthdate_filter }
chill.person.export.filter_deathdate: chill.person.export.filter_deathdate:
class: Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter class: Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter
tags: tags:
- { name: chill.export_filter, alias: person_deathdate_filter } - { name: chill.export_filter, alias: person_deathdate_filter }
chill.person.export.filter_dead_or_alive: chill.person.export.filter_dead_or_alive:
class: Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter class: Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter
tags: tags:
@ -68,7 +68,7 @@ services:
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: person_nationality_filter } - { name: chill.export_filter, alias: person_nationality_filter }
chill.person.export.filter_residential_address_at_user: chill.person.export.filter_residential_address_at_user:
class: Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter class: Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter
autowire: true autowire: true
@ -83,6 +83,13 @@ services:
tags: tags:
- { name: chill.export_filter, alias: person_residential_address_at_thirdparty_filter } - { 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 ## Aggregators
chill.person.export.aggregator_nationality: chill.person.export.aggregator_nationality:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator
@ -90,35 +97,35 @@ services:
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: person_nationality_aggregator } - { name: chill.export_aggregator, alias: person_nationality_aggregator }
chill.person.export.aggregator_country_of_birth: chill.person.export.aggregator_country_of_birth:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\CountryOfBirthAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\CountryOfBirthAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: person_country_of_birth_aggregator } - { name: chill.export_aggregator, alias: person_country_of_birth_aggregator }
chill.person.export.aggregator_gender: chill.person.export.aggregator_gender:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: person_gender_aggregator } - { name: chill.export_aggregator, alias: person_gender_aggregator }
chill.person.export.aggregator_age: chill.person.export.aggregator_age:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: person_age_aggregator } - { name: chill.export_aggregator, alias: person_age_aggregator }
chill.person.export.aggregator_marital_status: chill.person.export.aggregator_marital_status:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\MaritalStatusAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\MaritalStatusAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: person_marital_status_aggregator } - { name: chill.export_aggregator, alias: person_marital_status_aggregator }
chill.person.export.aggregator_household_position: chill.person.export.aggregator_household_position:
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\HouseholdPositionAggregator class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\HouseholdPositionAggregator
autowire: true autowire: true

View File

@ -401,8 +401,8 @@ Family composition: Composition familiale
Family composition at this time: Composition familiale à cette date. Family composition at this time: Composition familiale à cette date.
Filtered by person's marital status: Filtré par état matrimonial Filtered by person's marital status: Filtré par état matrimonial
Filter by person's marital status: Filtrer par état matrimonial à une certaine date. Filter by person's marital status: Filtrer par état matrimonial
Marital status at this time: État matrimonial à cette date. Marital status at this time: État matrimonial par rapport à cette date
Filter by entrusted child status: Filtrer les usagers qui sont "enfant confié" Filter by entrusted child status: Filtrer les usagers qui sont "enfant confié"
Filtered by entrusted child status: Uniquement les usagers qui sont "enfant confié" Filtered by entrusted child status: Uniquement les usagers qui sont "enfant confié"