mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Feature: Apply rolling "open between dates filters" (accompanying period)
This commit is contained in:
parent
48da6d0a92
commit
8aeeab9e6b
@ -12,15 +12,23 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use DateTime;
|
|
||||||
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;
|
||||||
|
|
||||||
class OpenBetweenDatesFilter implements FilterInterface
|
class OpenBetweenDatesFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
|
private RollingDateConverterInterface $rollingDateConverter;
|
||||||
|
|
||||||
|
public function __construct(RollingDateConverterInterface $rollingDateConverter)
|
||||||
|
{
|
||||||
|
$this->rollingDateConverter = $rollingDateConverter;
|
||||||
|
}
|
||||||
|
|
||||||
public function addRole(): ?string
|
public function addRole(): ?string
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -34,8 +42,8 @@ class OpenBetweenDatesFilter implements FilterInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$qb->andWhere($clause);
|
$qb->andWhere($clause);
|
||||||
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
|
$qb->setParameter('datefrom', $this->rollingDateConverter->convert($data['date_from']), Types::DATE_IMMUTABLE);
|
||||||
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
|
$qb->setParameter('dateto', $this->rollingDateConverter->convert($data['date_to']), Types::DATE_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -46,19 +54,19 @@ class OpenBetweenDatesFilter implements FilterInterface
|
|||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('date_from', ChillDateType::class, [
|
->add('date_from', PickRollingDateType::class, [
|
||||||
'data' => new DateTime(),
|
'data' => new RollingDate(RollingDate::T_MONTH_PREVIOUS_START),
|
||||||
])
|
])
|
||||||
->add('date_to', ChillDateType::class, [
|
->add('date_to', PickRollingDateType::class, [
|
||||||
'data' => new DateTime(),
|
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string'): array
|
public function describeAction($data, $format = 'string'): array
|
||||||
{
|
{
|
||||||
return ['Filtered by opening dates: between %datefrom% and %dateto%', [
|
return ['Filtered by opening dates: between %datefrom% and %dateto%', [
|
||||||
'%datefrom%' => $data['date_from']->format('d-m-Y'),
|
'%datefrom%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
|
||||||
'%dateto%' => $data['date_to']->format('d-m-Y'),
|
'%dateto%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user