mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
chill-bundles#25: replace ChillDateType by PickRollingDateType
batch/serial replacing untested
This commit is contained in:
@@ -12,12 +12,21 @@ declare(strict_types=1);
|
||||
namespace Chill\ReportBundle\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use DateTime;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
|
||||
class ReportDateFilter implements FilterInterface
|
||||
{
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
public function __construct(
|
||||
RollingDateConverterInterface $rollingDateConverter
|
||||
) {
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
@@ -39,8 +48,12 @@ class ReportDateFilter implements FilterInterface
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('report_date_filter_date_from', $data['date_from']);
|
||||
$qb->setParameter('report_date_filter_date_to', $data['date_to']);
|
||||
$qb->setParameter('report_date_filter_date_from',
|
||||
$this->rollingDateConverter->convert($data['date_from'])
|
||||
);
|
||||
$qb->setParameter('report_date_filter_date_to',
|
||||
$this->rollingDateConverter->convert($data['date_to'])
|
||||
);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
@@ -50,14 +63,14 @@ class ReportDateFilter implements FilterInterface
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', ChillDateType::class, [
|
||||
$builder->add('date_from', PickRollingDateType::class, [
|
||||
'label' => 'Report is after this date',
|
||||
'data' => new DateTime(),
|
||||
'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
]);
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, [
|
||||
$builder->add('date_to', PickRollingDateType::class, [
|
||||
'label' => 'Report is before this date',
|
||||
'data' => new DateTime(),
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -65,8 +78,8 @@ class ReportDateFilter implements FilterInterface
|
||||
{
|
||||
return ['Filtered by report\'s date: '
|
||||
. 'between %date_from% and %date_to%', [
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||
'%date_from%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
|
||||
'%date_to%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
|
||||
], ];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user