mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[export] fix 2 job/scope aggregators in acp
This commit is contained in:
parent
bea21d45fc
commit
1973a4b849
@ -11,8 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
@ -22,21 +26,69 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'user_working_on_course_job_id';
|
||||
private const PREFIX = 'acp_agg_user_job_working_on_course';
|
||||
|
||||
public function __construct(
|
||||
private RollingDateConverter $rollingDateConverter,
|
||||
private UserJobRepositoryInterface $userJobRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
"acpinfo",
|
||||
Join::WITH,
|
||||
$qb->expr()->eq( "IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
|
||||
)
|
||||
->leftJoin("acpinfo.user", "{$p}_user")
|
||||
->leftJoin(
|
||||
UserJobHistory::class,
|
||||
"{$p}_history",
|
||||
Join::WITH,
|
||||
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", ":{$p}_at")
|
||||
)
|
||||
)
|
||||
)
|
||||
->addSelect("IDENTITY({$p}_history.job) AS {$p}_select")
|
||||
->setParameter(
|
||||
"{$p}_at", $this->rollingDateConverter->convert($data['job_at'])
|
||||
)
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// nothing to add here
|
||||
$builder->add('job_at', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_job_working.Calc date',
|
||||
'required' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
return ['job_at' => new RollingDate(RollingDate::T_TODAY)];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
@ -58,42 +110,13 @@ final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
return [self::PREFIX . '_select'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.aggregator.course.by_job_working.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpinfo', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
'acpinfo',
|
||||
Join::WITH,
|
||||
'acp.id = IDENTITY(acpinfo.accompanyingPeriod)'
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acpinfo_user.userJob) AS ' . self::COLUMN_NAME);
|
||||
$qb->addGroupBy(self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
@ -23,21 +26,69 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'user_working_on_course_scope_id';
|
||||
private const PREFIX = 'acp_agg_user_scope_working_on_course';
|
||||
|
||||
public function __construct(
|
||||
private RollingDateConverter $rollingDateConverter,
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
"acpinfo",
|
||||
Join::WITH,
|
||||
$qb->expr()->eq("IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
|
||||
)
|
||||
->leftJoin("acpinfo.user", "{$p}_user")
|
||||
->leftJoin(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_history",
|
||||
Join::WITH,
|
||||
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", ":{$p}_at")
|
||||
)
|
||||
)
|
||||
)
|
||||
->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select")
|
||||
->setParameter(
|
||||
"{$p}_at", $this->rollingDateConverter->convert($data['scope_at'])
|
||||
)
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// nothing to add here
|
||||
$builder->add('scope_at', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_scope_working.Calc date',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
return ['scope_at' => new RollingDate(RollingDate::T_TODAY)];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
@ -59,42 +110,13 @@ final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterfa
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
return [self::PREFIX. '_select'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.aggregator.course.by_scope_working.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpinfo', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
'acpinfo',
|
||||
Join::WITH,
|
||||
'acp.id = IDENTITY(acpinfo.accompanyingPeriod)'
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acpinfo_user.mainScope) AS ' . self::COLUMN_NAME);
|
||||
$qb->addGroupBy(self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
||||
|
@ -1036,9 +1036,11 @@ export:
|
||||
by_job_working:
|
||||
title: Grouper les parcours par métier de l'intervenant
|
||||
job: Métier de l'intervenant
|
||||
Calc date: Date de calcul du métier de l'intervenant
|
||||
by_scope_working:
|
||||
title: Grouper les parcours par service de l'intervenant
|
||||
scope: Service de l'intervenant
|
||||
Calc date: Date de calcul du service de l'intervenant
|
||||
by_scope:
|
||||
Group course by scope: Grouper les parcours par service
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user