HasNoReferrer filter

This commit is contained in:
Mathieu Jaumotte 2022-10-31 15:32:34 +01:00 committed by Julien Fastré
parent a18870c91e
commit bc41910a39
2 changed files with 25 additions and 6 deletions

View File

@ -12,9 +12,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use DateTime;
class HasNoReferrerFilter implements FilterInterface
{
@ -26,10 +30,18 @@ class HasNoReferrerFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
->andWhere('
NOT EXISTS (
SELECT 1 FROM '. UserHistory::class .' uh
WHERE uh.startDate < :date
AND (
uh.endDate IS NULL
or uh.endDate > :date
)
AND uh.accompanyingPeriod = acp
)
')
->setParameter('date', $data['calc_date'], Types::DATE_IMMUTABLE);
}
public function applyOn(): string
@ -39,12 +51,17 @@ class HasNoReferrerFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
$builder
->add('calc_date', ChillDateType::class, [
'label' => 'Has no referrer on this date',
'data' => new DateTime(),
]);
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
return ['Filtered acp which has no referrer on date: %date%', [
'%date%' => $data['calc_date']->format('d-m-Y'),
]];
}

View File

@ -554,6 +554,8 @@ Date to: Date de fin
Filter by temporary location: Filtrer les parcours avec une localisation temporaire
Filter by which has no referrer: Filtrer les parcours sans référent
"Filtered acp which has no referrer on date: %date%": "Filtré les parcours sans référent à cette date: %date%"
Has no referrer on this date: N'a pas de référent à cette date
Filter by which has no action: Filtrer les parcours qui nont pas dactions
Filtered acp which has no actions: Filtré les parcours qui n'ont pas d'actions
Group by number of actions: Grouper les parcours par nombre dactions