mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
exports: add new step filter
This commit is contained in:
parent
7f1dadc136
commit
b608976326
85
src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php
Normal file
85
src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class StepFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
private const STEPS = [
|
||||||
|
'Draft' => AccompanyingPeriod::STEP_DRAFT,
|
||||||
|
'Confirmed' => AccompanyingPeriod::STEP_CONFIRMED,
|
||||||
|
'Closed' => AccompanyingPeriod::STEP_CLOSED,
|
||||||
|
];
|
||||||
|
|
||||||
|
private const DEFAULT_CHOICE = AccompanyingPeriod::STEP_CONFIRMED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_step', ChoiceType::class, [
|
||||||
|
'choices' => self::STEPS,
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true,
|
||||||
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
|
'data' => self::DEFAULT_CHOICE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'Filter by step';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
$step = array_flip(self::STEPS)[$data['accepted_step']];
|
||||||
|
|
||||||
|
return ["Filtered by steps: only %step%", [
|
||||||
|
'%step%' => $this->translator->trans($step)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->eq('acp.step', ':step');
|
||||||
|
|
||||||
|
// override original where clause
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('step', $data['accepted_step']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -61,20 +61,25 @@ services:
|
|||||||
|
|
||||||
chill.person.export.filter_userscope:
|
chill.person.export.filter_userscope:
|
||||||
class: Chill\PersonBundle\Export\Filter\UserScopeFilter
|
class: Chill\PersonBundle\Export\Filter\UserScopeFilter
|
||||||
arguments:
|
autowire: true
|
||||||
$translator: '@translator'
|
autoconfigure: true
|
||||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_userscope_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_userscope_filter }
|
||||||
|
|
||||||
chill.person.export.filter_userjob:
|
chill.person.export.filter_userjob:
|
||||||
class: Chill\PersonBundle\Export\Filter\UserJobFilter
|
class: Chill\PersonBundle\Export\Filter\UserJobFilter
|
||||||
arguments:
|
autowire: true
|
||||||
$translator: '@translator'
|
autoconfigure: true
|
||||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_userjob_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_userjob_filter }
|
||||||
|
|
||||||
|
chill.person.export.filter_step:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\StepFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_step_filter }
|
||||||
|
|
||||||
chill.person.export.aggregator_nationality:
|
chill.person.export.aggregator_nationality:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator
|
class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -384,6 +384,10 @@ Filter by user job: Filtrer par métier du référent
|
|||||||
Accepted userjob: Métiers
|
Accepted userjob: Métiers
|
||||||
"Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%"
|
"Filtered by user jobs: only %jobs%": "Filtré par métier du référent: uniquement %jobs%"
|
||||||
|
|
||||||
|
Filter by step: Filtrer par statut du parcours
|
||||||
|
Accepted step: Statuts
|
||||||
|
"Filtered by steps: only %step%": "Filtré par statut du parcours: uniquement %step%"
|
||||||
|
|
||||||
## aggregators
|
## aggregators
|
||||||
Group people by nationality: Aggréger les personnes par nationalités
|
Group people by nationality: Aggréger les personnes par nationalités
|
||||||
Group by level: Grouper par niveau
|
Group by level: Grouper par niveau
|
||||||
@ -536,9 +540,9 @@ occasional: ponctuel
|
|||||||
regular: régulier
|
regular: régulier
|
||||||
Confidential: confidentiel
|
Confidential: confidentiel
|
||||||
confidential: confidentiel
|
confidential: confidentiel
|
||||||
Draft: brouillon
|
Draft: Brouillon
|
||||||
Confirmed: en file active
|
Confirmed: En file active
|
||||||
Closed: Cloturé
|
Closed: Clôturé
|
||||||
|
|
||||||
# Accompanying Course
|
# Accompanying Course
|
||||||
Accompanying Course: Parcours d'accompagnement
|
Accompanying Course: Parcours d'accompagnement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user