diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php new file mode 100644 index 000000000..4c2183a7a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -0,0 +1,85 @@ + 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; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports.yaml b/src/Bundle/ChillPersonBundle/config/services/exports.yaml index 4cf752870..e58ba3ef5 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports.yaml @@ -61,19 +61,24 @@ services: chill.person.export.filter_userscope: class: Chill\PersonBundle\Export\Filter\UserScopeFilter - arguments: - $translator: '@translator' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + autowire: true + autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } chill.person.export.filter_userjob: class: Chill\PersonBundle\Export\Filter\UserJobFilter - arguments: - $translator: '@translator' - $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + autowire: true + autoconfigure: true tags: - { 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: class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7939a083d..42b6e6840 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -384,6 +384,10 @@ Filter by user job: Filtrer par métier du référent Accepted userjob: Métiers "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 Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau @@ -536,9 +540,9 @@ occasional: ponctuel regular: régulier Confidential: confidentiel confidential: confidentiel -Draft: brouillon -Confirmed: en file active -Closed: Cloturé +Draft: Brouillon +Confirmed: En file active +Closed: Clôturé # Accompanying Course Accompanying Course: Parcours d'accompagnement