diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index e7363a9b29f..421b56b0e9c 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -96,36 +96,36 @@ function dol_string_unaccent($str) { $string = rawurlencode($str); $replacements = array( - '%C3%80' => 'A','%C3%81' => 'A', - '%C3%88' => 'E','%C3%89' => 'E', - '%C3%8C' => 'I','%C3%8D' => 'I', - '%C3%92' => 'O','%C3%93' => 'O', - '%C3%99' => 'U','%C3%9A' => 'U', - '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a', - '%C3%A8' => 'e','%C3%A9' => 'e','%C3%AA' => 'e','%C3%AB' => 'e', - '%C3%AC' => 'i','%C3%AD' => 'i', - '%C3%B2' => 'o','%C3%B3' => 'o', - '%C3%B9' => 'u','%C3%BA' => 'u' + '%C3%80' => 'A','%C3%81' => 'A', + '%C3%88' => 'E','%C3%89' => 'E', + '%C3%8C' => 'I','%C3%8D' => 'I', + '%C3%92' => 'O','%C3%93' => 'O', + '%C3%99' => 'U','%C3%9A' => 'U', + '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a', + '%C3%A8' => 'e','%C3%A9' => 'e','%C3%AA' => 'e','%C3%AB' => 'e', + '%C3%AC' => 'i','%C3%AD' => 'i', + '%C3%B2' => 'o','%C3%B3' => 'o', + '%C3%B9' => 'u','%C3%BA' => 'u' ); $string=strtr($string, $replacements); return rawurldecode($string); } else { - $string = strtr($str, - "xC0\xC1\xC2\xC3\xC5\xC7 + $string = strtr($str, + "xC0\xC1\xC2\xC3\xC5\xC7 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD \xE0\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8 \xF9\xFA\xFB\xFD\xFF", - "AAAAAC + "AAAAAC EEEEIIIIDN OOOOOUUUY aaaaaceeee iiiidnooooo uuuyy"); - $string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th")); + $string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th")); return $string; } } @@ -182,7 +182,7 @@ function dolibarr_syslog($message, $level=LOG_INFO) //print $level.' - '.$conf->global->SYSLOG_LEVEL.' - '.$conf->syslog->enabled." \n"; if ($level > $conf->global->SYSLOG_LEVEL) return; - // Load error message files if this is an error message (rare) + // Load error message files if this is an error message (rare) if ($level == LOG_ERR) { $langs->load("errors"); @@ -248,9 +248,9 @@ function dolibarr_syslog($message, $level=LOG_INFO) { $facility = LOG_USER; } - + openlog("dolibarr", LOG_PID | LOG_PERROR, $facility); - + if (! $level) { syslog(LOG_ERR, $message); @@ -259,7 +259,7 @@ function dolibarr_syslog($message, $level=LOG_INFO) { syslog($level, $message); } - + closelog(); } } @@ -712,15 +712,16 @@ function dolibarr_print_object_info($object) } /** - * \brief Format phone numbers according to country - * \param phone Phone number to format - * \param country Country to use for formatting - * \param cid Id of contact if known - * \param socid Id of third party if known - * \param nolinks true means no HTML links is added - * \return string Formated phone number + * \brief Format phone numbers according to country + * \param phone Phone number to format + * \param country Country to use for formatting + * \param cid Id of contact if known + * \param socid Id of third party if known + * \param nolinks true means no HTML links is added + * \param separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx + * \return string Formated phone number */ -function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$nolinks=false) +function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$nolinks=false,$separ=" ") { global $conf,$user; @@ -731,25 +732,24 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$nolinks=fals if (strtoupper($country) == "FR") { // France - if (strlen($newphone) == 10) { - $newphone=substr($newphone,0,2)." ".substr($newphone,2,2)." ".substr($newphone,4,2)." ".substr($newphone,6,2)." ".substr($newphone,8,2); + if (strlen($phone) == 10) { + $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); } elseif (strlen($newphone) == 7) { - - $newphone=substr($newphone,0,3)." ".substr($newphone,3,2)." ".substr($newphone,5,2); + $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); } elseif (strlen($newphone) == 9) { - $newphone=substr($newphone,0,2)." ".substr($newphone,2,3)." ".substr($newphone,5,2)." ".substr($newphone,7,2); + $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); } elseif (strlen($newphone) == 11) { - $newphone=substr($newphone,0,3)." ".substr($newphone,3,2)." ".substr($newphone,5,2)." ".substr($newphone,7,2)." ".substr($newphone,9,2); + $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } elseif (strlen($newphone) == 12) { - $newphone=substr($newphone,0,4)." ".substr($newphone,4,2)." ".substr($newphone,6,2)." ".substr($newphone,8,2)." ".substr($newphone,10,2); + $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } @@ -760,12 +760,12 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$nolinks=fals $newphone=''.$newphone.''; } $clicktodiallink=dol_phone_link($phone); - if ($clicktodiallink) + if ($clicktodiallink) { $newphone='
| '.$newphone.' | '.$clicktodiallink.' |