Feature: [export][work] Group by current action

This commit is contained in:
Julien Fastré 2022-11-02 14:55:12 +01:00
parent cda25d3459
commit 63d38e35f7
3 changed files with 26 additions and 11 deletions

View File

@ -16,19 +16,27 @@ use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class CurrentActionAggregator implements AggregatorInterface
{
private TranslatorInterface $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
public function alterQuery(QueryBuilder $qb, $data): void
{
$qb
->addSelect('
(CASE true WHEN acpw.startDate IS NULL ELSE false END)
(CASE WHEN acpw.endDate IS NULL THEN true ELSE false END)
AS acpw_current_action_aggregator
')
->addGroupBy('acpw_current_action_aggregator');
@ -39,24 +47,24 @@ class CurrentActionAggregator implements AggregatorInterface
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
public function buildForm(FormBuilderInterface $builder): void
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return static function ($value): string {
return function ($value): string {
if ('_header' === $value) {
return '';
return 'export.aggregator.course_work.by_current_action.Current action ?';
}
switch ($value) {
case true:
return 'Current action';
return $this->translator->trans('export.aggregator.course_work.by_current_action.Current action');
case false:
return 'Not current action';
return $this->translator->trans('export.aggregator.course_work.by_current_action.Not current action');
default:
throw new LogicException(sprintf('The value %s is not valid', $value));
@ -71,6 +79,6 @@ class CurrentActionAggregator implements AggregatorInterface
public function getTitle(): string
{
return 'Group by current actions';
return 'export.aggregator.course_work.by_current_action.Group by current actions';
}
}

View File

@ -94,3 +94,7 @@ services:
- { name: chill.export_aggregator, alias: social_work_actions_goal_result_aggregator }
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CurrentActionAggregator:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: social_work_actions_current_aggregator }

View File

@ -577,9 +577,6 @@ Group by creator job: Grouper les parcours par métier du créateur
Filter by current actions: Filtrer les actions en cours
Filtered by current action: 'Filtré: uniquement les actions en cours (sans date de fin)'
Group by current actions: Grouper les actions en cours
Current action: Actions en cours
Not current action: Actions terminées
Filter by start date evaluations: Filtrer les évaluations par date de début
Filter by end date evaluations: Filtrer les évaluations par date de fin
start period date: Date de début de la période
@ -1015,6 +1012,12 @@ export:
Calc date: Date de calcul de la composition du ménage
by_number_of_action:
Number of actions: Nombre d'actions
course_work:
by_current_action:
Current action ?: Action en cours ?
Group by current actions: Grouper les actions en cours
Current action: Action en cours
Not current action: Action terminée
filter:
course:
by_user_scope: