mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: [export] add byLocation filter/aggregators in asideActivity exports
This commit is contained in:
parent
0e16ab4c18
commit
67ea62f33d
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\AsideActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
|
use Chill\AsideActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Chill\MainBundle\Repository\LocationRepository;
|
||||||
|
use Closure;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class ByLocationAggregator implements AggregatorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(private LocationRepository $locationRepository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
|
{
|
||||||
|
// no form
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getFormDefaultData(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
return function ($value): string {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'export.aggregator.Aside activity localisation';
|
||||||
|
}
|
||||||
|
if (null === $value || '' === $value || null === $l = $this->locationRepository->find($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $l->getName();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getQueryKeys($data): array
|
||||||
|
{
|
||||||
|
return ['by_aside_activity_location_aggregator'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'export.aggregator.Group by aside activity location';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data): void
|
||||||
|
{
|
||||||
|
$qb->addSelect('IDENTITY(aside.location) AS by_aside_activity_location_aggregator')
|
||||||
|
->addGroupBy('by_aside_activity_location_aggregator');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ASIDE_ACTIVITY_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ use Chill\MainBundle\Export\Helper\DateTimeHelper;
|
|||||||
use Chill\MainBundle\Export\Helper\UserHelper;
|
use Chill\MainBundle\Export\Helper\UserHelper;
|
||||||
use Chill\MainBundle\Export\ListInterface;
|
use Chill\MainBundle\Export\ListInterface;
|
||||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Repository\LocationRepository;
|
||||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
@ -58,6 +59,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
|||||||
CenterRepositoryInterface $centerRepository,
|
CenterRepositoryInterface $centerRepository,
|
||||||
AsideActivityCategoryRepository $asideActivityCategoryRepository,
|
AsideActivityCategoryRepository $asideActivityCategoryRepository,
|
||||||
CategoryRender $categoryRender,
|
CategoryRender $categoryRender,
|
||||||
|
private LocationRepository $locationRepository,
|
||||||
TranslatableStringHelperInterface $translatableStringHelper
|
TranslatableStringHelperInterface $translatableStringHelper
|
||||||
) {
|
) {
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
@ -145,6 +147,19 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
|||||||
return $this->categoryRender->renderString($c, []);
|
return $this->categoryRender->renderString($c, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case 'location':
|
||||||
|
return function ($value) {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'export.aside_activity.location';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $value || '' === $value || null === $l = $this->locationRepository->find($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $l->getName();
|
||||||
|
};
|
||||||
|
|
||||||
case 'main_scope':
|
case 'main_scope':
|
||||||
return function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
@ -191,6 +206,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
|||||||
'date',
|
'date',
|
||||||
'duration',
|
'duration',
|
||||||
'note',
|
'note',
|
||||||
|
'location',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +242,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
|||||||
->addSelect('IDENTITY(aside.type) AS aside_activity_type')
|
->addSelect('IDENTITY(aside.type) AS aside_activity_type')
|
||||||
->addSelect('aside.date')
|
->addSelect('aside.date')
|
||||||
->addSelect('aside.duration')
|
->addSelect('aside.duration')
|
||||||
|
->addSelect('IDENTITY(aside.location) AS location')
|
||||||
->addSelect('aside.note');
|
->addSelect('aside.note');
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\AsideActivityBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\AsideActivityBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Entity\Location;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\LocationRepository;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class ByLocationFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
public function __construct(private LocationRepository $locationRepository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'export.filter.Filter by aside activity location';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('locations', EntityType::class, [
|
||||||
|
'label' => 'pick location',
|
||||||
|
'class' => Location::class,
|
||||||
|
'choices' => $this->locationRepository->findAll(),
|
||||||
|
'required' => false,
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => false,
|
||||||
|
'attr' => ['class' => 'select2'],
|
||||||
|
'choice_label' => fn (Location $l) => $l->getName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getFormDefaultData(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$locations = array_map(
|
||||||
|
fn (Location $l): string => $l->getName(),
|
||||||
|
$data['locations']->toArray()
|
||||||
|
);
|
||||||
|
|
||||||
|
return ['export.filter.Filtered by aside activity location: only %location%', [
|
||||||
|
'%location%' => implode(', ', $locations),
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data): void
|
||||||
|
{
|
||||||
|
$clause = $qb->expr()->in('aside.location', ':locations');
|
||||||
|
|
||||||
|
$qb->andWhere($clause);
|
||||||
|
$qb->setParameter('locations', $data['locations']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ASIDE_ACTIVITY_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -46,19 +46,29 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: 'aside_activity_user_filter' }
|
- { name: chill.export_filter, alias: 'aside_activity_user_filter' }
|
||||||
|
|
||||||
|
chill.aside_activity.export.location_filter:
|
||||||
|
class: Chill\AsideActivityBundle\Export\Filter\ByLocationFilter
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'aside_activity_location_filter' }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
|
|
||||||
chill.aside_activity.export.type_aggregator:
|
chill.aside_activity.export.type_aggregator:
|
||||||
class: Chill\AsideActivityBundle\Export\Aggregator\ByActivityTypeAggregator
|
class: Chill\AsideActivityBundle\Export\Aggregator\ByActivityTypeAggregator
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_type_aggregator }
|
- { name: chill.export_aggregator, alias: 'activity_type_aggregator' }
|
||||||
|
|
||||||
chill.aside_activity.export.user_job_aggregator:
|
chill.aside_activity.export.user_job_aggregator:
|
||||||
class: Chill\AsideActivityBundle\Export\Aggregator\ByUserJobAggregator
|
class: Chill\AsideActivityBundle\Export\Aggregator\ByUserJobAggregator
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: aside_activity_user_job_aggregator }
|
- { name: chill.export_aggregator, alias: 'aside_activity_user_job_aggregator' }
|
||||||
|
|
||||||
chill.aside_activity.export.user_scope_aggregator:
|
chill.aside_activity.export.user_scope_aggregator:
|
||||||
class: Chill\AsideActivityBundle\Export\Aggregator\ByUserScopeAggregator
|
class: Chill\AsideActivityBundle\Export\Aggregator\ByUserScopeAggregator
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: aside_activity_user_scope_aggregator }
|
- { name: chill.export_aggregator, alias: 'aside_activity_user_scope_aggregator' }
|
||||||
|
|
||||||
|
chill.aside_activity.export.location_aggregator:
|
||||||
|
class: Chill\AsideActivityBundle\Export\Aggregator\ByLocationAggregator
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_aggregator, alias: 'aside_activity_location_aggregator' }
|
||||||
|
@ -183,6 +183,7 @@ export:
|
|||||||
duration: Durée
|
duration: Durée
|
||||||
note: Note
|
note: Note
|
||||||
id: Identifiant
|
id: Identifiant
|
||||||
|
location: Localisation
|
||||||
|
|
||||||
Exports of aside activities: Exports des activités annexes
|
Exports of aside activities: Exports des activités annexes
|
||||||
Count aside activities: Nombre d'activités annexes
|
Count aside activities: Nombre d'activités annexes
|
||||||
@ -203,11 +204,16 @@ export:
|
|||||||
Filter by user jobs: Filtrer les activités annexes par métier des utilisateurs
|
Filter by user jobs: Filtrer les activités annexes par métier des utilisateurs
|
||||||
'Filtered aside activities by user scope: only %scopes%': "Filtré par service des utilisateur: uniquement %scopes%"
|
'Filtered aside activities by user scope: only %scopes%': "Filtré par service des utilisateur: uniquement %scopes%"
|
||||||
Filter by user scope: Filtrer les activités annexes par service d'utilisateur
|
Filter by user scope: Filtrer les activités annexes par service d'utilisateur
|
||||||
|
Filter by aside activity location: Filtrer les activités annexes par localisation
|
||||||
|
'Filtered by aside activity location: only %location%': "Filtré par localisation: uniquement %location%"
|
||||||
aggregator:
|
aggregator:
|
||||||
Group by aside activity type: Grouper les activités annexes par type d'activité
|
Group by aside activity type: Grouper les activités annexes par type d'activité
|
||||||
Aside activity type: Type d'activité annexe
|
Aside activity type: Type d'activité annexe
|
||||||
Aggregate by user job: Grouper les activités annexes par métier des utilisateurs
|
Aggregate by user job: Grouper les activités annexes par métier des utilisateurs
|
||||||
Aggregate by user scope: Grouper les activités annexes par service des utilisateurs
|
Aggregate by user scope: Grouper les activités annexes par service des utilisateurs
|
||||||
|
Aside activity location: Localisation des activités annexe
|
||||||
|
Group by aside activity location: Grouper les activités annexes par localisation
|
||||||
|
Aside activity localisation: Localisation
|
||||||
|
|
||||||
# ROLES
|
# ROLES
|
||||||
CHILL_ASIDE_ACTIVITY_STATS: Statistiques pour les activités annexes
|
CHILL_ASIDE_ACTIVITY_STATS: Statistiques pour les activités annexes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user