mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
exports: add new OpenBetweenDates filter
This commit is contained in:
parent
dd06a262a2
commit
7677b8aaa0
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class OpenBetweenDatesFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('date_from', ChillDateType::class, [
|
||||||
|
'data' => new DateTime(),
|
||||||
|
])
|
||||||
|
->add('date_to', ChillDateType::class, [
|
||||||
|
'data' => new DateTime(),
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filtered by opened between dates';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return ['Filtered by opening dates: between %datefrom% and %dateto%', [
|
||||||
|
'%datefrom%' => $data['date_from']->format('d-m-Y'),
|
||||||
|
'%dateto%' => $data['date_to']->format('d-m-Y'),
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->lt('acp.openingDate', ':datefrom'),
|
||||||
|
$qb->expr()->gt('acp.closingDate', ':dateto')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
|
||||||
|
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -102,4 +102,13 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_referrer_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_referrer_filter }
|
||||||
|
|
||||||
|
chill.person.export.filter_openbetweendates:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\OpenBetweenDatesFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_openbetweendates_filter }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
@ -420,6 +420,10 @@ Filtered by referrers: Filtrer par référent
|
|||||||
Accepted referrers: Référents
|
Accepted referrers: Référents
|
||||||
"Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%"
|
"Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%"
|
||||||
|
|
||||||
|
Filtered by opened between dates: Filtrer les parcours ouverts entre deux dates
|
||||||
|
Date from: Date de début
|
||||||
|
Date to: Date de fin
|
||||||
|
"Filtered by opening dates: between %datefrom% and %dateto%": "Filtrer les parcours ouverts entre deux dates: entre le %datefrom% et le %dateto%"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user