Fixed: fix date's type in DateType input, and prevent collision on

parameter name
This commit is contained in:
Julien Fastré 2022-11-02 13:14:48 +01:00
parent abd79df8cd
commit d6b358cfa1

View File

@ -15,7 +15,7 @@ use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory; use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
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;
@ -33,15 +33,15 @@ class HasNoReferrerFilter implements FilterInterface
->andWhere(' ->andWhere('
NOT EXISTS ( NOT EXISTS (
SELECT 1 FROM ' . UserHistory::class . ' uh SELECT 1 FROM ' . UserHistory::class . ' uh
WHERE uh.startDate < :date WHERE uh.startDate <= :has_no_referrer_filter_date
AND ( AND (
uh.endDate IS NULL uh.endDate IS NULL
or uh.endDate > :date or uh.endDate > :has_no_referrer_filter_date
) )
AND uh.accompanyingPeriod = acp AND uh.accompanyingPeriod = acp
) )
') ')
->setParameter('date', $data['calc_date'], Types::DATE_IMMUTABLE); ->setParameter('has_no_referrer_filter_date', $data['calc_date'], Types::DATE_IMMUTABLE);
} }
public function applyOn(): string public function applyOn(): string
@ -54,7 +54,8 @@ class HasNoReferrerFilter implements FilterInterface
$builder $builder
->add('calc_date', ChillDateType::class, [ ->add('calc_date', ChillDateType::class, [
'label' => 'Has no referrer on this date', 'label' => 'Has no referrer on this date',
'data' => new DateTime(), 'data' => new DateTimeImmutable(),
'input' => 'datetime_immutable',
]); ]);
} }