mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: add new requestor aggregator
This commit is contained in:
parent
d86b86487f
commit
436f1d6c61
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* les regroupements suivants seront effecturés:
|
||||
* - le demandeur est un usager concerné
|
||||
* - le demander est un usager, mais non concerné
|
||||
* - le demandeur est un tiers
|
||||
* - le parcours ne comporte pas de demandeur
|
||||
*/
|
||||
class RequestorAggregator implements AggregatorInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
switch ($value) {
|
||||
|
||||
case '_header':
|
||||
return 'Requestor';
|
||||
|
||||
case 'participation':
|
||||
return $this->translator->trans('is person concerned');
|
||||
|
||||
case 'other_person':
|
||||
return $this->translator->trans('is other person');
|
||||
|
||||
case 'thirdparty':
|
||||
return $this->translator->trans('is thirdparty');
|
||||
|
||||
case 'no_requestor':
|
||||
return $this->translator->trans('no requestor');
|
||||
|
||||
default:
|
||||
throw new \LogicException(sprintf('The value %s is not valid', $value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['requestor_aggregator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by requestor';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
/*
|
||||
La requête va être différente par chaque regroupement. comment faire ?
|
||||
|
||||
$qb
|
||||
->join('acp.requestorPerson','rp')
|
||||
->join('acp.requestorThirdParty','rt')
|
||||
->join('acp.participations', 'part')
|
||||
;
|
||||
|
||||
$qb->addSelect('rp.id AS requestor_aggregator');
|
||||
*/
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('requestor_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('requestor_aggregator');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@ -213,6 +213,13 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_administrative_location_aggregator }
|
||||
|
||||
chill.person.export.aggregator_requestor:
|
||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_requestor_aggregator }
|
||||
|
||||
chill.person.export.aggregator_confidential:
|
||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator
|
||||
autowire: true
|
||||
|
@ -485,6 +485,7 @@ is other person: Le demandeur est un autre usager
|
||||
is thirdparty: Le demandeur est un tiers
|
||||
no requestor: Il n'y a pas de demandeur
|
||||
"Filtered by requestor: only %choice%": "Filtré par présence du demandeur au sein des usagers concernés: uniquement si %choice%"
|
||||
Group by requestor: Grouper selon la nature du demandeur
|
||||
|
||||
Filter by confidential: Filtrer les parcours par confidentialité
|
||||
Accepted confidentials: ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user