mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
exports: add new ActiveOnDate filter
This commit is contained in:
parent
c401e34d63
commit
758c56482b
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
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 ActiveOnDateFilter implements FilterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('on_date', ChillDateType::class, [
|
||||
'data' => new DateTime(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filtered by active on date';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return ['Filtered by actives courses: active on %ondate%', [
|
||||
'%ondate%' => $data['on_date']->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()->lte('acp.openingDate', ':ondate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->gt('acp.closingDate', ':ondate'),
|
||||
$qb->expr()->isNull('acp.closingDate')
|
||||
)
|
||||
);
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string')
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return ['Filtered by actives courses: at least one day between %datefrom% and %dateto%', [
|
||||
'%datefrom%' => $data['date_from']->format('d-m-Y'),
|
||||
|
@ -40,7 +40,7 @@ class OpenBetweenDatesFilter implements FilterInterface
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string')
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return ['Filtered by opening dates: between %datefrom% and %dateto%', [
|
||||
'%datefrom%' => $data['date_from']->format('d-m-Y'),
|
||||
|
@ -95,6 +95,13 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_intensity_filter }
|
||||
|
||||
chill.person.export.filter_activeondate:
|
||||
class: Chill\PersonBundle\Export\Filter\ActiveOnDateFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_activeondate_filter }
|
||||
|
||||
chill.person.export.filter_activeonedaybetweendates:
|
||||
class: Chill\PersonBundle\Export\Filter\ActiveOneDayBetweenDatesFilter
|
||||
autowire: true
|
||||
|
@ -428,6 +428,10 @@ Date to: Date de fin
|
||||
Filtered by active at least one day between dates: Filtrer les parcours actifs au moins un jour dans la période
|
||||
"Filtered by actives courses: at least one day between %datefrom% and %dateto%": "Filtrer les parcours actifs: au moins un jour entre le %datefrom% et le %dateto%"
|
||||
|
||||
Filtered by active on date: Filtrer les parcours actifs à une date
|
||||
On date: Actifs à cette date
|
||||
"Filtered by actives courses: active on %ondate%": "Filtrer les parcours actifs: actifs le %ondate%"
|
||||
|
||||
## aggregators
|
||||
Group people by nationality: Aggréger les personnes par nationalités
|
||||
Group by level: Grouper par niveau
|
||||
|
Loading…
x
Reference in New Issue
Block a user