mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
exports: add on_date parameter on Composition Filter/Aggregator
This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -54,7 +57,9 @@ class CompositionAggregator implements AggregatorInterface
|
||||
*/
|
||||
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 {
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user