45 if ($centimes && strlen($num) == 1) {
49 if (isModEnabled(
'numberwords')) {
56 $concatWords = $langs->getLabelFromNumber($num, $type);
59 $TNum = explode(
'.', $num);
61 $num = (int) $TNum[0];
65 $langs->transnoentitiesnoconv(
'one'),
66 $langs->transnoentitiesnoconv(
'two'),
67 $langs->transnoentitiesnoconv(
'three'),
68 $langs->transnoentitiesnoconv(
'four'),
69 $langs->transnoentitiesnoconv(
'five'),
70 $langs->transnoentitiesnoconv(
'six'),
71 $langs->transnoentitiesnoconv(
'seven'),
72 $langs->transnoentitiesnoconv(
'eight'),
73 $langs->transnoentitiesnoconv(
'nine'),
74 $langs->transnoentitiesnoconv(
'ten'),
75 $langs->transnoentitiesnoconv(
'eleven'),
76 $langs->transnoentitiesnoconv(
'twelve'),
77 $langs->transnoentitiesnoconv(
'thirteen'),
78 $langs->transnoentitiesnoconv(
'fourteen'),
79 $langs->transnoentitiesnoconv(
'fifteen'),
80 $langs->transnoentitiesnoconv(
'sixteen'),
81 $langs->transnoentitiesnoconv(
'seventeen'),
82 $langs->transnoentitiesnoconv(
'eighteen'),
83 $langs->transnoentitiesnoconv(
'nineteen')
87 $langs->transnoentitiesnoconv(
'ten'),
88 $langs->transnoentitiesnoconv(
'twenty'),
89 $langs->transnoentitiesnoconv(
'thirty'),
90 $langs->transnoentitiesnoconv(
'forty'),
91 $langs->transnoentitiesnoconv(
'fifty'),
92 $langs->transnoentitiesnoconv(
'sixty'),
93 $langs->transnoentitiesnoconv(
'seventy'),
94 $langs->transnoentitiesnoconv(
'eighty'),
95 $langs->transnoentitiesnoconv(
'ninety'),
96 $langs->transnoentitiesnoconv(
'hundred')
100 $langs->transnoentitiesnoconv(
'thousand'),
101 $langs->transnoentitiesnoconv(
'million'),
102 $langs->transnoentitiesnoconv(
'billion'),
103 $langs->transnoentitiesnoconv(
'trillion'),
104 $langs->transnoentitiesnoconv(
'quadrillion')
107 $num_length = strlen($num);
108 $levels = (int) (($num_length + 2) / 3);
109 $max_length = $levels * 3;
110 $num = substr(
'00'.$num, -$max_length);
111 $num_levels = str_split($num, 3);
112 $nboflevels = count($num_levels);
113 for ($i = 0; $i < $nboflevels; $i++) {
115 $hundreds = (int) ($num_levels[$i] / 100);
116 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').($hundreds == 1 ?
'' :
's').
' ' :
'');
117 $tens = (int) ($num_levels[$i] % 100);
120 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
122 $tens = (int) ($tens / 10);
123 $tens =
' '.$list2[$tens].
' ';
124 $singles = (int) ($num_levels[$i] % 10);
125 $singles =
' '.$list1[$singles].
' ';
127 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
129 $commas = count($words);
131 $commas = $commas - 1;
133 $concatWords = implode(
' ', $words);
135 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
137 if (!empty($currency)) {
138 $concatWords .=
' '.$currency;
142 $decimalpart = empty($TNum[1]) ?
'' : preg_replace(
'/0+$/',
'', $TNum[1]);
145 if (!empty($currency)) {
146 $concatWords .=
' '.$langs->transnoentities(
'and');
149 $concatWords .=
' '.dol_convertToWord($decimalpart, $langs,
'',
true);
150 if (!empty($currency)) {
151 $concatWords .=
' '.$langs->transnoentities(
'centimes');
174 if ($numero >= 1000000000001) {
179 $strnumber = number_format($numero, 10);
180 $len = strlen($strnumber);
181 for ($i = 0; $i < $len; $i++) {
182 if ($strnumber[$i] ==
'.') {
183 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
190 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
191 if ($numero >= 1 && $numero < 2) {
192 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
193 } elseif ($numero >= 0 && $numero < 1) {
194 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
195 } elseif ($numero >= 1000000 && $numero < 1000001) {
196 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
197 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
198 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
202 if ($number >= 1000000000) {
203 $CdMMillon = (int) ($numero / 100000000000);
204 $numero = $numero - $CdMMillon * 100000000000;
205 $DdMMillon = (int) ($numero / 10000000000);
206 $numero = $numero - $DdMMillon * 10000000000;
207 $UdMMillon = (int) ($numero / 1000000000);
208 $numero = $numero - $UdMMillon * 1000000000;
209 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
212 if ($number >= 1000000) {
213 $CdMILLON = (int) ($numero / 100000000);
214 $numero = $numero - $CdMILLON * 100000000;
215 $DdMILLON = (int) ($numero / 10000000);
216 $numero = $numero - $DdMILLON * 10000000;
217 $udMILLON = (int) ($numero / 1000000);
218 $numero = $numero - $udMILLON * 1000000;
220 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
221 $entexto .=
" MILLÓN ";
223 $entexto .=
" MILLONES ";
226 if ($number >= 1000) {
227 $cdm = (int) ($numero / 100000);
228 $numero = $numero - $cdm * 100000;
229 $ddm = (int) ($numero / 10000);
230 $numero = $numero - $ddm * 10000;
231 $udm = (int) ($numero / 1000);
232 $numero = $numero - $udm * 1000;
234 if ($cdm || $ddm || $udm) {
238 $c = (int) ($numero / 100);
239 $numero = $numero - $c * 100;
240 $d = (int) ($numero / 10);
241 $u = (int) $numero - $d * 10;
243 if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) {
246 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";
263 if ($hundreds == 1 && $tens == 0 && $units == 0) {
266 $centenas = array(
"CIENTO",
"DOSCIENTOS",
"TRESCIENTOS",
"CUATROCIENTOS",
"QUINIENTOS",
"SEISCIENTOS",
"SETECIENTOS",
"OCHOCIENTOS",
"NOVECIENTOS");
267 $decenas = array(
"",
"",
"TREINTA ",
"CUARENTA ",
"CINCUENTA ",
"SESENTA ",
"SETENTA ",
"OCHENTA ",
"NOVENTA ");
268 $veintis = array(
"VEINTE",
"VEINTIUN",
"VEINTIDÓS",
"VEINTITRÉS",
"VEINTICUATRO",
"VEINTICINCO",
"VEINTISÉIS",
"VEINTISIETE",
"VEINTIOCHO",
"VEINTINUEVE");
269 $diecis = array(
"DIEZ",
"ONCE",
"DOCE",
"TRECE",
"CATORCE",
"QUINCE",
"DIECISÉIS",
"DIECISIETE",
"DIECIOCHO",
"DIECINUEVE");
270 $unidades = array(
"UN",
"DOS",
"TRES",
"CUATRO",
"CINCO",
"SEIS",
"SIETE",
"OCHO",
"NUEVE");
272 if ($hundreds != 0) {
273 $entexto .= $centenas[$hundreds - 1];
276 if ($hundreds != 0) {
279 $entexto .= $decenas[$tens - 1];
282 $entexto .= $unidades[$units - 1];
285 } elseif ($tens == 2) {
286 if ($hundreds != 0) {
289 $entexto .=
" ".$veintis[$units];
291 } elseif ($tens == 1) {
292 if ($hundreds != 0) {
295 $entexto .= $diecis[$units];
299 if ($hundreds != 0 || $tens != 0) {
302 $entexto .= $unidades[$units - 1];