mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add WithParticipationBetweenDatesFilter to ChillPersonBundle
This update adds a new filter, WithParticipationBetweenDatesFilter, to the ChillPersonBundle. This filter helps to find persons who participated in any parcours between specified date ranges. Additionally, relevant French translations have been updated and the filter has been registered in the services configuration file.
This commit is contained in:
parent
d1ce99e6d3
commit
5b2a2a1bc5
@ -0,0 +1,96 @@
|
||||
<?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\ActivityBundle\Entity\Activity;
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
final readonly class WithParticipationBetweenDatesFilter implements FilterInterface
|
||||
{
|
||||
public function __construct(
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = 'with_participation_between_dates_filter';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class." {$p}_acpp ".
|
||||
"WHERE {$p}_acpp.person = person ".
|
||||
"AND OVERLAPSI (acpp.startDate, acpp.endDate), (:{$p}_date_after), :{$p}_date_before)) = 'TRUE' ")
|
||||
)
|
||||
->setParameter("{$p}_date_after", $this->rollingDateConverter->convert($data['date_after']), Types::DATE_IMMUTABLE)
|
||||
->setParameter("{$p}_date_before", $this->rollingDateConverter->convert($data['date_before']), Types::DATE_IMMUTABLE);
|
||||
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_after', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.person.with_participation_between_dates.date_after',
|
||||
]);
|
||||
|
||||
$builder->add('date_before', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.person.with_participation_between_dates.date_before',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'date_after' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
'date_before' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return ['Filtered by participations during period: between %dateafter% and %datebefore%', [
|
||||
'%dateafter%' => $this->rollingDateConverter->convert($data['date_after'])->format('d-m-Y'),
|
||||
'%datebefore%' => $this->rollingDateConverter->convert($data['date_before'])->format('d-m-Y'),
|
||||
]];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.filter.person.with_participation_between_dates.title';
|
||||
}
|
||||
|
||||
}
|
@ -116,6 +116,10 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_without_household_composition_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\PersonFilters\WithParticipationBetweenDatesFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_with_participation_between_dates_filter }
|
||||
|
||||
## Aggregators
|
||||
chill.person.export.aggregator_nationality:
|
||||
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator
|
||||
|
@ -1142,6 +1142,10 @@ export:
|
||||
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
|
||||
Address at date: Adresse à la date
|
||||
with_participation_between_dates:
|
||||
date_after: Concerné par un parcours après le
|
||||
date_before: Concerné par un parcours avant le
|
||||
title: Filtrer les usagers ayant été associés à un parcours ouverts un jour dans la période de temps indiquée
|
||||
|
||||
course:
|
||||
having_info_within_interval:
|
||||
|
Loading…
x
Reference in New Issue
Block a user