45 if ($centimes && strlen((
string) $num) == 1) {
50 $concatWords = $langs->getLabelFromNumber((
string) $num, $currency);
53 $TNum = explode(
'.', (
string) $num);
55 $num = abs((
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);
111 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').
' ' :
'');
112 $tens = (int) ((
int) $num_levels[$i] % 100);
115 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
117 $tsd = (int) ($tens / 10);
118 $usd = (int) ($tens % 10);
122 $tenWord = trim($list1[10]);
123 if ($usd > 0 && ($tsd == 7 || $tsd == 9) && $tenWord !==
'' && strpos(trim($list2[$tsd]), $tenWord) !==
false) {
125 $baseWord = trim($list2[$tsd - 1]);
127 if (substr($baseWord, -1) ===
's') {
128 $baseWord = substr($baseWord, 0, -1);
130 $tens =
' '.$baseWord.
' ';
131 $singles =
' '.$list1[10 + $usd].
' ';
133 $tens =
' '.$list2[$tsd].
' ';
134 $singles =
' '.$list1[$usd].
' ';
137 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
139 $commas = count($words);
143 $concatWords = implode(
' ', $words);
145 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
147 if (!empty($currency)) {
148 $concatWords .=
' '.$currency;
152 $decimalpart = empty($TNum[1]) ?
'' : preg_replace(
'/0+$/',
'', $TNum[1]);
155 if (!empty($currency)) {
156 $concatWords .=
' '.$langs->transnoentities(
'and');
159 $concatWords .=
' '.dol_convertToWord((
float) $decimalpart, $langs,
'',
true);
160 if (!empty($currency)) {
161 $concatWords .=
' '.$langs->transnoentities(
'centimes');
185 if ($numero >= 1000000000001) {
190 $strnumber = number_format($numero, 10);
191 $len = strlen($strnumber);
192 $parte_decimal =
'00';
193 for ($i = 0; $i < $len; $i++) {
194 if ($strnumber[$i] ==
'.') {
195 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
201 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
202 if ($numero >= 1 && $numero < 2) {
203 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
204 } elseif ($numero >= 0 && $numero < 1) {
205 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
206 } elseif ($numero >= 1000000 && $numero < 1000001) {
207 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
208 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
209 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
213 if ($number >= 1000000000) {
214 $CdMMillon = (int) ($numero / 100000000000);
215 $numero -= $CdMMillon * 100000000000;
216 $DdMMillon = (int) ($numero / 10000000000);
217 $numero -= $DdMMillon * 10000000000;
218 $UdMMillon = (int) ($numero / 1000000000);
219 $numero -= $UdMMillon * 1000000000;
220 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
227 if ($number >= 1000000) {
228 $CdMILLON = (int) ($numero / 100000000);
229 $numero -= $CdMILLON * 100000000;
230 $DdMILLON = (int) ($numero / 10000000);
231 $numero -= $DdMILLON * 10000000;
232 $udMILLON = (int) ($numero / 1000000);
233 $numero -= $udMILLON * 1000000;
235 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
236 $entexto .=
" MILLÓN ";
238 $entexto .=
" MILLONES ";
242 if ($number >= 1000) {
243 $cdm = (int) ($numero / 100000);
244 $numero -= $cdm * 100000;
245 $ddm = (int) ($numero / 10000);
246 $numero -= $ddm * 10000;
247 $udm = (int) ($numero / 1000);
248 $numero -= $udm * 1000;
250 if ($cdm || $ddm || $udm) {
258 $c = (int) ($numero / 100);
260 $d = (int) ($numero / 10);
261 $u = (int) $numero - $d * 10;
263 if (!$cdm && !$ddm && !$udm && !
$c && !$d && !$u && $number > 1000000) {
266 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";
283 if ($hundreds == 1 && $tens == 0 && $units == 0) {
286 $centenas = array(
"CIENTO",
"DOSCIENTOS",
"TRESCIENTOS",
"CUATROCIENTOS",
"QUINIENTOS",
"SEISCIENTOS",
"SETECIENTOS",
"OCHOCIENTOS",
"NOVECIENTOS");
287 $decenas = array(
"",
"",
"TREINTA ",
"CUARENTA ",
"CINCUENTA ",
"SESENTA ",
"SETENTA ",
"OCHENTA ",
"NOVENTA ");
288 $veintis = array(
"VEINTE",
"VEINTIUN",
"VEINTIDÓS",
"VEINTITRÉS",
"VEINTICUATRO",
"VEINTICINCO",
"VEINTISÉIS",
"VEINTISIETE",
"VEINTIOCHO",
"VEINTINUEVE");
289 $diecis = array(
"DIEZ",
"ONCE",
"DOCE",
"TRECE",
"CATORCE",
"QUINCE",
"DIECISÉIS",
"DIECISIETE",
"DIECIOCHO",
"DIECINUEVE");
290 $unidades = array(
"UN",
"DOS",
"TRES",
"CUATRO",
"CINCO",
"SEIS",
"SIETE",
"OCHO",
"NUEVE");
292 if ($hundreds != 0) {
293 $entexto .= $centenas[$hundreds - 1];
296 if ($hundreds != 0) {
299 $entexto .= $decenas[$tens - 1];
302 $entexto .= $unidades[$units - 1];
305 } elseif ($tens == 2) {
306 if ($hundreds != 0) {
309 $entexto .=
" ".$veintis[$units];
311 } elseif ($tens == 1) {
312 if ($hundreds != 0) {
315 $entexto .= $diecis[$units];
319 if ($hundreds != 0 || $tens != 0) {
322 $entexto .= $unidades[$units - 1];