mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: [export][acp] use the acp's step history to aggregate steps in StepAggregator
This commit is contained in:
parent
59e21b6819
commit
2ee4897db9
@ -17,12 +17,13 @@ These are alias conventions :
|
|||||||
| | Scope::class | acp.scopes | acpscope |
|
| | Scope::class | acp.scopes | acpscope |
|
||||||
| | SocialIssue::class | acp.socialIssues | acpsocialissue |
|
| | SocialIssue::class | acp.socialIssues | acpsocialissue |
|
||||||
| | User::class | acp.user | acpuser |
|
| | User::class | acp.user | acpuser |
|
||||||
|
| | AccompanyingPeriopStepHistory::class | acp.stepHistories | acpstephistories |
|
||||||
| AccompanyingPeriodWork::class | | | acpw |
|
| AccompanyingPeriodWork::class | | | acpw |
|
||||||
| | AccompanyingPeriodWorkEvaluation::class | acpw.accompanyingPeriodWorkEvaluations | workeval |
|
| | AccompanyingPeriodWorkEvaluation::class | acpw.accompanyingPeriodWorkEvaluations | workeval |
|
||||||
| | User::class | acpw.referrers | acpwuser |
|
| | User::class | acpw.referrers | acpwuser |
|
||||||
| | SocialAction::class | acpw.socialAction | acpwsocialaction |
|
| | SocialAction::class | acpw.socialAction | acpwsocialaction |
|
||||||
| | Goal::class | acpw.goals | goal |
|
| | Goal::class | acpw.goals | goal |
|
||||||
| | Result::class | acpw.results | result |
|
| | Result::class | acpw.results | result |
|
||||||
| AccompanyingPeriodParticipation::class | | | acppart |
|
| AccompanyingPeriodParticipation::class | | | acppart |
|
||||||
| | Person::class | acppart.person | partperson |
|
| | Person::class | acppart.person | partperson |
|
||||||
| AccompanyingPeriodWorkEvaluation::class | | | workeval |
|
| AccompanyingPeriodWorkEvaluation::class | | | workeval |
|
||||||
@ -47,7 +48,7 @@ These are alias conventions :
|
|||||||
| | HouseholdComposition::class | household.compositions | composition |
|
| | HouseholdComposition::class | household.compositions | composition |
|
||||||
| Activity::class | | | activity |
|
| Activity::class | | | activity |
|
||||||
| | Person::class | activity.person | actperson |
|
| | Person::class | activity.person | actperson |
|
||||||
| | AccompanyingPeriod::class | activity.accompanyingPeriod | acp |
|
| | AccompanyingPeriod::class | activity.accompanyingPeriod | acp |
|
||||||
| | Person::class | activity\_person\_having\_activity.person | person\_person\_having\_activity |
|
| | Person::class | activity\_person\_having\_activity.person | person\_person\_having\_activity |
|
||||||
| | ActivityReason::class | activity\_person\_having\_activity.reasons | reasons\_person\_having\_activity |
|
| | ActivityReason::class | activity\_person\_having\_activity.reasons | reasons\_person\_having\_activity |
|
||||||
| | ActivityType::class | activity.activityType | acttype |
|
| | ActivityType::class | activity.activityType | acttype |
|
||||||
|
@ -12,20 +12,21 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
//use Chill\MainBundle\Export\FilterInterface;
|
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
use function in_array;
|
||||||
|
|
||||||
final class StepAggregator implements AggregatorInterface //, FilterInterface
|
final class StepAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
|
private const A = 'acpstephistories';
|
||||||
|
|
||||||
|
private const P = 'acp_step_agg_date';
|
||||||
|
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -41,30 +42,26 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->addSelect('acp.step AS step_aggregator');
|
if (!in_array(self::A, $qb->getAllAliases(), true)) {
|
||||||
$qb->addGroupBy('step_aggregator');
|
$qb->leftJoin('acp.stepHistories', self::A);
|
||||||
|
|
||||||
/*
|
|
||||||
// add date in where clause
|
|
||||||
$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
|
||||||
$qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE);
|
->addSelect(self::A . '.step AS step_aggregator')
|
||||||
*/
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->isNull(self::A . '.step'),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->isNull(self::A . '.endDate'),
|
||||||
|
$qb->expr()->lt(self::A . '.endDate', ':' . self::P)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameter(self::P, $data['on_date'])
|
||||||
|
->addGroupBy('step_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -95,8 +92,11 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface
|
|||||||
case '_header':
|
case '_header':
|
||||||
return 'Step';
|
return 'Step';
|
||||||
|
|
||||||
|
case null:
|
||||||
|
return '';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
return $value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user