mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
renaming of export to avoid confusion + start of agent traitant filter
This commit is contained in:
parent
b12e5e78b6
commit
d5d38053cd
@ -22,5 +22,5 @@ abstract class Declarations
|
|||||||
|
|
||||||
public const ACP_TYPE = 'accompanying_period';
|
public const ACP_TYPE = 'accompanying_period';
|
||||||
|
|
||||||
public const SOCIAL_ACTION_TYPE = 'social_actions';
|
public const SOCIAL_WORK_ACTION_TYPE = 'social_actions';
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ use Chill\MainBundle\Export\ExportInterface;
|
|||||||
use Chill\MainBundle\Export\FormatterInterface;
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -23,23 +23,23 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
class CountSocialActions implements ExportInterface, GroupedExportInterface
|
class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
protected SocialActionRepository $socialActionRepository;
|
protected AccompanyingPeriodWorkRepository $socialActionRepository;
|
||||||
|
|
||||||
public function __construct(SocialActionRepository $socialActionRepository)
|
public function __construct(AccompanyingPeriodWorkRepository $socialActionRepository)
|
||||||
{
|
{
|
||||||
$this->socialActionRepository = $socialActionRepository;
|
$this->socialActionRepository = $socialActionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder): void
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
{
|
{
|
||||||
// TODO: Implement buildForm() method.
|
// No form necessary?
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Count social actions';
|
return 'Count social work actions';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllowedFormattersTypes(): array
|
public function getAllowedFormattersTypes(): array
|
||||||
@ -49,12 +49,12 @@ class CountSocialActions implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Count social actions by various parameters';
|
return 'Count social work actions by various parameters';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_count_social_actions' !== $key) {
|
if ('export_count_social_work_actions' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class CountSocialActions implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return ['export_count_social_actions'];
|
return ['export_count_social_work_actions'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResult($qb, $data)
|
public function getResult($qb, $data)
|
||||||
@ -78,32 +78,32 @@ class CountSocialActions implements ExportInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return Declarations::SOCIAL_ACTION_TYPE;
|
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||||
{
|
{
|
||||||
$qb = $this
|
$qb = $this
|
||||||
->socialActionRepository
|
->socialActionRepository
|
||||||
->createQueryBuilder('sa')
|
->createQueryBuilder('acpw')
|
||||||
->select('COUNT(sa.id) as export_count_social_actions');
|
->select('COUNT(acpw.id) as export_count_social_work_actions');
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requiredRole(): Role
|
public function requiredRole(): Role
|
||||||
{
|
{
|
||||||
//TODO change to string, but changes needed also in exportManager and possibly other locations.
|
//TODO change to string, but changes needed also in ExportManager and possibly other locations.
|
||||||
return new Role(AccompanyingPeriodVoter::STATS);
|
return new Role(AccompanyingPeriodVoter::STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsModifiers(): array
|
public function supportsModifiers(): array
|
||||||
{
|
{
|
||||||
return [Declarations::SOCIAL_ACTION_TYPE];
|
return [Declarations::SOCIAL_WORK_ACTION_TYPE];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroup(): string
|
public function getGroup(): string
|
||||||
{
|
{
|
||||||
return 'Exports of social actions';
|
return 'Exports of social work actions';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
|
|
||||||
|
class ReferrerFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private UserRender $userRender;
|
||||||
|
|
||||||
|
public function __construct(UserRender $userRender)
|
||||||
|
{
|
||||||
|
$this->userRender = $userRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('users', EntityType::class, [
|
||||||
|
'class' => User::class,
|
||||||
|
'choice_label' => function (User $u) {
|
||||||
|
$this->userRender->renderString($u, []);
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter by referrers';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$users = [];
|
||||||
|
|
||||||
|
foreach ($data['users'] as $u) {
|
||||||
|
$users[] = $u->getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered by users: only %users%', [
|
||||||
|
'%user%' => implode(', ou ', $users)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->in('acpw.referrers', ':users');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('users', $data['users']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,11 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
|
$this->repository = $entityManager->getRepository(AccompanyingPeriodWork::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||||
|
{
|
||||||
|
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||||
|
}
|
||||||
|
|
||||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period): int
|
public function countByAccompanyingPeriod(AccompanyingPeriod $period): int
|
||||||
{
|
{
|
||||||
return $this->repository->countByAccompanyingPeriod($period);
|
return $this->repository->countByAccompanyingPeriod($period);
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
services:
|
services:
|
||||||
chill.person.export.count_social_actions:
|
|
||||||
class: Chill\PersonBundle\Export\Export\CountSocialActions
|
chill.person.export.count_social_work_actions:
|
||||||
|
class: Chill\PersonBundle\Export\Export\CountSocialWorkActions
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: count_social_actions }
|
- { name: chill.export, alias: count_social_work_actions }
|
||||||
|
|
||||||
|
chill.person.export.filter_referrers:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\ReferrerFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: social_work_actions_referrer_filter }
|
@ -345,9 +345,9 @@ Accompanying courses duration: Durée moyenne des parcours
|
|||||||
Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours en jours, selon différents filtres.
|
Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours en jours, selon différents filtres.
|
||||||
Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré
|
Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré
|
||||||
|
|
||||||
Exports of social actions: Exports des actions d'accompangement
|
Exports of social work actions: Exports des actions d'accompangement
|
||||||
Count social actions: Nombre d'actions d'accompagnement
|
Count social work actions: Nombre d'actions d'accompagnement
|
||||||
Count social actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
|
Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
|
||||||
|
|
||||||
## filters
|
## filters
|
||||||
Filter by person gender: Filtrer par genre de la personne
|
Filter by person gender: Filtrer par genre de la personne
|
||||||
|
Loading…
x
Reference in New Issue
Block a user