From a423f8685a72f465a0a1c44c608b3a74356a1c99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Jul 2022 02:23:30 +0200 Subject: [PATCH] php8 --- htdocs/core/class/dolgraph.class.php | 2 +- htdocs/core/customreports.php | 42 +++++++++++++++------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 2fe60cc323c..e24afd73879 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1316,7 +1316,7 @@ class DolGraph if (empty($showlegend)) { $this->stringtoshow .= 'legend: { display: false }, '."\n"; } else { - $this->stringtoshow .= 'legend: { maxWidth: '.round($this->width / 2).', labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\' },'."\n"; + $this->stringtoshow .= 'legend: { maxWidth: '.round(intVal($this->width) / 2).', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ? 'right' : 'top') . '\' },'."\n"; } $this->stringtoshow .= "}, \n"; diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 46b885bd60a..2ad0e047346 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -217,7 +217,7 @@ foreach ($arrayoftype as $key => $val) { if (dol_eval($val['enabled'], 1, 1, '1')) { $newarrayoftype[$key] = $arrayoftype[$key]; } - if ($val['langs']) { + if (!empty($val['langs'])) { $langs->load($val['langs']); } } @@ -970,31 +970,31 @@ 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); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Sum").')', - 'position' => ($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' => ($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' => ($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' => ($position+($count * 100000)).'.4', + 'position' => ($position + ($count * 100000)).'.4', 'table' => $object->table_element ); } } // Add extrafields to Measures - if ($object->isextrafieldmanaged) { + if (!empty($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); @@ -1098,26 +1098,27 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $position = (!empty($val['position']) ? $val['position'] : 0); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofxaxis[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', - 'position' => ($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' => ($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' => ($position+($count * 100000)).'.3', + 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element ); } else { + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofxaxis[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), - 'position' => ($position+($count * 100000)), + 'position' => ($position + ($count * 100000)), 'table' => $object->table_element ); } @@ -1125,7 +1126,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, } // Add extrafields to X-Axis - if ($object->isextrafieldmanaged) { + if (!empty($object->isextrafieldmanaged)) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { continue; @@ -1196,7 +1197,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup // Add main fields of object foreach ($object->fields as $key => $val) { - if (!$val['isameasure']) { + if (empty($val['isameasure'])) { if (in_array($key, array( 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { @@ -1218,26 +1219,27 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $position = (!empty($val['position']) ? $val['position'] : 0); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($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' => ($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' => ($position+($count * 100000)).'.3', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element ); } else { + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofgroupby[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position+($count * 100000)), + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position + ($count * 100000)), 'table' => $object->table_element ); } @@ -1245,7 +1247,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup } // Add extrafields to Group by - if ($object->isextrafieldmanaged) { + if (! empty($object->isextrafieldmanaged)) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { continue;