Feature: [export][evaluation] add by end date filter

This commit is contained in:
Julien Fastré 2022-11-02 15:56:48 +01:00
parent d8104c4443
commit 2d40c38c88

View File

@ -14,7 +14,7 @@ namespace Chill\PersonBundle\Export\Filter\EvaluationFilters;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use DateTime; use DateTimeImmutable;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@ -26,12 +26,12 @@ class ByEndDateFilter implements FilterInterface
return null; return null;
} }
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data): void
{ {
$qb $qb
->andWhere('workeval.endDate IS BETWEEN :start_date and :end_date') ->andWhere('workeval.endDate BETWEEN :work_eval_by_end_date_start_date and :work_eval_by_end_date_end_date')
->setParameter('start_date', $data['start_date'], Types::DATE_IMMUTABLE) ->setParameter('work_eval_by_end_date_start_date', $data['start_date'], Types::DATE_IMMUTABLE)
->setParameter('end_date', $data['end_date'], Types::DATE_IMMUTABLE); ->setParameter('work_eval_by_end_date_end_date', $data['end_date'], Types::DATE_IMMUTABLE);
} }
public function applyOn(): string public function applyOn(): string
@ -39,16 +39,18 @@ class ByEndDateFilter implements FilterInterface
return Declarations::EVAL_TYPE; return Declarations::EVAL_TYPE;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder): void
{ {
$builder $builder
->add('start_date', ChillDateType::class, [ ->add('start_date', ChillDateType::class, [
'label' => 'start period date', 'label' => 'start period date',
'data' => new DateTime(), 'data' => new DateTimeImmutable('1 year ago'),
'input' => 'datetime_immutable',
]) ])
->add('end_date', ChillDateType::class, [ ->add('end_date', ChillDateType::class, [
'label' => 'end period date', 'label' => 'end period date',
'data' => new DateTime(), 'data' => new DateTimeImmutable(),
'input' => 'datetime_immutable',
]); ]);
} }