From 5e4102386217e9f4dc5e9dac66046ae35cf4e9b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 19 Jul 2023 22:58:11 +0200 Subject: [PATCH] Debug v18 --- htdocs/core/lib/functions.lib.php | 7 ++++--- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 339714055d1..e273f17b154 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2540,7 +2540,7 @@ function dol_bc($var, $moreclass = '') * * @param Object $object A company or contact object * @param int $withcountry 1=Add country into address string - * @param string $sep Separator to use to build string + * @param string $sep Separator to use to separate info when building string * @param Translate $outputlangs Object lang that contains language for text translation. * @param int $mode 0=Standard output, 1=Remove address * @param string $extralangcode User extralanguage $langcode as values for address, town @@ -2557,7 +2557,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs // See format of addresses on https://en.wikipedia.org/wiki/Address // Address if (empty($mode)) { - $ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : $object->address)); + $ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : preg_replace('/[\n\r]/', $sep, $object->address))); } // Zip/Town/State if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US', 'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) { @@ -2587,7 +2587,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : (empty($object->town) ? '' : $object->town)); $ret .= ($town ? (($object->zip ? ' ' : '').$town) : ''); if (!empty($object->state)) { - $ret .= "\n".$object->state; + $ret .= $sep.$object->state; } } elseif (isset($object->country_code) && in_array($object->country_code, array('JP'))) { // JP: In romaji, title firstname name\n address lines \n [state,] town zip \n country @@ -2609,6 +2609,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $ret .= ($ret ? ", " : '').$object->state; } } + if (!is_object($outputlangs)) { $outputlangs = $langs; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 231cbc2546d..c574b96cb29 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2694,7 +2694,7 @@ class Societe extends CommonObject } if (!empty($this->address)) { - $datas['address'] = '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); // Address + country + $datas['address'] = '
'.$langs->trans("Addressaaa").': '.dol_format_address($this, 1, ' ', $langs); // Address + country } elseif (!empty($this->country_code)) { $datas['address'] = '
'.$langs->trans('Country').': '.$this->country_code; }