mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: [address reference] add a filter to filter person by ref status
This commit is contained in:
parent
f256dda6fe
commit
adc80d5080
@ -38,7 +38,7 @@ class RollingDateDataMapper implements DataMapperInterface
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
$viewData = new RollingDate(
|
||||
$forms['roll']->getData(),
|
||||
($forms['roll']->getData() ?? RollingDate::T_TODAY),
|
||||
$forms['fixedDate']->getData()
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||
{
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
RollingDateConverterInterface $rollingDateConverter
|
||||
) {
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$subQuery =
|
||||
'SELECT 1
|
||||
FROM ' . PersonHouseholdAddress::class . ' person_filter_having_address_to_review_person_household_address
|
||||
JOIN person_filter_having_address_to_review_person_household_address.address person_filter_having_address_to_review_address
|
||||
WHERE
|
||||
person_filter_having_address_to_review_person_household_address.validFrom <= :person_filter_having_address_to_review_date
|
||||
AND
|
||||
(person_filter_having_address_to_review_person_household_address.validTo IS NULL
|
||||
OR person_filter_having_address_to_review_person_household_address.validTo > :person_filter_having_address_to_review_date)
|
||||
AND
|
||||
person_filter_having_address_to_review_person_household_address.person = person
|
||||
AND person_filter_having_address_to_review_address.refStatus IN (:person_filter_having_address_to_review_ref_statuses)
|
||||
';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists($subQuery)
|
||||
)
|
||||
->setParameter(
|
||||
'person_filter_having_address_to_review_date',
|
||||
$this->rollingDateConverter->convert($data['date_calc'] ?? RollingDate::T_TODAY)
|
||||
)
|
||||
->setParameter('person_filter_having_address_to_review_ref_statuses', $data['ref_statuses'] ?? [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', PickRollingDateType::class, [
|
||||
'label' => 'Compute address at date',
|
||||
'required' => true,
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
])
|
||||
->add('ref_statuses', ChoiceType::class, [
|
||||
'label' => 'export.filter.person.by_address_ref_status.Status',
|
||||
'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH],
|
||||
'choice_label' => function (string $item) {
|
||||
return 'export.filter.person.by_address_ref_status.'.$item;
|
||||
},
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'export.filter.person.by_address_ref_status.Filtered by person\'s address status computed at %datecalc%, only %statuses%',
|
||||
[
|
||||
'%datecalc%' => $this->rollingDateConverter->convert($data['date_calc'])->format('Y-m-d'),
|
||||
'%statuses%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
function (string $item) {
|
||||
return 'export.filter.person.by_address_ref_status.'.$item;
|
||||
},
|
||||
$data['ref_statuses'] ?? RollingDate::T_TODAY
|
||||
)
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.person.by_address_ref_status.Filter by person\'s address ref status';
|
||||
}
|
||||
}
|
@ -110,6 +110,12 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_geog_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\PersonFilters\AddressRefStatusFilter:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_address_ref_status_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\PersonFilters\ByHouseholdCompositionFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_by_household_composition_filter }
|
||||
|
@ -1061,6 +1061,13 @@ export:
|
||||
Filter persons without household composition: Filtrer les personnes sans composition de ménage (ni ménage)
|
||||
Persons filtered by no composition at %date%: Uniquement les personnes sans composition de ménage à la date du %date%
|
||||
Date calc: Date de calcul
|
||||
by_address_ref_status:
|
||||
Filter by person's address ref status: Filtrer par comparaison avec l'adresse de référence
|
||||
to_review: Diffère de l'adresse de référence
|
||||
reviewed: Diffère de l'adresse de référence mais conservé par l'utilisateur
|
||||
match: Identique à l'adresse de référence
|
||||
Filtered by person\'s address status computed at %datecalc%, only %statuses%: Filtré par comparaison à l'adresse de référence, calculé à %datecalc%, seulement %statuses%
|
||||
Status: Statut
|
||||
|
||||
course:
|
||||
by_user_scope:
|
||||
|
Loading…
x
Reference in New Issue
Block a user