mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: fix alterQuery and DescribeAction in SocialWorkTypeFilter
This commit is contained in:
parent
4cb6e8e564
commit
478afc893b
@ -50,17 +50,23 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
$builder
|
||||
->add('actionType', HiddenType::class)
|
||||
->get('actionType')
|
||||
->addModelTransformer($this->iterableToIdTransformer(SocialAction::class))
|
||||
->addModelTransformer(
|
||||
$this->iterableToIdTransformer(SocialAction::class)
|
||||
)
|
||||
;
|
||||
$builder
|
||||
->add('goal', HiddenType::class)
|
||||
->get('goal')
|
||||
->addModelTransformer($this->iterableToIdTransformer(Goal::class))
|
||||
->addModelTransformer(
|
||||
$this->iterableToIdTransformer(Goal::class)
|
||||
)
|
||||
;
|
||||
$builder
|
||||
->add('result', HiddenType::class)
|
||||
->get('result')
|
||||
->addModelTransformer($this->iterableToIdTransformer(Result::class))
|
||||
->addModelTransformer(
|
||||
$this->iterableToIdTransformer(Result::class)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
@ -90,27 +96,35 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by type of action, objectives and results';
|
||||
return 'Filter by type of action, goals and results';
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
$actionTypes = [];
|
||||
$objectives = [];
|
||||
$goals = [];
|
||||
$results = [];
|
||||
|
||||
foreach ($data['actionType'] as $at) {
|
||||
$actionTypes[] = $at->getTitle();
|
||||
}
|
||||
foreach ($data['objectives'] as $o) {
|
||||
$objectives[] = $o->getTitle();
|
||||
}
|
||||
foreach ($data['results'] as $r) {
|
||||
$results[] = $r->getTitle();
|
||||
$actionTypes[] = $this->translatableStringHelper->localize(
|
||||
$at->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
return ['Filtered by referrers: only %actionTypes%', [
|
||||
'%actionTypes%' => implode(', ou ', $actionTypes)
|
||||
foreach ($data['goal'] as $g) {
|
||||
$goals[] = $this->translatableStringHelper->localize(
|
||||
$g->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($data['result'] as $r) {
|
||||
$results[] = $this->translatableStringHelper->localize(
|
||||
$r->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
return ['Filtered actions by type, goals and results: %selected%', [
|
||||
'%selected%' => implode(', ', array_merge($actionTypes, $goals, $results))
|
||||
]];
|
||||
}
|
||||
|
||||
@ -122,15 +136,9 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
$clause = $qb->expr()->eq('acpw.socialAction',':actionType');
|
||||
|
||||
/*
|
||||
if (!empty($data['goal'])) {
|
||||
$clause
|
||||
$qb->expr()->in('acpw.goals', ':goals');
|
||||
}
|
||||
$qb->expr()->in('acpw.results', ':results');
|
||||
*/
|
||||
if (count($data['actionType']) > 0) {
|
||||
$clause = $qb->expr()->in('acpw.socialAction', ':actionType');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
@ -138,12 +146,34 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->setParameter('actionType', $data['actionType']);
|
||||
}
|
||||
|
||||
if (count($data['goal']) > 0) {
|
||||
if (!in_array('goal', $qb->getAllAliases(), true)) {
|
||||
$qb->join('acpw.goals', 'goal');
|
||||
}
|
||||
|
||||
$where->add(
|
||||
$qb->expr()->in('goal.id', ':goals')
|
||||
);
|
||||
|
||||
$qb->setParameter('goals', $data['goal']);
|
||||
}
|
||||
|
||||
if (count($data['result']) > 0) {
|
||||
if (!in_array('result', $qb->getAllAliases(), true)) {
|
||||
$qb->join('acpw.results', 'result');
|
||||
}
|
||||
|
||||
$where->add(
|
||||
$qb->expr()->in('result.id', ':results')
|
||||
);
|
||||
|
||||
$qb->setParameter('results', $data['result']);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameters([
|
||||
'actionType' => $data['actionType'],
|
||||
'goal' => $data['goal'],
|
||||
'result' => $data['result'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
@ -456,7 +456,9 @@ Filter by socialaction: Filtrer les parcours par action d'accompagnement
|
||||
Accepted socialactions: Actions d'accompagnement
|
||||
"Filtered by socialactions: only %socialactions%": "Filtré par action d'accompagnement: uniquement %socialactions%"
|
||||
Group by social action: Grouper les parcours par action d'accompagnement
|
||||
Filter by type of action, objectives and results: "Filtrer les actions par type, objectif et résultat"
|
||||
|
||||
Filter by type of action, goals and results: "Filtrer les actions par type, objectif et résultat"
|
||||
'Filtered actions by type, goals and results: %selected%': "Actions filtrées par: %selected%"
|
||||
|
||||
Filter by evaluation: Filtrer les parcours par évaluation
|
||||
Accepted evaluations: Évaluations
|
||||
|
Loading…
x
Reference in New Issue
Block a user