diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index 45fddd9c1..d40170447 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -12,9 +12,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\EvaluationFilters; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; +use DateTime; class ByEndDateFilter implements FilterInterface { @@ -26,10 +29,9 @@ class ByEndDateFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $qb - ->andWhere( - $qb->expr()->in('', ':') - ) - ->setParameter('', $data[]); + ->andWhere('workeval.endDate IS BETWEEN :start_date and :end_date') + ->setParameter('start_date', $data['start_date'], Types::DATE_IMMUTABLE) + ->setParameter('end_date', $data['end_date'], Types::DATE_IMMUTABLE); } public function applyOn(): string @@ -39,12 +41,22 @@ class ByEndDateFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add(); + $builder + ->add('start_date', ChillDateType::class, [ + 'label' => 'start period date', + 'data' => new DateTime(), + ]) + ->add('end_date', ChillDateType::class, [ + 'label' => 'end period date', + 'data' => new DateTime(), + ]); } public function describeAction($data, $format = 'string'): array { - return ['', [ + return ['Filtered by end date: between %start_date% and %end_date%', [ + '%start_date%' => $data['start_date']->format('d-m-Y'), + '%end_date%' => $data['end_date']->format('d-m-Y'), ]]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7bd0294b8..3e3ec4a2c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -569,11 +569,11 @@ Group by current actions: Grouper les actions en cours Current action: Actions en cours Not current action: Actions terminées Filter by start date evaluations: Filtrer les évaluations par date de début +Filter by end date evaluations: Filtrer les évaluations par date de fin start period date: Date de début de la période end period date: Date de fin de la période -"Filtered by start date: between %start_date% and %end_date%": "Filtré par la date de début: entre %start_date% et %end_date%" -Filter by end date evaluations: Filtrer les évaluations par date de fin -Filter by max date evaluations: Filtrer les évaluations par date d'échéance +"Filtered by start date: between %start_date% and %end_date%": "Filtré par la date de début: comprise entre %start_date% et %end_date%" +"Filtered by end date: between %start_date% and %end_date%": "Filtré par la date de fin: comprise entre %start_date% et %end_date%" Filter by current evaluations: Filtrer les évaluations en cours Group by start date evaluations: Grouper les évaluations par semaine/mois/année de la date de début Group by end date evaluations: Grouper les évaluations par semaine/mois/année de la date de fin