ByStartDateFilter evaluation

This commit is contained in:
Mathieu Jaumotte 2022-10-31 15:46:29 +01:00
parent d48474bbc9
commit e3846829e1
2 changed files with 21 additions and 6 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 ByStartDateFilter implements FilterInterface
{
@ -26,10 +29,9 @@ class ByStartDateFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
->andWhere('workeval.startDate 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 ByStartDateFilter 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 start 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'),
]];
}

View File

@ -569,6 +569,9 @@ 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
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
Filter by current evaluations: Filtrer les évaluations en cours