mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
split ReferrerFilter, logiquement ce sont des filtres différents
This commit is contained in:
parent
b614149fab
commit
93eb9220a7
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter;
|
||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
@ -42,7 +42,7 @@ class ReferrerFilter implements FilterInterface
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filtered by referrers';
|
||||
return 'Filter by referrers';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,21 +76,7 @@ class ReferrerFilter implements FilterInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
switch ($qb->getRootAlias()) {
|
||||
|
||||
case 'acp':
|
||||
$clause = $qb->expr()->in('acp.user', ':referrers');
|
||||
break;
|
||||
|
||||
case 'acpw':
|
||||
$qb->join('acpw.referrers', 'r');
|
||||
$clause = $qb->expr()->in('r', ':referrers');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception("Does not apply on that base entity");
|
||||
}
|
||||
$clause = $qb->expr()->in('acp.user', ':referrers');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
@ -107,6 +93,6 @@ class ReferrerFilter implements FilterInterface
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_SHARED;
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\Query\Expr\From;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class ReferrerFilter implements FilterInterface
|
||||
{
|
||||
private UserRender $userRender;
|
||||
|
||||
public function __construct(UserRender $userRender)
|
||||
{
|
||||
$this->userRender = $userRender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('accepted_agents', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choice_label' => function (User $u) {
|
||||
return $this->userRender->renderString($u, []);
|
||||
},
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by treating agent';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
$users = [];
|
||||
|
||||
foreach ($data['accepted_agents'] as $r) {
|
||||
$users[] = $r;
|
||||
}
|
||||
|
||||
return [
|
||||
'Filtered by treating agent: only %agents%', [
|
||||
'%agents' => implode(", ou ", $users)
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->join('acpw.referrers', 'u');
|
||||
|
||||
$where = $qb->getDQLPart('where');
|
||||
$clause = $qb->expr()->in('u', ':agents');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('agents', $data['accepted_agents']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
}
|
@ -136,7 +136,7 @@ services:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_activeonedaybetweendates_filter }
|
||||
|
||||
chill.person.export.filter_referrer:
|
||||
class: Chill\PersonBundle\Export\Filter\ReferrerFilter
|
||||
class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
|
@ -29,6 +29,13 @@ services:
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_job_filter }
|
||||
|
||||
chill.person.export.filter_treating_agent:
|
||||
class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ReferrerFilter
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: social_work_actions_referrer_filter }
|
||||
|
||||
## AGGREGATORS
|
||||
chill.person.export.aggregator_action_type:
|
||||
|
@ -508,11 +508,16 @@ On date: Actifs à cette date
|
||||
Filter by active at least one day between dates: Filtrer les parcours actifs au moins un jour dans la période
|
||||
"Filtered by actives courses: at least one day between %datefrom% and %dateto%": "Filtrer les parcours actifs: au moins un jour entre le %datefrom% et le %dateto%"
|
||||
|
||||
Filtered by referrers: Filtrer par référent
|
||||
Filter by referrers: Filtrer par référent
|
||||
Accepted referrers: Référents
|
||||
"Filtered by referrer: only %referrers%": "Filtré par référent: uniquement %referrers%"
|
||||
Group by referrers: Grouper par référent
|
||||
|
||||
Filter by treating agent: Filtrer par agent traitant
|
||||
Accepted agents: Agent traitant
|
||||
"Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%"
|
||||
Group by treating agent: Grouper par agent traitant
|
||||
|
||||
Filter by opened between dates: Filtrer les parcours ouverts entre deux dates
|
||||
Date from: Date de début
|
||||
Date to: Date de fin
|
||||
|
Loading…
x
Reference in New Issue
Block a user