Commit 67d62e8d authored by Julien Fastré's avatar Julien Fastré
Browse files

[report list] fix "all fields are always shown"

parent 6d8d99c5
Branch master
=============
- [list export] fix error "all custom fields are shown"
......@@ -447,11 +447,14 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$qb = $this->em->createQueryBuilder();
// process fields which are not custom fields
foreach ($this->fields as $f) {
// do not add fields which are not selected
if (!\in_array($f, $data['fields'])) {
continue;
}
// add a column to the query for each field
switch ($f) {
case 'person_countryOfBirth':
case 'person_nationality':
......@@ -500,10 +503,16 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
}
// process fields which are custom fields
foreach ($this->getCustomFields() as $cf) {
// do not add custom fields which are not selected
if (!\in_array($cf->getSlug(), $data['fields'])) {
continue;
}
$cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType());
// if is multiple, split into multiple columns
if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) {
foreach($cfType->getChoices($cf) as $choiceSlug => $label) {
$slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]);
......@@ -513,6 +522,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
$qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug());
}
} else {
// not multiple, add a single column
$slug = $this->slugToDQL($cf->getSlug());
$qb->addSelect(
sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s',
......@@ -531,7 +541,6 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
->setParameter('authorized_centers', $centers);
;
return $qb;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment