create 6 new filters/aggr files

This commit is contained in:
Mathieu Jaumotte 2023-11-13 17:53:02 +01:00
parent d5bc9d10d5
commit 6944773868
8 changed files with 516 additions and 0 deletions

View File

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorAggregator implements AggregatorInterface
{
private const PREFIX = 'acpw_aggr_creator';
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
return function ($value): string {
};
}
public function getQueryKeys($data): array
{
return [];
}
public function getTitle(): string
{
return 'export.aggregator.course_work.by_creator.title';
}
}

View File

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorJobAggregator implements AggregatorInterface
{
private const PREFIX = 'acpw_aggr_creator_job';
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
return function ($value): string {
};
}
public function getQueryKeys($data): array
{
return [];
}
public function getTitle(): string
{
return 'export.aggregator.course_work.by_creator_job.title';
}
}

View File

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorScopeAggregator implements AggregatorInterface
{
private const PREFIX = 'acpw_aggr_creator_scope';
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
return function ($value): string {
};
}
public function getQueryKeys($data): array
{
return [];
}
public function getTitle(): string
{
return 'export.aggregator.course_work.by_creator_scope.title';
}
}

View File

@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickUserDynamicType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorFilter implements FilterInterface
{
private const PREFIX = 'acpw_filter_creator';
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->join('acpw.createdBy', "{$p}_creator")
->andWhere($qb->expr()->in("{$p}_creator", ":{$p}_creators"))
->setParameter("{$p}_creators", $data['creators'])
//->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert(
// $data['creator_at'] ?? new RollingDate(RollingDate::T_TODAY)
//))
;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('creators', PickUserDynamicType::class, [
'multiple' => true,
'label' => 'export.filter.work.by_creator.Creators',
])
//->add('creator_at', PickRollingDateType::class, [
// 'label' => 'export.filter.work.by_creator.Calc date',
// 'help' => 'export.filter.work.by_creator.calc_date_help',
//])
;
}
public function describeAction($data, $format = 'string'): array
{
return [];
}
public function getFormDefaultData(): array
{
return [
'creators' => [],
//'creator_at' => new RollingDate(RollingDate::T_TODAY),
];
}
public function getTitle(): string
{
return 'export.filter.work.by_creator.title';
}
}

View File

@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorJobFilter implements FilterInterface
{
private const PREFIX = 'acpw_filter_creator_job';
public function __construct(
private readonly UserJobRepository $userJobRepository,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->setParameter("{$p}_jobs", $data['jobs'])
;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('jobs', EntityType::class, [
'class' => UserJob::class,
'choices' => $this->userJobRepository->findAllActive(),
'multiple' => true,
'expanded' => true,
'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
'label' => 'Job',
]);
}
public function describeAction($data, $format = 'string'): array
{
$creatorJobs = [];
foreach ($data['jobs'] as $j) {
$creatorJobs[] = $this->translatableStringHelper->localize(
$j->getLabel()
);
}
return ['export.filter.work.by_creator_job.Filtered by creator job: only %jobs%', [
'%jobs%' => implode(', ', $creatorJobs),
]];
}
public function getFormDefaultData(): array
{
return [
'jobs' => [],
];
}
public function getTitle(): string
{
return 'export.filter.work.by_creator_job.title';
}
}

View File

@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\ScopeRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
class CreatorScopeFilter implements FilterInterface
{
private const PREFIX = 'acpw_filter_creator_scope';
public function __construct(
private readonly ScopeRepository $scopeRepository,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->setParameter("{$p}_scopes", $data['scopes'])
;
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('scopes', EntityType::class, [
'class' => Scope::class,
'choices' => $this->scopeRepository->findAllActive(),
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
'multiple' => true,
'expanded' => true,
'label' => 'Scope',
]);
}
public function describeAction($data, $format = 'string'): array
{
$creatorScopes = [];
foreach ($data['scopes'] as $s) {
$creatorScopes[] = $this->translatableStringHelper->localize(
$s->getName()
);
}
return ['export.filter.work.by_creator_scope.Filtered by creator scope: only %scopes%', [
'%scopes%' => implode(', ', $creatorScopes),
]];
}
public function getFormDefaultData(): array
{
return [
'scopes' => [],
];
}
public function getTitle(): string
{
return 'export.filter.work.by_creator_scope.title';
}
}

View File

@ -63,6 +63,19 @@ services:
tags:
- { name: chill.export_filter, alias: social_work_actions_end_btw_dates_filter }
Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorFilter:
tags:
- { name: chill.export_filter, alias: social_work_actions_creator_filter }
Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorJobFilter:
tags:
- { name: chill.export_filter, alias: social_work_actions_creator_job_filter }
Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorScopeFilter:
tags:
- { name: chill.export_filter, alias: social_work_actions_creator_scope_filter }
## AGGREGATORS
chill.person.export.aggregator_action_type:
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
@ -105,6 +118,18 @@ services:
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator:
tags:
- { name: chill.export_aggregator, alias: accompanyingcourse_handling3party_aggregator }
#
# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorAggregator:
# tags:
# - { name: chill.export_aggregator, alias: social_work_actions_creator_aggregator }
#
# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorJobAggregator:
# tags:
# - { name: chill.export_aggregator, alias: social_work_actions_creator_job_aggregator }
#
# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorScopeAggregator:
# tags:
# - { name: chill.export_aggregator, alias: social_work_actions_creator_scope_aggregator }
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HandlingThirdPartyFilter:
tags:

View File

@ -1094,6 +1094,12 @@ export:
by_handling_third_party:
title: Grouper les actions par tiers traitant
header: Tiers traitant
by_creator:
title: Grouper les actions par créateur
by_creator_job:
title: Grouper les actions par métier du créateur
by_creator_scope:
title: Grouper les actions par service du créateur
eval:
by_end_date:
@ -1214,6 +1220,17 @@ export:
title: Filtrer les actions par tiers traitant
Only 3 parties %3parties%: "Seulement les actions d'accompagnement qui ont pour tiers traitant: %3parties%"
pick_3parties: Tiers traitants des actions
by_creator:
title: Filtrer les actions par créateur
Creators: Créateur de l'action
#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%"
by_creator_scope:
title: Filtrer les actions par service du créateur
"Filtered by creator scope: only %scopes%'": "Filtré par service du créateur: uniquement %scopes%"
list:
person_with_acp: