mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
export new administrative location filter
This commit is contained in:
parent
4794e5e7b5
commit
6e439adce2
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Location;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class AdministrativeLocationFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TranslatableStringHelper $translatableStringHelper
|
||||||
|
) {
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_locations', EntityType::class, [
|
||||||
|
'class' => Location::class,
|
||||||
|
'choice_label' => function (Location $l) {
|
||||||
|
return $l->getName() .' ('. $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')';
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter by administrative location';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$locations = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_locations'] as $l) {
|
||||||
|
$locations[] = $l->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered by administratives locations: only %locations%', [
|
||||||
|
'%locations%' => implode(", ou ", $locations)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->in('acp.administrativeLocation', ':locations');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('locations', $data['accepted_locations']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -95,6 +95,13 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter }
|
||||||
|
|
||||||
|
chill.person.export.filter_administrative_location:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\AdministrativeLocationFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_administrative_location_filter }
|
||||||
|
|
||||||
chill.person.export.filter_confidential:
|
chill.person.export.filter_confidential:
|
||||||
class: Chill\PersonBundle\Export\Filter\ConfidentialFilter
|
class: Chill\PersonBundle\Export\Filter\ConfidentialFilter
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -410,6 +410,10 @@ Filter by closing motive: Filtrer par motif de fermeture
|
|||||||
Accepted closingmotives: Motifs de clôture
|
Accepted closingmotives: Motifs de clôture
|
||||||
"Filtered by closingmotive: only %closingmotives%": "Filtré par motif de clôture: uniquement %closingmotives%"
|
"Filtered by closingmotive: only %closingmotives%": "Filtré par motif de clôture: uniquement %closingmotives%"
|
||||||
|
|
||||||
|
Filter by administrative location: Filtrer par localisation administrative
|
||||||
|
Accepted locations: Localisations administratives
|
||||||
|
"Filtered by administratives locations: only %locations%": "Filtré par localisation administrative: uniquement %locations%"
|
||||||
|
|
||||||
Filter by confidential: Filtrer par confidentialité
|
Filter by confidential: Filtrer par confidentialité
|
||||||
Accepted confidentials: ''
|
Accepted confidentials: ''
|
||||||
is confidential: le parcours est confidentiel
|
is confidential: le parcours est confidentiel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user