46 if ($centimes && strlen((
string) $num) == 1) {
50 if (isModEnabled(
'numberwords')) {
57 $concatWords = $langs->getLabelFromNumber($num, $type);
60 $TNum = explode(
'.', (
string) $num);
62 $num = (int) $TNum[0];
66 $langs->transnoentitiesnoconv(
'one'),
67 $langs->transnoentitiesnoconv(
'two'),
68 $langs->transnoentitiesnoconv(
'three'),
69 $langs->transnoentitiesnoconv(
'four'),
70 $langs->transnoentitiesnoconv(
'five'),
71 $langs->transnoentitiesnoconv(
'six'),
72 $langs->transnoentitiesnoconv(
'seven'),
73 $langs->transnoentitiesnoconv(
'eight'),
74 $langs->transnoentitiesnoconv(
'nine'),
75 $langs->transnoentitiesnoconv(
'ten'),
76 $langs->transnoentitiesnoconv(
'eleven'),
77 $langs->transnoentitiesnoconv(
'twelve'),
78 $langs->transnoentitiesnoconv(
'thirteen'),
79 $langs->transnoentitiesnoconv(
'fourteen'),
80 $langs->transnoentitiesnoconv(
'fifteen'),
81 $langs->transnoentitiesnoconv(
'sixteen'),
82 $langs->transnoentitiesnoconv(
'seventeen'),
83 $langs->transnoentitiesnoconv(
'eighteen'),
84 $langs->transnoentitiesnoconv(
'nineteen')
88 $langs->transnoentitiesnoconv(
'ten'),
89 $langs->transnoentitiesnoconv(
'twenty'),
90 $langs->transnoentitiesnoconv(
'thirty'),
91 $langs->transnoentitiesnoconv(
'forty'),
92 $langs->transnoentitiesnoconv(
'fifty'),
93 $langs->transnoentitiesnoconv(
'sixty'),
94 $langs->transnoentitiesnoconv(
'seventy'),
95 $langs->transnoentitiesnoconv(
'eighty'),
96 $langs->transnoentitiesnoconv(
'ninety'),
97 $langs->transnoentitiesnoconv(
'hundred')
101 $langs->transnoentitiesnoconv(
'thousand'),
102 $langs->transnoentitiesnoconv(
'million'),
103 $langs->transnoentitiesnoconv(
'billion'),
104 $langs->transnoentitiesnoconv(
'trillion'),
105 $langs->transnoentitiesnoconv(
'quadrillion')
108 $num_length = strlen((
string) $num);
109 $levels = (int) (($num_length + 2) / 3);
110 $max_length = $levels * 3;
111 $num = substr(
'00'.$num, -$max_length);
112 $num_levels = str_split($num, 3);
113 $nboflevels = count($num_levels);
114 for ($i = 0; $i < $nboflevels; $i++) {
116 $hundreds = (int) ($num_levels[$i] / 100);
117 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').($hundreds == 1 ?
'' :
's').
' ' :
'');
118 $tens = (int) ($num_levels[$i] % 100);
121 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
123 $tens = (int) ($tens / 10);
124 $tens =
' '.$list2[$tens].
' ';
125 $singles = (int) ($num_levels[$i] % 10);
126 $singles =
' '.$list1[$singles].
' ';
128 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
130 $commas = count($words);
132 $commas = $commas - 1;
134 $concatWords = implode(
' ', $words);
136 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
138 if (!empty($currency)) {
139 $concatWords .=
' '.$currency;
143 $decimalpart = empty($TNum[1]) ?
'' : preg_replace(
'/0+$/',
'', $TNum[1]);
146 if (!empty($currency)) {
147 $concatWords .=
' '.$langs->transnoentities(
'and');
150 $concatWords .=
' '.dol_convertToWord($decimalpart, $langs,
'',
true);
151 if (!empty($currency)) {
152 $concatWords .=
' '.$langs->transnoentities(
'centimes');
175 if ($numero >= 1000000000001) {
180 $strnumber = number_format($numero, 10);
181 $len = strlen($strnumber);
182 for ($i = 0; $i < $len; $i++) {
183 if ($strnumber[$i] ==
'.') {
184 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
191 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
192 if ($numero >= 1 && $numero < 2) {
193 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
194 } elseif ($numero >= 0 && $numero < 1) {
195 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
196 } elseif ($numero >= 1000000 && $numero < 1000001) {
197 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
198 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
199 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
203 if ($number >= 1000000000) {
204 $CdMMillon = (int) ($numero / 100000000000);
205 $numero = $numero - $CdMMillon * 100000000000;
206 $DdMMillon = (int) ($numero / 10000000000);
207 $numero = $numero - $DdMMillon * 10000000000;
208 $UdMMillon = (int) ($numero / 1000000000);
209 $numero = $numero - $UdMMillon * 1000000000;
210 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
213 if ($number >= 1000000) {
214 $CdMILLON = (int) ($numero / 100000000);
215 $numero = $numero - $CdMILLON * 100000000;
216 $DdMILLON = (int) ($numero / 10000000);
217 $numero = $numero - $DdMILLON * 10000000;
218 $udMILLON = (int) ($numero / 1000000);
219 $numero = $numero - $udMILLON * 1000000;
221 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
222 $entexto .=
" MILLÓN ";
224 $entexto .=
" MILLONES ";
227 if ($number >= 1000) {
228 $cdm = (int) ($numero / 100000);
229 $numero = $numero - $cdm * 100000;
230 $ddm = (int) ($numero / 10000);
231 $numero = $numero - $ddm * 10000;
232 $udm = (int) ($numero / 1000);
233 $numero = $numero - $udm * 1000;
235 if ($cdm || $ddm || $udm) {
239 $c = (int) ($numero / 100);
240 $numero = $numero - $c * 100;
241 $d = (int) ($numero / 10);
242 $u = (int) $numero - $d * 10;
244 if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) {
247 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";
264 if ($hundreds == 1 && $tens == 0 && $units == 0) {
267 $centenas = array(
"CIENTO",
"DOSCIENTOS",
"TRESCIENTOS",
"CUATROCIENTOS",
"QUINIENTOS",
"SEISCIENTOS",
"SETECIENTOS",
"OCHOCIENTOS",
"NOVECIENTOS");
268 $decenas = array(
"",
"",
"TREINTA ",
"CUARENTA ",
"CINCUENTA ",
"SESENTA ",
"SETENTA ",
"OCHENTA ",
"NOVENTA ");
269 $veintis = array(
"VEINTE",
"VEINTIUN",
"VEINTIDÓS",
"VEINTITRÉS",
"VEINTICUATRO",
"VEINTICINCO",
"VEINTISÉIS",
"VEINTISIETE",
"VEINTIOCHO",
"VEINTINUEVE");
270 $diecis = array(
"DIEZ",
"ONCE",
"DOCE",
"TRECE",
"CATORCE",
"QUINCE",
"DIECISÉIS",
"DIECISIETE",
"DIECIOCHO",
"DIECINUEVE");
271 $unidades = array(
"UN",
"DOS",
"TRES",
"CUATRO",
"CINCO",
"SEIS",
"SIETE",
"OCHO",
"NUEVE");
273 if ($hundreds != 0) {
274 $entexto .= $centenas[$hundreds - 1];
277 if ($hundreds != 0) {
280 $entexto .= $decenas[$tens - 1];
283 $entexto .= $unidades[$units - 1];
286 } elseif ($tens == 2) {
287 if ($hundreds != 0) {
290 $entexto .=
" ".$veintis[$units];
292 } elseif ($tens == 1) {
293 if ($hundreds != 0) {
296 $entexto .= $diecis[$units];
300 if ($hundreds != 0 || $tens != 0) {
303 $entexto .= $unidades[$units - 1];