diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php new file mode 100644 index 000000000..f33ce9c1e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/ConfidentialFilter.php @@ -0,0 +1,87 @@ + false, + 'is confidential' => true, + ]; + + private CONST DEFAULT_CHOICE = false; + + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('accepted_confidentials', ChoiceType::class, [ + 'choices' => self::CHOICES, + 'multiple' => false, + 'expanded' => true, + 'empty_data' => self::DEFAULT_CHOICE, + 'data' => self::DEFAULT_CHOICE, + ]); + } + + public function getTitle(): string + { + return 'Filter by confidential'; + } + + public function describeAction($data, $format = 'string'): array + { + dump($data, self::CHOICES); + //$choice = //array_flip(self::CHOICES)[$data['accepted_confidentials']]; + foreach (self::CHOICES as $k => $v) { + if ($v === $data['accepted_confidentials']) { + $choice = $k; + } + } + + return [ + 'Filtered by confidential: only %confidential%', [ + '%confidential%' => $this->translator->trans($choice) + ] + ]; + } + + public function addRole() + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->eq('acp.confidential', ':confidential'); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('confidential', $data['accepted_confidentials']); + } + + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml index d34512220..abaeffd8a 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_period.yaml @@ -74,4 +74,11 @@ services: tags: - { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter } + chill.person.export.filter_confidential: + class: Chill\PersonBundle\Export\Filter\ConfidentialFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: accompanyingcourse_confidential_filter } + ## Aggregators \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 51ca82ce6..75da040d0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -398,6 +398,12 @@ 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%" +Filter by confidential: Filtrer par confidentialité +Accepted confidentials: Choix possibles +is confidential: le parcours est confidentiel +is not confidential: le parcours n'est pas confidentiel +"Filtered by confidential: only %confidential%": "Filtré par confidentialité: uniquement si %confidential%" + ## aggregators Group people by nationality: Aggréger les personnes par nationalités Group by level: Grouper par niveau