From af73f2b6830599cd2ad81beb710f49931fb166c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 13:44:47 +0200 Subject: [PATCH] Fix php8 --- htdocs/core/class/commondocgenerator.class.php | 13 +++++++++++-- htdocs/core/class/translate.class.php | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bee63613bca..d0b64fdca77 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -895,7 +895,12 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; + $valueofselectkey = $object->array_options['options_'.$key]; + if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) { + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; + } else { + $object->array_options['options_'.$key] = ''; + } } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray = explode(',', $object->array_options['options_'.$key]); $output = array(); @@ -945,7 +950,11 @@ abstract class CommonDocGenerator } } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + if (array_key_exists('option_'.$key, $object->array_options)) { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + } else { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => '')); + } } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 94bd36799fc..c11f94fa047 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -904,11 +904,11 @@ class Translate * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * - * @param int $number Number to encode in full text - * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) - * @return string Label translated in UTF8 (but without entities) - * 10 if setDefaultLang was en_US => ten - * 123 if setDefaultLang was fr_FR => cent vingt trois + * @param int|string $number Number to encode in full text + * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) + * @return string Label translated in UTF8 (but without entities) + * 10 if setDefaultLang was en_US => ten + * 123 if setDefaultLang was fr_FR => cent vingt trois */ public function getLabelFromNumber($number, $isamount = '') {