44 if ($centimes && strlen((
string) $num) == 1) {
48 if (isModEnabled(
'numberwords')) {
49 $concatWords = $langs->getLabelFromNumber($num, $currency);
52 $TNum = explode(
'.', (
string) $num);
54 $num = (int) $TNum[0];
58 $langs->transnoentitiesnoconv(
'one'),
59 $langs->transnoentitiesnoconv(
'two'),
60 $langs->transnoentitiesnoconv(
'three'),
61 $langs->transnoentitiesnoconv(
'four'),
62 $langs->transnoentitiesnoconv(
'five'),
63 $langs->transnoentitiesnoconv(
'six'),
64 $langs->transnoentitiesnoconv(
'seven'),
65 $langs->transnoentitiesnoconv(
'eight'),
66 $langs->transnoentitiesnoconv(
'nine'),
67 $langs->transnoentitiesnoconv(
'ten'),
68 $langs->transnoentitiesnoconv(
'eleven'),
69 $langs->transnoentitiesnoconv(
'twelve'),
70 $langs->transnoentitiesnoconv(
'thirteen'),
71 $langs->transnoentitiesnoconv(
'fourteen'),
72 $langs->transnoentitiesnoconv(
'fifteen'),
73 $langs->transnoentitiesnoconv(
'sixteen'),
74 $langs->transnoentitiesnoconv(
'seventeen'),
75 $langs->transnoentitiesnoconv(
'eighteen'),
76 $langs->transnoentitiesnoconv(
'nineteen')
80 $langs->transnoentitiesnoconv(
'ten'),
81 $langs->transnoentitiesnoconv(
'twenty'),
82 $langs->transnoentitiesnoconv(
'thirty'),
83 $langs->transnoentitiesnoconv(
'forty'),
84 $langs->transnoentitiesnoconv(
'fifty'),
85 $langs->transnoentitiesnoconv(
'sixty'),
86 $langs->transnoentitiesnoconv(
'seventy'),
87 $langs->transnoentitiesnoconv(
'eighty'),
88 $langs->transnoentitiesnoconv(
'ninety'),
89 $langs->transnoentitiesnoconv(
'hundred')
93 $langs->transnoentitiesnoconv(
'thousand'),
94 $langs->transnoentitiesnoconv(
'million'),
95 $langs->transnoentitiesnoconv(
'billion'),
96 $langs->transnoentitiesnoconv(
'trillion'),
97 $langs->transnoentitiesnoconv(
'quadrillion')
100 $num_length = strlen((
string) $num);
101 $levels = (int) (($num_length + 2) / 3);
102 $max_length = $levels * 3;
103 $num = substr(
'00'.$num, -$max_length);
104 $num_levels = str_split($num, 3);
105 $nboflevels = count($num_levels);
106 for ($i = 0; $i < $nboflevels; $i++) {
108 $hundreds = (int) ($num_levels[$i] / 100);
109 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').($hundreds == 1 ?
'' :
's').
' ' :
'');
110 $tens = (int) ($num_levels[$i] % 100);
113 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
115 $tens = (int) ($tens / 10);
116 $tens =
' '.$list2[$tens].
' ';
117 $singles = (int) ($num_levels[$i] % 10);
118 $singles =
' '.$list1[$singles].
' ';
120 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
122 $commas = count($words);
124 $commas = $commas - 1;
126 $concatWords = implode(
' ', $words);
128 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
130 if (!empty($currency)) {
131 $concatWords .=
' '.$currency;
135 $decimalpart = empty($TNum[1]) ?
'' : preg_replace(
'/0+$/',
'', $TNum[1]);
138 if (!empty($currency)) {
139 $concatWords .=
' '.$langs->transnoentities(
'and');
142 $concatWords .=
' '.dol_convertToWord($decimalpart, $langs,
'',
true);
143 if (!empty($currency)) {
144 $concatWords .=
' '.$langs->transnoentities(
'centimes');
167 if ($numero >= 1000000000001) {
172 $strnumber = number_format($numero, 10);
173 $len = strlen($strnumber);
174 for ($i = 0; $i < $len; $i++) {
175 if ($strnumber[$i] ==
'.') {
176 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
183 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
184 if ($numero >= 1 && $numero < 2) {
185 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
186 } elseif ($numero >= 0 && $numero < 1) {
187 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
188 } elseif ($numero >= 1000000 && $numero < 1000001) {
189 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
190 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
191 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
195 if ($number >= 1000000000) {
196 $CdMMillon = (int) ($numero / 100000000000);
197 $numero = $numero - $CdMMillon * 100000000000;
198 $DdMMillon = (int) ($numero / 10000000000);
199 $numero = $numero - $DdMMillon * 10000000000;
200 $UdMMillon = (int) ($numero / 1000000000);
201 $numero = $numero - $UdMMillon * 1000000000;
202 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
205 if ($number >= 1000000) {
206 $CdMILLON = (int) ($numero / 100000000);
207 $numero = $numero - $CdMILLON * 100000000;
208 $DdMILLON = (int) ($numero / 10000000);
209 $numero = $numero - $DdMILLON * 10000000;
210 $udMILLON = (int) ($numero / 1000000);
211 $numero = $numero - $udMILLON * 1000000;
213 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
214 $entexto .=
" MILLÓN ";
216 $entexto .=
" MILLONES ";
219 if ($number >= 1000) {
220 $cdm = (int) ($numero / 100000);
221 $numero = $numero - $cdm * 100000;
222 $ddm = (int) ($numero / 10000);
223 $numero = $numero - $ddm * 10000;
224 $udm = (int) ($numero / 1000);
225 $numero = $numero - $udm * 1000;
227 if ($cdm || $ddm || $udm) {
231 $c = (int) ($numero / 100);
232 $numero = $numero - $c * 100;
233 $d = (int) ($numero / 10);
234 $u = (int) $numero - $d * 10;
236 if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) {
239 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";
256 if ($hundreds == 1 && $tens == 0 && $units == 0) {
259 $centenas = array(
"CIENTO",
"DOSCIENTOS",
"TRESCIENTOS",
"CUATROCIENTOS",
"QUINIENTOS",
"SEISCIENTOS",
"SETECIENTOS",
"OCHOCIENTOS",
"NOVECIENTOS");
260 $decenas = array(
"",
"",
"TREINTA ",
"CUARENTA ",
"CINCUENTA ",
"SESENTA ",
"SETENTA ",
"OCHENTA ",
"NOVENTA ");
261 $veintis = array(
"VEINTE",
"VEINTIUN",
"VEINTIDÓS",
"VEINTITRÉS",
"VEINTICUATRO",
"VEINTICINCO",
"VEINTISÉIS",
"VEINTISIETE",
"VEINTIOCHO",
"VEINTINUEVE");
262 $diecis = array(
"DIEZ",
"ONCE",
"DOCE",
"TRECE",
"CATORCE",
"QUINCE",
"DIECISÉIS",
"DIECISIETE",
"DIECIOCHO",
"DIECINUEVE");
263 $unidades = array(
"UN",
"DOS",
"TRES",
"CUATRO",
"CINCO",
"SEIS",
"SIETE",
"OCHO",
"NUEVE");
265 if ($hundreds != 0) {
266 $entexto .= $centenas[$hundreds - 1];
269 if ($hundreds != 0) {
272 $entexto .= $decenas[$tens - 1];
275 $entexto .= $unidades[$units - 1];
278 } elseif ($tens == 2) {
279 if ($hundreds != 0) {
282 $entexto .=
" ".$veintis[$units];
284 } elseif ($tens == 1) {
285 if ($hundreds != 0) {
288 $entexto .= $diecis[$units];
292 if ($hundreds != 0 || $tens != 0) {
295 $entexto .= $unidades[$units - 1];