mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add filter for courses not linked to a reference address
This commit introduces a new filter to the Accompanying Course section. It allows users to filter for courses that are not associated with a reference address. The accompanying test and translation changes are also included in this update.
This commit is contained in:
parent
9ba557a5bf
commit
950835c10b
5
.changes/unreleased/Feature-20240207-114629.yaml
Normal file
5
.changes/unreleased/Feature-20240207-114629.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: 'Export: add filter for courses not linked to a reference address'
|
||||||
|
time: 2024-02-07T11:46:29.491027007+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "243"
|
@ -0,0 +1,99 @@
|
|||||||
|
<?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\AccompanyingCourseFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Address;
|
||||||
|
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\Entity\Household\PersonHouseholdAddress;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
final readonly class NotAssociatedWithAReferenceAddressFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private RollingDateConverterInterface $rollingDateConverter,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'export.filter.course.not_having_address_reference.title';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('date_calc', PickRollingDateType::class, [
|
||||||
|
'label' => 'export.filter.course.not_having_address_reference.adress_at',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormDefaultData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'exports.filter.course.not_having_address_reference.describe',
|
||||||
|
[
|
||||||
|
'date_calc' => $this->rollingDateConverter->convert($data['date_calc']),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$k = 'acp_not_associated_ref_filter';
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->leftJoin(
|
||||||
|
'acp.locationHistories',
|
||||||
|
$k,
|
||||||
|
Join::WITH,
|
||||||
|
"{$k}.period = acp AND {$k}.startDate <= :{$k}_date_calc AND ({$k}.endDate IS NULL OR {$k}.endDate > :{$k}_date_calc)"
|
||||||
|
)
|
||||||
|
->leftJoin(
|
||||||
|
PersonHouseholdAddress::class,
|
||||||
|
"{$k}_p_address",
|
||||||
|
Join::WITH,
|
||||||
|
"{$k}.personLocation = {$k}_p_address.person AND {$k}_p_address.validFrom <= :{$k}_date_calc AND ({$k}_p_address.validTo IS NULL OR {$k}_p_address.validTo > :{$k}_date_calc)"
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
Address::class,
|
||||||
|
"{$k}_address",
|
||||||
|
Join::WITH,
|
||||||
|
"{$k}_address.id = COALESCE(IDENTITY({$k}_p_address.address), IDENTITY({$k}.addressLocation))"
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
$qb->andWhere("{$k}_address.addressReference IS NULL");
|
||||||
|
$qb->setParameter("{$k}_date_calc", $this->rollingDateConverter->convert($data['date_calc']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Tests\Export\Filter\AccompanyingCourseFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\NotAssociatedWithAReferenceAddressFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
class NotAssociatedWithAReferenceAddressFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
$dateConverter = new class () implements RollingDateConverterInterface {
|
||||||
|
public function convert(?RollingDate $rollingDate): ?\DateTimeImmutable
|
||||||
|
{
|
||||||
|
if (null === $rollingDate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new \DateTimeImmutable('now');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new NotAssociatedWithAReferenceAddressFilter($dateConverter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders()
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('acp.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -147,6 +147,10 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_info_within_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_info_within_filter }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\NotAssociatedWithAReferenceAddressFilter:
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_not_having_addr_reference_filter }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
chill.person.export.aggregator_referrer_scope:
|
chill.person.export.aggregator_referrer_scope:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator
|
||||||
|
@ -140,6 +140,11 @@ 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:
|
||||||
|
not_having_address_reference:
|
||||||
|
describe: >-
|
||||||
|
Uniquement les parcours qui ne sont pas localisés à une adresse de référence, à la date du {date_calc, date, medium}
|
||||||
|
|
||||||
'total persons matching the search pattern': >-
|
'total persons matching the search pattern': >-
|
||||||
{ total, plural,
|
{ total, plural,
|
||||||
=0 {Aucun usager ne correspond aux termes de recherche}
|
=0 {Aucun usager ne correspond aux termes de recherche}
|
||||||
|
@ -1153,6 +1153,9 @@ export:
|
|||||||
'Filtered by participations during period: between %dateafter% and %datebefore%': 'Filtré par personne concerné par un parcours dans la periode entre: %dateafter% et %datebefore%'
|
'Filtered by participations during period: between %dateafter% and %datebefore%': 'Filtré par personne concerné par un parcours dans la periode entre: %dateafter% et %datebefore%'
|
||||||
|
|
||||||
course:
|
course:
|
||||||
|
not_having_address_reference:
|
||||||
|
title: Filtrer les parcours non localisés à une adresse de réference
|
||||||
|
adress_at: Adresse à la date du
|
||||||
having_info_within_interval:
|
having_info_within_interval:
|
||||||
title: Filtrer les parcours ayant reçu une intervention entre deux dates
|
title: Filtrer les parcours ayant reçu une intervention entre deux dates
|
||||||
start_date: Début de la période
|
start_date: Début de la période
|
||||||
|
Loading…
x
Reference in New Issue
Block a user