mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
complete aggregators
This commit is contained in:
parent
fde6000d0b
commit
b790e2fcf1
@ -12,7 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -22,7 +23,8 @@ class CreatorAggregator implements AggregatorInterface
|
||||
private const PREFIX = 'acpw_aggr_creator';
|
||||
|
||||
public function __construct(
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
private UserRepository $userRepository,
|
||||
private UserRender $userRender
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@ -32,7 +34,11 @@ class CreatorAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb;
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->addSelect("IDENTITY(acpw.createdBy) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -40,10 +46,7 @@ class CreatorAggregator implements AggregatorInterface
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add();
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
@ -53,13 +56,23 @@ class CreatorAggregator implements AggregatorInterface
|
||||
public function getLabels($key, array $values, mixed $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.course_work.by_creator.Creator';
|
||||
};
|
||||
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$r = $this->userRepository->find($value);
|
||||
|
||||
return $this->userRender->renderString($r, ['absence' => false, 'user_job' => false, 'main_scope' => false]);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@ -22,6 +25,7 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
private const PREFIX = 'acpw_aggr_creator_job';
|
||||
|
||||
public function __construct(
|
||||
private readonly UserJobRepository $jobRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
) {}
|
||||
|
||||
@ -32,7 +36,26 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb;
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin(
|
||||
UserJobHistory::class,
|
||||
"{$p}_history",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_history.user", "acpw.createdBy"),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->addSelect("IDENTITY({$p}_history.job) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -40,10 +63,7 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add();
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
@ -53,13 +73,23 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
public function getLabels($key, array $values, mixed $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.course_work.by_creator_job.Creator\'s job';
|
||||
}
|
||||
|
||||
if (null === $value || '' === $value || null === $j = $this->jobRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@ -22,6 +25,7 @@ class CreatorScopeAggregator implements AggregatorInterface
|
||||
private const PREFIX = 'acpw_aggr_creator_scope';
|
||||
|
||||
public function __construct(
|
||||
private readonly ScopeRepository $scopeRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper
|
||||
) {}
|
||||
|
||||
@ -32,7 +36,26 @@ class CreatorScopeAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb;
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_history",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_history.user", "acpw.createdBy"),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -40,10 +63,7 @@ class CreatorScopeAggregator implements AggregatorInterface
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add();
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
@ -53,13 +73,23 @@ class CreatorScopeAggregator implements AggregatorInterface
|
||||
public function getLabels($key, array $values, mixed $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.course_work.by_creator_scope.Creator\'s scope';
|
||||
}
|
||||
|
||||
if (null === $value || '' === $value || null === $s = $this->scopeRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$s->getName()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@ -1096,10 +1096,13 @@ export:
|
||||
header: Tiers traitant
|
||||
by_creator:
|
||||
title: Grouper les actions par créateur
|
||||
Creator: Créateur de l'action
|
||||
by_creator_job:
|
||||
title: Grouper les actions par métier du créateur
|
||||
Creator's job: Métier du créateur
|
||||
by_creator_scope:
|
||||
title: Grouper les actions par service du créateur
|
||||
Creator's scope: Service du créateur
|
||||
|
||||
eval:
|
||||
by_end_date:
|
||||
@ -1224,8 +1227,6 @@ export:
|
||||
title: Filtrer les actions par créateur
|
||||
Creators: Créateur de l'action
|
||||
"Filtered by creator: only %creators%": "Filtré par créateur de l'action: uniquement %creators%"
|
||||
#Calc date: Date à laquelle le créateur ...
|
||||
#calc_date_help: Il s'agit de la date à laquelle le créateur ...
|
||||
by_creator_job:
|
||||
title: Filtrer les actions par métier du créateur
|
||||
"Filtered by creator job: only %jobs%'": "Filtré par métier du créateur: uniquement %jobs%"
|
||||
|
Loading…
x
Reference in New Issue
Block a user