mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[export] add a filter and aggregator on accompanying period work: group/filter by handling third party
This commit is contained in:
parent
f799fe0649
commit
a4edb34668
6
.changes/unreleased/Feature-20231018-133203.yaml
Normal file
6
.changes/unreleased/Feature-20231018-133203.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
kind: Feature
|
||||
body: '[export] add a filter and aggregator on accompanying period work: group/filter
|
||||
by handling third party'
|
||||
time: 2023-10-18T13:32:03.565201495+02:00
|
||||
custom:
|
||||
Issue: "172"
|
@ -0,0 +1,73 @@
|
||||
<?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\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregatorTest;
|
||||
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @see HandlingThirdPartyAggregatorTest
|
||||
*/
|
||||
final readonly class HandlingThirdPartyAggregator implements AggregatorInterface
|
||||
{
|
||||
private const PREFIX = 'acpw_handling3party_agg';
|
||||
|
||||
public function __construct(private LabelThirdPartyHelper $labelThirdPartyHelper) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form needed here
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, mixed $data)
|
||||
{
|
||||
return $this->labelThirdPartyHelper->getLabel($key, $values, 'export.aggregator.course_work.by_handling_third_party.header');
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::PREFIX.'_h3party'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course_work.by_handling_third_party.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->addSelect("IDENTITY(acpw.handlingThierParty) AS {$p}_h3party")
|
||||
->addGroupBy("{$p}_h3party");
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
<?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\Export\FilterInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class HandlingThirdPartyFilter implements FilterInterface
|
||||
{
|
||||
private const PREFIX = 'acpw_handling_3party_filter';
|
||||
|
||||
public function __construct(
|
||||
private ThirdPartyRender $thirdPartyRender,
|
||||
) {}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.filter.work.by_handling3party.title';
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('handling_3parties', PickThirdpartyDynamicType::class, [
|
||||
'label' => 'export.filter.work.by_handling3party.pick_3parties',
|
||||
'multiple' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['handling_3parties' => []];
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'export.filter.work.by_handling3party.Only 3 parties %3parties%',
|
||||
[
|
||||
'%3parties%' => implode(
|
||||
', ',
|
||||
array_map(fn (ThirdParty $thirdParty) => $this->thirdPartyRender->renderString($thirdParty, []), $data['handling_3parties'])
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb->andWhere("acpw.handlingThierParty IN (:{$p}_3ps)");
|
||||
$qb->setParameter("{$p}_3ps", $data['handling_3parties']);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<?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\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class HandlingThirdPartyAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
private static HandlingThirdPartyAggregator $handlingThirdPartyAggregator;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
self::bootKernel();
|
||||
self::$handlingThirdPartyAggregator = self::$container->get(HandlingThirdPartyAggregator::class);
|
||||
}
|
||||
|
||||
public function getAggregator()
|
||||
{
|
||||
return self::$handlingThirdPartyAggregator;
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container
|
||||
->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(acpw.id)')
|
||||
->from(AccompanyingPeriodWork::class, 'acpw'),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?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\SocialWorkFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HandlingThirdPartyFilter;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class HandlingThirdPartyFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
self::bootKernel();
|
||||
$this->thirdPartyRender = self::$container->get(ThirdPartyRender::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return new HandlingThirdPartyFilter($this->thirdPartyRender);
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$thirdParties = $em->createQuery('SELECT tp FROM '.ThirdParty::class.' tp')
|
||||
->setMaxResults(2)
|
||||
->getResult();
|
||||
|
||||
return [
|
||||
[
|
||||
'handling_3parties' => $thirdParties,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('acpw.id')
|
||||
->from(AccompanyingPeriodWork::class, 'acpw'),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,116 +1,93 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
## Indicators
|
||||
Chill\PersonBundle\Export\Export\CountAccompanyingPeriodWork:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: count_social_work_actions }
|
||||
|
||||
Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWork:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: list_social_work_actions }
|
||||
|
||||
## FILTERS
|
||||
chill.person.export.filter_social_work_type:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_type_filter }
|
||||
|
||||
chill.person.export.filter_scope:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_scope_filter }
|
||||
|
||||
chill.person.export.filter_job:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\JobFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_job_filter }
|
||||
|
||||
chill.person.export.filter_treatingagent:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ReferrerFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_treatingagent_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\SocialWorkFilters\CurrentActionFilter:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_current_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkStartDateBetweenDateFilter:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_start_btw_dates_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\SocialWorkFilters\AccompanyingPeriodWorkEndDateBetweenDateFilter:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_end_btw_dates_filter }
|
||||
|
||||
## AGGREGATORS
|
||||
chill.person.export.aggregator_action_type:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_action_type_aggregator }
|
||||
|
||||
chill.person.export.aggregator_treatingagent_scope:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ScopeAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_scope_aggregator }
|
||||
|
||||
chill.person.export.aggregator_treatingagent_job:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\JobAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_job_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_treatingagent_aggregator }
|
||||
|
||||
chill.person.export.aggregator_goal:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_goal_aggregator }
|
||||
|
||||
chill.person.export.aggregator_result:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_result_aggregator }
|
||||
|
||||
chill.person.export.aggregator_goalresult:
|
||||
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalResultAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_goal_result_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CurrentActionAggregator:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: social_work_actions_current_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_handling3party_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HandlingThirdPartyFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: 'acpw_handling3party_filter'}
|
||||
|
@ -1066,6 +1066,9 @@ export:
|
||||
by_agent_job:
|
||||
Group by treating agent job: Grouper les actions par métier de l'agent traitant
|
||||
Calc date: Date de calcul du métier de l'agent traitant
|
||||
by_handling_third_party:
|
||||
title: Grouper les actions par tiers traitant
|
||||
header: Tiers traitant
|
||||
|
||||
eval:
|
||||
by_end_date:
|
||||
@ -1181,6 +1184,10 @@ export:
|
||||
Calc date: Date à laquelle l'agent est en situation de désignation sur l'action
|
||||
calc_date_help: Il s'agit de la date à laquelle l'agent est actif comme agent traitant de l'action, et non la date à la quelle l'agent est désigné comme agent traitant.
|
||||
"Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%"
|
||||
by_handling3party:
|
||||
title: Filtrer les actions par tiers traitant
|
||||
Only 3 parties %3parties%: "Seulement les actions d'accompagnement qui ont pour tiers traitant: %3parties%"
|
||||
pick_3parties: Tiers traitants des actions
|
||||
|
||||
list:
|
||||
person_with_acp:
|
||||
|
@ -25,7 +25,7 @@ class LabelThirdPartyHelper
|
||||
return $header;
|
||||
}
|
||||
|
||||
if (null === $value || null === $thirdParty = $this->thirdPartyRepository->find($value)) {
|
||||
if ('' === $value || null === $value || null === $thirdParty = $this->thirdPartyRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user