45 if ($centimes && strlen((
string) $num) == 1) {
49 if (isModEnabled(
'numberwords')) {
50 $concatWords = $langs->getLabelFromNumber($num, $currency);
53 $TNum = explode(
'.', (
string) $num);
55 $num = (int) $TNum[0];
59 $langs->transnoentitiesnoconv(
'one'),
60 $langs->transnoentitiesnoconv(
'two'),
61 $langs->transnoentitiesnoconv(
'three'),
62 $langs->transnoentitiesnoconv(
'four'),
63 $langs->transnoentitiesnoconv(
'five'),
64 $langs->transnoentitiesnoconv(
'six'),
65 $langs->transnoentitiesnoconv(
'seven'),
66 $langs->transnoentitiesnoconv(
'eight'),
67 $langs->transnoentitiesnoconv(
'nine'),
68 $langs->transnoentitiesnoconv(
'ten'),
69 $langs->transnoentitiesnoconv(
'eleven'),
70 $langs->transnoentitiesnoconv(
'twelve'),
71 $langs->transnoentitiesnoconv(
'thirteen'),
72 $langs->transnoentitiesnoconv(
'fourteen'),
73 $langs->transnoentitiesnoconv(
'fifteen'),
74 $langs->transnoentitiesnoconv(
'sixteen'),
75 $langs->transnoentitiesnoconv(
'seventeen'),
76 $langs->transnoentitiesnoconv(
'eighteen'),
77 $langs->transnoentitiesnoconv(
'nineteen')
81 $langs->transnoentitiesnoconv(
'ten'),
82 $langs->transnoentitiesnoconv(
'twenty'),
83 $langs->transnoentitiesnoconv(
'thirty'),
84 $langs->transnoentitiesnoconv(
'forty'),
85 $langs->transnoentitiesnoconv(
'fifty'),
86 $langs->transnoentitiesnoconv(
'sixty'),
87 $langs->transnoentitiesnoconv(
'seventy'),
88 $langs->transnoentitiesnoconv(
'eighty'),
89 $langs->transnoentitiesnoconv(
'ninety'),
90 $langs->transnoentitiesnoconv(
'hundred')
94 $langs->transnoentitiesnoconv(
'thousand'),
95 $langs->transnoentitiesnoconv(
'million'),
96 $langs->transnoentitiesnoconv(
'billion'),
97 $langs->transnoentitiesnoconv(
'trillion'),
98 $langs->transnoentitiesnoconv(
'quadrillion')
101 $num_length = strlen((
string) $num);
102 $levels = (int) (($num_length + 2) / 3);
103 $max_length = $levels * 3;
104 $num = substr(
'00'.$num, -$max_length);
105 $num_levels = str_split($num, 3);
106 $nboflevels = count($num_levels);
107 for ($i = 0; $i < $nboflevels; $i++) {
109 $hundreds = (int) ((
int) $num_levels[$i] / 100);
110 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').($hundreds == 1 ?
'' :
's').
' ' :
'');
111 $tens = (int) ((
int) $num_levels[$i] % 100);
114 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
116 $tens = (int) ($tens / 10);
117 $tens =
' '.$list2[$tens].
' ';
118 $singles = (int) ((
int) $num_levels[$i] % 10);
119 $singles =
' '.$list1[$singles].
' ';
121 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
123 $commas = count($words);
127 $concatWords = implode(
' ', $words);
129 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
131 if (!empty($currency)) {
132 $concatWords .=
' '.$currency;
136 $decimalpart = empty($TNum[1]) ?
'' : preg_replace(
'/0+$/',
'', $TNum[1]);
139 if (!empty($currency)) {
140 $concatWords .=
' '.$langs->transnoentities(
'and');
143 $concatWords .=
' '.dol_convertToWord((
float) $decimalpart, $langs,
'',
true);
144 if (!empty($currency)) {
145 $concatWords .=
' '.$langs->transnoentities(
'centimes');
168 if ($numero >= 1000000000001) {
173 $strnumber = number_format($numero, 10);
174 $len = strlen($strnumber);
175 $parte_decimal =
'00';
176 for ($i = 0; $i < $len; $i++) {
177 if ($strnumber[$i] ==
'.') {
178 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
184 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
185 if ($numero >= 1 && $numero < 2) {
186 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
187 } elseif ($numero >= 0 && $numero < 1) {
188 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
189 } elseif ($numero >= 1000000 && $numero < 1000001) {
190 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
191 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
192 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
196 if ($number >= 1000000000) {
197 $CdMMillon = (int) ($numero / 100000000000);
198 $numero -= $CdMMillon * 100000000000;
199 $DdMMillon = (int) ($numero / 10000000000);
200 $numero -= $DdMMillon * 10000000000;
201 $UdMMillon = (int) ($numero / 1000000000);
202 $numero -= $UdMMillon * 1000000000;
203 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
210 if ($number >= 1000000) {
211 $CdMILLON = (int) ($numero / 100000000);
212 $numero -= $CdMILLON * 100000000;
213 $DdMILLON = (int) ($numero / 10000000);
214 $numero -= $DdMILLON * 10000000;
215 $udMILLON = (int) ($numero / 1000000);
216 $numero -= $udMILLON * 1000000;
218 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
219 $entexto .=
" MILLÓN ";
221 $entexto .=
" MILLONES ";
225 if ($number >= 1000) {
226 $cdm = (int) ($numero / 100000);
227 $numero -= $cdm * 100000;
228 $ddm = (int) ($numero / 10000);
229 $numero -= $ddm * 10000;
230 $udm = (int) ($numero / 1000);
231 $numero -= $udm * 1000;
233 if ($cdm || $ddm || $udm) {
241 $c = (int) ($numero / 100);
243 $d = (int) ($numero / 10);
244 $u = (int) $numero - $d * 10;
246 if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) {
249 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";
266 if ($hundreds == 1 && $tens == 0 && $units == 0) {
269 $centenas = array(
"CIENTO",
"DOSCIENTOS",
"TRESCIENTOS",
"CUATROCIENTOS",
"QUINIENTOS",
"SEISCIENTOS",
"SETECIENTOS",
"OCHOCIENTOS",
"NOVECIENTOS");
270 $decenas = array(
"",
"",
"TREINTA ",
"CUARENTA ",
"CINCUENTA ",
"SESENTA ",
"SETENTA ",
"OCHENTA ",
"NOVENTA ");
271 $veintis = array(
"VEINTE",
"VEINTIUN",
"VEINTIDÓS",
"VEINTITRÉS",
"VEINTICUATRO",
"VEINTICINCO",
"VEINTISÉIS",
"VEINTISIETE",
"VEINTIOCHO",
"VEINTINUEVE");
272 $diecis = array(
"DIEZ",
"ONCE",
"DOCE",
"TRECE",
"CATORCE",
"QUINCE",
"DIECISÉIS",
"DIECISIETE",
"DIECIOCHO",
"DIECINUEVE");
273 $unidades = array(
"UN",
"DOS",
"TRES",
"CUATRO",
"CINCO",
"SEIS",
"SIETE",
"OCHO",
"NUEVE");
275 if ($hundreds != 0) {
276 $entexto .= $centenas[$hundreds - 1];
279 if ($hundreds != 0) {
282 $entexto .= $decenas[$tens - 1];
285 $entexto .= $unidades[$units - 1];
288 } elseif ($tens == 2) {
289 if ($hundreds != 0) {
292 $entexto .=
" ".$veintis[$units];
294 } elseif ($tens == 1) {
295 if ($hundreds != 0) {
298 $entexto .= $diecis[$units];
302 if ($hundreds != 0 || $tens != 0) {
305 $entexto .= $unidades[$units - 1];