ByEndDateFilter evaluation

This commit is contained in:
2022-10-31 15:51:35 +01:00
parent e3846829e1
commit 791ea25e4f
2 changed files with 21 additions and 9 deletions

View File

@@ -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'),
]];
}