mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 22:46:13 +00:00
exports: add on_date parameter on Composition Filter/Aggregator
This commit is contained in:
parent
c693dfde66
commit
bc5d610f80
@ -3,9 +3,12 @@
|
|||||||
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
|
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
@ -54,7 +57,9 @@ class CompositionAggregator implements AggregatorInterface
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
// TODO: Implement buildForm() method.
|
$builder->add('on_date', ChillDateType::class, [
|
||||||
|
'data' => new \DateTime('now'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,6 +92,26 @@ class CompositionAggregator implements AggregatorInterface
|
|||||||
} else {
|
} else {
|
||||||
$qb->groupBy('composition_aggregator');
|
$qb->groupBy('composition_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add date in where clause
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->lte('composition.startDate', ':ondate'),
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->gt('composition.endDate', ':ondate'),
|
||||||
|
$qb->expr()->isNull('composition.endDate')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace Chill\PersonBundle\Export\Filter\HouseholdFilters;
|
namespace Chill\PersonBundle\Export\Filter\HouseholdFilters;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
|
use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
@ -26,16 +28,21 @@ class CompositionFilter implements FilterInterface
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('accepted_composition', EntityType::class, [
|
$builder
|
||||||
'class' => HouseholdCompositionType::class,
|
->add('accepted_composition', EntityType::class, [
|
||||||
'choice_label' => function (HouseholdCompositionType $type) {
|
'class' => HouseholdCompositionType::class,
|
||||||
return $this->translatableStringHelper->localize(
|
'choice_label' => function (HouseholdCompositionType $type) {
|
||||||
$type->getLabel()
|
return $this->translatableStringHelper->localize(
|
||||||
);
|
$type->getLabel()
|
||||||
},
|
);
|
||||||
'multiple' => true,
|
},
|
||||||
'expanded' => true,
|
'multiple' => true,
|
||||||
]);
|
'expanded' => true,
|
||||||
|
])
|
||||||
|
->add('on_date', ChillDateType::class, [
|
||||||
|
'data' => new \DateTime('now'),
|
||||||
|
])
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,8 +66,9 @@ class CompositionFilter implements FilterInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['Filtered by composition: only %compositions%', [
|
return ['Filtered by composition: only %compositions% on %ondate%', [
|
||||||
'%compositions%' => implode(", ou ", $compositions)
|
'%compositions%' => implode(", ou ", $compositions),
|
||||||
|
'%ondate%' => $data['on_date']->format('d-m-Y')
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +87,16 @@ class CompositionFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
$clause = $qb->expr()->in('composition.householdCompositionType', ':compositions');
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->in('composition.householdCompositionType', ':compositions'),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->lte('composition.startDate', ':ondate'),
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->gt('composition.endDate', ':ondate'),
|
||||||
|
$qb->expr()->isNull('composition.endDate')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
@ -89,6 +106,7 @@ class CompositionFilter implements FilterInterface
|
|||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter('compositions', $data['accepted_composition']);
|
$qb->setParameter('compositions', $data['accepted_composition']);
|
||||||
|
$qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -532,7 +532,7 @@ is not specified: La date d'échéance n'est pas spécifiée
|
|||||||
|
|
||||||
Filter by composition: Filtrer par composition familiale
|
Filter by composition: Filtrer par composition familiale
|
||||||
Accepted composition: Composition familiale
|
Accepted composition: Composition familiale
|
||||||
"Filtered by composition: only %compositions%": "Filtré par composition familiale: uniquement %compositions%"
|
"Filtered by composition: only %compositions% on %ondate%": "Filtré par composition familiale: uniquement %compositions%, en date du %ondate%"
|
||||||
Group by composition: Grouper par composition familiale
|
Group by composition: Grouper par composition familiale
|
||||||
|
|
||||||
## aggregators
|
## aggregators
|
||||||
|
Loading…
x
Reference in New Issue
Block a user