diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php index b41347026..e6c56f11e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilter.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; -use Chill\CustomFieldsBundle\Form\Type\ChoicesType; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Export\FilterInterface; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php new file mode 100644 index 000000000..de84d5877 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php @@ -0,0 +1,103 @@ + true, + 'is not specified' => false, + ]; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('maxdate', ChoiceType::class, [ + 'choices' => self::MAXDATE_CHOICES, + 'multiple' => false, + 'expanded' => true + ]); + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Filter by maxdate'; + } + + /** + * @inheritDoc + */ + public function describeAction($data, $format = 'string'): array + { + foreach (self::MAXDATE_CHOICES as $k => $v) { + if ($v === $data['maxdate']) { + $choice = $k; + } + } + + return ['Filtered by maxdate: only %choice%', [ + '%choice%' => $this->translator->trans($choice) + ]]; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + + if ($data['maxdate'] === true) { + $clause = $qb->expr()->isNotNull('eval.maxDate'); + } else { + $clause = $qb->expr()->isNull('eval.maxDate'); + } + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + + dump($data['maxdate']); + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::EVAL_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml index 92d9cfd3d..e21e0b6c1 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml @@ -16,6 +16,13 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_evaluationtype_filter } + chill.person.export.filter_maxdate: + class: Chill\PersonBundle\Export\Filter\EvaluationFilters\MaxDateFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_maxdate_filter } + ## Aggregators chill.person.export.aggregator_evaluationtype: class: Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\EvaluationTypeAggregator diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7ef7cc107..af21991d3 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -521,6 +521,12 @@ Accepted evaluationtype: Évaluations Group by evaluation type: Grouper par type d'évaluation Evaluation type: Type d'évaluation +Filter by maxdate: Filtrer par date d'échéance +Maxdate: '' +is specified: La date d'échéance est spécifiée +is not specified: La date d'échéance n'est pas spécifiée +"Filtered by maxdate: only %choice%": "Filtré par date d'échéance: uniquement si %choice%" + ## aggregators Group people by nationality: Grouper les personnes par nationalités Group by level: Grouper par niveau