From 1595bb11483169cbbf806351fad249180cc5be66 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 22 Nov 2017 09:51:46 +0100 Subject: [PATCH 1/2] NEW add possibility to remove address field --- htdocs/core/lib/functions.lib.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5a61409d692..bd910fa4d1a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1536,14 +1536,15 @@ function dol_bc($var,$moreclass='') /** * Return a formated address (part address/zip/town/state) according to country rules * - * @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 Translate $outputlangs Object lang that contains language for text translation. - * @return string Formated string + * @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 Translate $outputlangs Object lang that contains language for text translation. + * @param boolean $withoutaddress Possibility to remove address + * @return string Formated string * @see dol_print_address */ -function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') +function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $withoutaddress=false) { global $conf,$langs; @@ -1551,7 +1552,9 @@ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') $countriesusingstate=array('AU','CA','US','IN','GB','ES','UK','TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS // Address - $ret .= $object->address; + if (empty($withoutaddress)) { + $ret .= $object->address; + } // Zip/Town/State if (in_array($object->country_code,array('AU', 'CA', 'US')) || ! empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country { From c3d8ef2104fb34d0f870179a9d82c78e55d8b30a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Nov 2017 11:14:52 +0100 Subject: [PATCH 2/2] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 795ecb3e299..6fb35bee827 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1543,11 +1543,11 @@ function dol_bc($var,$moreclass='') * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string * @param Translate $outputlangs Object lang that contains language for text translation. - * @param boolean $withoutaddress Possibility to remove address + * @param int $mode 0=Standard output, 1=Remove address * @return string Formated string * @see dol_print_address */ -function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $withoutaddress=false) +function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0) { global $conf,$langs; @@ -1555,7 +1555,7 @@ function dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $countriesusingstate=array('AU','CA','US','IN','GB','ES','UK','TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS // Address - if (empty($withoutaddress)) { + if (empty($mode)) { $ret .= $object->address; } // Zip/Town/State