mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
exports: add new AdministrativeLocation aggregator
This commit is contained in:
parent
ec7325ebbd
commit
ace2cb6151
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Location;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Chill\MainBundle\Repository\LocationRepository;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class AdministrativeLocationAggregator implements AggregatorInterface
|
||||||
|
{
|
||||||
|
private LocationRepository $locationRepository;
|
||||||
|
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
LocationRepository $locationRepository,
|
||||||
|
TranslatableStringHelper $translatableStringHelper
|
||||||
|
) {
|
||||||
|
$this->locationRepository = $locationRepository;
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
return function ($value): string {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'Administrative location';
|
||||||
|
}
|
||||||
|
|
||||||
|
$l = $this->locationRepository->find($value);
|
||||||
|
|
||||||
|
return $l->getName() .' ('. $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getQueryKeys($data): array
|
||||||
|
{
|
||||||
|
return ['location_aggregator'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
// no form
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'Group by administrative location';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$qb->join('acp.administrativeLocation', 'al');
|
||||||
|
|
||||||
|
$qb->addSelect('IDENTITY(acp.administrativeLocation) AS location_aggregator');
|
||||||
|
|
||||||
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
if (!empty($groupBy)) {
|
||||||
|
$qb->addGroupBy('location_aggregator');
|
||||||
|
} else {
|
||||||
|
$qb->groupBy('location_aggregator');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -205,3 +205,10 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: accompanyingcourse_closingmotive_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_closingmotive_aggregator }
|
||||||
|
|
||||||
|
chill.person.export.aggregator_administrative_location:
|
||||||
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\AdministrativeLocationAggregator
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_aggregator, alias: accompanyingcourse_administrative_location_aggregator }
|
||||||
|
@ -457,7 +457,9 @@ Group by closing motive: Grouper par motif de fermeture
|
|||||||
|
|
||||||
Filter by administrative location: Filtrer par localisation administrative
|
Filter by administrative location: Filtrer par localisation administrative
|
||||||
Accepted locations: Localisations administratives
|
Accepted locations: Localisations administratives
|
||||||
|
Administrative location: Localisation administrative
|
||||||
"Filtered by administratives locations: only %locations%": "Filtré par localisation administrative: uniquement %locations%"
|
"Filtered by administratives locations: only %locations%": "Filtré par localisation administrative: uniquement %locations%"
|
||||||
|
Group by administrative location: Grouper par localisation administrative
|
||||||
|
|
||||||
Filter by requestor: Filtrer les parcours selon la présence du demandeur au sein des usagers concernés
|
Filter by requestor: Filtrer les parcours selon la présence du demandeur au sein des usagers concernés
|
||||||
Accepted choices: ''
|
Accepted choices: ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user