From 5b5f3a4aaf872bc17cefc4b5f461f20e2ff01e39 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Mar 2022 11:11:16 +0200 Subject: [PATCH] FIX avoid php warning "illegal string offset" --- htdocs/core/customreports.php | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index d14a0255a53..2d00677b20a 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -970,24 +970,25 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu // Add main fields of object foreach ($object->fields as $key => $val) { if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) { + $position = (!empty($val['position']) ? $val['position'] : 0); $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Sum").')', - 'position' => ($val['position']+($count * 100000)).'.1', + 'position' => ($position+($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-average'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Average").')', - 'position' => ($val['position']+($count * 100000)).'.2', + 'position' => ($position+($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-min'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Minimum").')', - 'position' => ($val['position']+($count * 100000)).'.3', + 'position' => ($position+($count * 100000)).'.3', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-max'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Maximum").')', - 'position' => ($val['position']+($count * 100000)).'.4', + 'position' => ($position+($count * 100000)).'.4', 'table' => $object->table_element ); } @@ -996,24 +997,25 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu if ($object->isextrafieldmanaged) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) { + $position = (!empty($val['position']) ? $val['position'] : 0); $arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Sum").')', - 'position' => ($val['position']+($count * 100000)).'.1', + 'position' => ($position+($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'e.'.$key.'-average'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Average").')', - 'position' => ($val['position']+($count * 100000)).'.2', + 'position' => ($position+($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'e.'.$key.'-min'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Minimum").')', - 'position' => ($val['position']+($count * 100000)).'.3', + 'position' => ($position+($count * 100000)).'.3', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'e.'.$key.'-max'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' ('.$langs->trans("Maximum").')', - 'position' => ($val['position']+($count * 100000)).'.4', + 'position' => ($position+($count * 100000)).'.4', 'table' => $object->table_element ); } @@ -1096,25 +1098,26 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $position = (!empty($val['position']) ? $val['position'] : 0); $arrayofxaxis[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', - 'position' => ($val['position']+($count * 100000)).'.1', + 'position' => ($position+($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofxaxis[$tablealias.'.'.$key.'-month'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', - 'position' => ($val['position']+($count * 100000)).'.2', + 'position' => ($position+($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofxaxis[$tablealias.'.'.$key.'-day'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', - 'position' => ($val['position']+($count * 100000)).'.3', + 'position' => ($position+($count * 100000)).'.3', 'table' => $object->table_element ); } else { $arrayofxaxis[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), - 'position' => ($val['position']+($count * 100000)), + 'position' => ($position+($count * 100000)), 'table' => $object->table_element ); } @@ -1215,25 +1218,26 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $position = (!empty($val['position']) ? $val['position'] : 0); $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($val['position']+($count * 100000)).'.1', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($position+($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofgroupby[$tablealias.'.'.$key.'-month'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($val['position']+($count * 100000)).'.2', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($position+($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofgroupby[$tablealias.'.'.$key.'-day'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($val['position']+($count * 100000)).'.3', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($position+($count * 100000)).'.3', 'table' => $object->table_element ); } else { $arrayofgroupby[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)), + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position+($count * 100000)), 'table' => $object->table_element ); }