mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add ByDateFilter and its test for AccompanyingPeriodStepHistoryFilters
A new filter called ByDateFilter has been added under AccompanyingPeriodStepHistoryFilters. This filter allows users to filter data based on a date range on the start date. Corresponding unit tests for ByDateFilter are included in this commit. Both English and French translations for the new filter are also added.
This commit is contained in:
parent
b6ea857389
commit
44ccfe92b6
@ -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\AccompanyingPeriodStepHistoryFilters;
|
||||||
|
|
||||||
|
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\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByDateFilterTest;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ByDateFilter
|
||||||
|
* Implements the FilterInterface.
|
||||||
|
*
|
||||||
|
* This class represents a filter that filters data based on a date range on the start date.
|
||||||
|
* It allows the user to select a start date and an end date to filter the data.
|
||||||
|
*
|
||||||
|
* @see ByDateFilterTest
|
||||||
|
*/
|
||||||
|
final readonly class ByDateFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private RollingDateConverterInterface $rollingDateConverter
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'export.filter.step_history.by_date.title';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('start_date', PickRollingDateType::class, [
|
||||||
|
'label' => 'export.filter.step_history.by_date.start_date_label',
|
||||||
|
])
|
||||||
|
->add('end_date', PickRollingDateType::class, [
|
||||||
|
'label' => 'export.filter.step_history.by_date.end_date_label',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormDefaultData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||||
|
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'exports.filter.step_history.by_date.description',
|
||||||
|
[
|
||||||
|
'start_date' => $this->rollingDateConverter->convert($data['start_date']),
|
||||||
|
'end_date' => $this->rollingDateConverter->convert($data['end_date']),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$startDate = 'acp_step_history_by_date_start_filter';
|
||||||
|
$endDate = 'acp_step_history_by_date_end_filter';
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->andWhere(
|
||||||
|
"acpstephistory.startDate >= :{$startDate} AND (acpstephistory.endDate < :{$endDate} OR acpstephistory.endDate IS NULL)"
|
||||||
|
)
|
||||||
|
->setParameter($startDate, $this->rollingDateConverter->convert($data['start_date']))
|
||||||
|
->setParameter($endDate, $this->rollingDateConverter->convert($data['end_date']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return Declarations::ACP_STEP_HISTORY;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||||
|
use Chill\PersonBundle\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByDateFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
class ByDateFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private RollingDateConverterInterface $rollingDateConverter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return new ByDateFilter($this->rollingDateConverter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||||
|
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders()
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$qb = $em->createQueryBuilder()
|
||||||
|
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
|
||||||
|
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
|
||||||
|
->join('acpstephistory.period', 'acp');
|
||||||
|
|
||||||
|
return [
|
||||||
|
$qb,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -140,7 +140,12 @@ exports:
|
|||||||
by_treating_agent:
|
by_treating_agent:
|
||||||
Filtered by treating agent at date: >-
|
Filtered by treating agent at date: >-
|
||||||
Les agents traitant au { agent_at, date, medium }, seulement {agents}
|
Les agents traitant au { agent_at, date, medium }, seulement {agents}
|
||||||
course:
|
|
||||||
|
step_history:
|
||||||
|
by_date:
|
||||||
|
description: >-
|
||||||
|
Changements de statuts filtrés par date: après le { start_date, date, medium } (inclus), avant le { end_date, date, medium }
|
||||||
|
|
||||||
not_having_address_reference:
|
not_having_address_reference:
|
||||||
describe: >-
|
describe: >-
|
||||||
Uniquement les parcours qui ne sont pas localisés à une adresse de référence, à la date du {date_calc, date, medium}
|
Uniquement les parcours qui ne sont pas localisés à une adresse de référence, à la date du {date_calc, date, medium}
|
||||||
|
@ -1131,6 +1131,13 @@ export:
|
|||||||
by_geog_unit:
|
by_geog_unit:
|
||||||
Filtered by person's geographical unit (based on address) computed at %datecalc%, only %units%: Filtré par unité géographique (sur base de l'adresse), calculé le %datecalc%, seulement %units%
|
Filtered by person's geographical unit (based on address) computed at %datecalc%, only %units%: Filtré par unité géographique (sur base de l'adresse), calculé le %datecalc%, seulement %units%
|
||||||
|
|
||||||
|
step_history:
|
||||||
|
by_closing_motive
|
||||||
|
by_date:
|
||||||
|
title: Filtrer les changements de statut du parcours par date
|
||||||
|
start_date_label: Changements après le
|
||||||
|
end_date_label: Changements avant le
|
||||||
|
|
||||||
person:
|
person:
|
||||||
by_composition:
|
by_composition:
|
||||||
Filter by household composition: Filtrer les usagers par composition du ménage
|
Filter by household composition: Filtrer les usagers par composition du ménage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user