mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
export new EvaluationFilter
This commit is contained in:
parent
b511517a0f
commit
bc2209319a
105
src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilter.php
Normal file
105
src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilter.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
|
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;
|
||||||
|
|
||||||
|
class EvaluationFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TranslatableStringHelper $translatableStringHelper
|
||||||
|
) {
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('accepted_evaluations', EntityType::class, [
|
||||||
|
'class' => Evaluation::class,
|
||||||
|
'choice_label' => function (Evaluation $ev) {
|
||||||
|
return $this->translatableStringHelper->localize($ev->getTitle());
|
||||||
|
},
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter by evaluation';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
$evaluations = [];
|
||||||
|
|
||||||
|
foreach ($data['accepted_evaluations'] as $ev) {
|
||||||
|
$evaluations[] = $this->translatableStringHelper->localize($ev->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Filtered by evaluations: only %evals%', [
|
||||||
|
'%evals%' => implode(", ou ", $evaluations)
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$qb
|
||||||
|
->join('acp.works', 'acpw')
|
||||||
|
->join('acpw.accompanyingPeriodWorkEvaluations', 'we')
|
||||||
|
->join('we.evaluation', 'ev')
|
||||||
|
;
|
||||||
|
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
$clause = $qb->expr()->in('ev.id', ':evaluations');
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
$qb->setParameter('evaluations', $data['accepted_evaluations']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -67,6 +67,13 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_socialaction_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_socialaction_filter }
|
||||||
|
|
||||||
|
chill.person.export.filter_evaluation:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\EvaluationFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: accompanyingcourse_evaluation_filter }
|
||||||
|
|
||||||
chill.person.export.filter_origin:
|
chill.person.export.filter_origin:
|
||||||
class: Chill\PersonBundle\Export\Filter\OriginFilter
|
class: Chill\PersonBundle\Export\Filter\OriginFilter
|
||||||
autowire: true
|
autowire: true
|
||||||
|
@ -394,6 +394,10 @@ Filter by socialaction: Filtrer par action d'accompagnement
|
|||||||
Accepted socialactions: Actions d'accompagnement
|
Accepted socialactions: Actions d'accompagnement
|
||||||
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
||||||
|
|
||||||
|
Filter by evaluation: Filtrer par évaluation
|
||||||
|
Accepted evaluations: Évaluations
|
||||||
|
"Filtered by evaluations: only %evals%": "Filtré par évaluation: uniquement %evals%"
|
||||||
|
|
||||||
Filter by origin: Filtrer par origine du parcours
|
Filter by origin: Filtrer par origine du parcours
|
||||||
Accepted origins: Origines
|
Accepted origins: Origines
|
||||||
"Filtered by origins: only %origins%": "Filtré par origine du parcours: uniquement %origins%"
|
"Filtered by origins: only %origins%": "Filtré par origine du parcours: uniquement %origins%"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user