diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 287b8f9fd2a..86f69680d01 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -71,16 +71,31 @@ $var=!$var; print "".$langs->trans("LanguageParameter","PHP LC_NUMERIC")."".setlocale(LC_NUMERIC,0)."\n"; $var=!$var; print "".$langs->trans("LanguageParameter","PHP LC_TIME")."".setlocale(LC_TIME,0)."\n"; +//$var=!$var; +//print "".$langs->trans("LanguageParameter","PHP LC_MONETARY")."".setlocale(LC_MONETARY,0)."\n"; $var=!$var; -print "".$langs->trans("LanguageParameter","PHP LC_MONETARY")."".setlocale(LC_MONETARY,0)."\n"; +print "=> price2num(1234.56)'.price2num(1233.56+1,'MT').""; +$var=!$var; +print "=> dolibarr_print_date(0,"daytext")'.dolibarr_print_date(0,"daytext").""; +// Thousands +$var=!$var; +$thousand=$langs->trans("SeparatorThousand"); +if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method +print "".$langs->trans("CurrentValueSeparatorThousand")."".($thousand==' '?$langs->trans("Space"):$thousand)."\n"; // Decimals $var=!$var; $dec=$langs->trans("SeparatorDecimal"); print "".$langs->trans("CurrentValueSeparatorDecimal")."".$dec."\n"; $var=!$var; -$thousand=$langs->trans("SeparatorThousand"); -if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method -print "".$langs->trans("CurrentValueSeparatorThousand")."".$thousand."\n"; +print "=> price2num('."'1".$thousand."234".$dec."56')".price2num("1".$thousand."234".$dec."56",'MT').""; +if ($thousand != ',' && $thousand != '.') +{ + $var=!$var; + print "=> price2num('."'1 234.56')".price2num("1 234.56",'MT').""; + print "\n"; +} + +print ''.$langs->trans("TimeZone").''.$langs->trans("Value").''."\n"; // Timezone $var=!$var; print "".$langs->trans("DolibarrTZ")."".$langs->trans("FeatureNotYetAvailable")."\n"; @@ -96,9 +111,9 @@ if (function_exists('date_default_timezone_get')) print "\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php } $var=!$var; -print "".$langs->trans("PHPServerOffsetWithGreenwich")."".(- dolibarr_mktime(0,0,0,1,1,1970))."\n"; +print "=> ".$langs->trans("PHPServerOffsetWithGreenwich")."".(- dolibarr_mktime(0,0,0,1,1,1970))."\n"; $var=!$var; -print "".$langs->trans("CurrentHour")."".dolibarr_print_date(time(),'dayhour')."\n"; +print "=> ".$langs->trans("CurrentHour")."".dolibarr_print_date(time(),'dayhour')."\n"; print ''; print '
'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 48e6ac089c2..3fb21a234af 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -37,6 +37,8 @@ UsePopupCalendar=Use popup for dates input UsePreviewTabs=Use preview tabs ShowPreview=Show preview ThemeCurrentlyActive=Theme currently active +CurrentTimeZone=Current TimeZone +Space=Space Fields=Fields Mask=Mask NextValue=Next value diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 3b825f60c5f..67f512e5fa4 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -37,6 +37,8 @@ UsePopupCalendar=Utiliser les popups pour la saisie des dates UsePreviewTabs=Afficher les onglets "Aperçu" ShowPreview=Afficher aperçu ThemeCurrentlyActive=Theme actuellement actif +CurrentTimeZone=TimeZone courant +Space=Espace Fields=Champs Mask=Masque NextValue=Prochaine valeur diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 6ca2ad78ac1..562d8a329f5 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -468,10 +468,10 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='') if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; - // Si date non definie, on renvoie '' - if ($time == '') return ''; // $time=0 permis car signifie 01/01/1970 00:00:00 - - // Analyse de la date + // If date undefined or "", we return "" + if (strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + + // Analyse de la date (deprecated) if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?',$time,$reg)) { // This part of code should not be used. @@ -492,7 +492,7 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='') $ret=adodb_strftime($format,$time,$to_gmt); } - // Page code for text from strftime functions + // What is page code of texts from strftime functions ? $pagecodefrom='ISO-8859-1'; $localtime=setlocale(LC_TIME,0); if (eregi('UTF',$localtime)) $pagecodefrom='UTF-8'; @@ -2148,14 +2148,10 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1) // Round PHP function does not allow number like '1,234.5' nor '1.234,5' nor '1 234,5' // Numbers must be '1234.5' // Decimal delimiter for database SQL request must be '.' - $dec=','; $thousand=' '; if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal"); if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand"); - // Define nbofdec - $nbofdec=max(0,strlen($amount-intval($amount))-2); - // Convert value to universal number format (no thousand separator, '.' as decimal separator) if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format { @@ -2163,7 +2159,11 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1) // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number // to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup. - $amount=number_format($amount,$nbofdec,$dec,$thousand); + if (is_numeric($amount)) + { + $nbofdec=max(0,strlen($amount-intval($amount))-2); + $amount=number_format($amount,$nbofdec,$dec,$thousand); + } //print "QQ".$amount.'
'; // Now make replace (the main goal of function) @@ -2186,7 +2186,11 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1) // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. - $amount=number_format($amount,min($nbofdec,$nbofdectoround),$dec,$thousand); // Convert amount to format with dolibarr dec and thousand + if (is_numeric($amount)) + { + $nbofdec=max(0,strlen($amount-intval($amount))-2); + $amount=number_format($amount,min($nbofdec,$nbofdectoround),$dec,$thousand); // Convert amount to format with dolibarr dec and thousand + } //print "RR".$amount.'
'; // Always make replace because each math function (like round) replace