mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
exports: create closingmotive filter
This commit is contained in:
parent
057617c1cb
commit
ef5b3b24e4
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter;
|
||||
|
||||
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;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
|
||||
class ClosingMotiveFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('accepted_closingmotives', EntityType::class, [
|
||||
'class' => ClosingMotive::class,
|
||||
'choice_label' => function (ClosingMotive $cm) {
|
||||
return $this->translatableStringHelper->localize($cm->getName());
|
||||
},
|
||||
'multiple' => false,
|
||||
'expanded' => false
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by closing motive';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'Filtered by closingmotive: only %closingmotive%', [
|
||||
'%closingmotive%' => $this->translatableStringHelper->localize(
|
||||
$data['accepted_closingmotives']->getName())
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
$clause = $qb->expr()->eq('acp.closingMotive', ':closingmotive');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('closingmotive', $data['accepted_closingmotives']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ class SocialIssueFilter implements FilterInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): QueryBuilder
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acp.socialIssues', 'si');
|
||||
|
||||
|
@ -67,4 +67,11 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_origin_filter }
|
||||
|
||||
chill.person.export.filter_closingmotive:
|
||||
class: Chill\PersonBundle\Export\Filter\ClosingMotiveFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter }
|
||||
|
||||
## Aggregators
|
@ -394,6 +394,10 @@ Filter by origin: Filtrer par origine du parcours
|
||||
Accepted origins: Origines
|
||||
"Filtered by origins: only %origin%": "Filtré par origine du parcours: uniquement %origin%"
|
||||
|
||||
Filter by closing motive: Filtrer par motif de fermeture
|
||||
Accepted closingmotives: Motifs de clôture
|
||||
"Filtered by closingmotive: only %closingmotive%": "Filtré par motif de clôture: uniquement %closingmotive%"
|
||||
|
||||
## aggregators
|
||||
Group people by nationality: Aggréger les personnes par nationalités
|
||||
Group by level: Grouper par niveau
|
||||
|
Loading…
x
Reference in New Issue
Block a user