mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
Fixes: [export] fixes filters by household composition, and apply them on persons directly
This commit is contained in:
@@ -9,20 +9,18 @@ declare(strict_types=1);
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdComposition;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepositoryInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
class ByHouseholdCompositionAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -47,30 +45,20 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
if (!in_array('acppart', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acp.participations', 'acppart');
|
||||
}
|
||||
|
||||
$qb
|
||||
->leftJoin(
|
||||
HouseholdMember::class,
|
||||
"{$p}_hm",
|
||||
Join::WITH,
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_hm"),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_hm.startDate", ":{$p}_date"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_hm.endDate"),
|
||||
$qb->expr()->gt("{$p}_hm.endDate", ":{$p}_date")
|
||||
)
|
||||
)
|
||||
)
|
||||
'person.householdParticipations',
|
||||
"{$p}_hm"
|
||||
)
|
||||
->leftJoin(
|
||||
HouseholdComposition::class,
|
||||
"{$p}_compo",
|
||||
Join::WITH,
|
||||
$qb->expr()->eq("{$p}_hm.household", "{$p}_compo.household"),
|
||||
)
|
||||
->andWhere("{$p}_hm.startDate <= :{$p}_date AND ({$p}_hm.endDate IS NULL OR {$p}_hm.endDate > :{$p}_date)")
|
||||
->andWhere("{$p}_hm.shareHousehold = 'TRUE'")
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_compo"),
|
||||
$qb->expr()->andX(
|
||||
@@ -89,13 +77,13 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_calc', ChillDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_household_composition.Calc date',
|
||||
'label' => 'export.aggregator.person.by_household_composition.Calc date',
|
||||
'input_format' => 'datetime_immutable',
|
||||
'data' => new DateTimeImmutable('now'),
|
||||
]);
|
||||
@@ -105,7 +93,7 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
|
||||
{
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.course.by_household_composition.Household composition';
|
||||
return 'export.aggregator.person.by_household_composition.Household composition';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -127,6 +115,6 @@ class ByHouseholdCompositionAggregator implements AggregatorInterface
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course.by_household_composition.Group course by household composition';
|
||||
return 'export.aggregator.person.by_household_composition.Group course by household composition';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user