- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
252 lines
8.5 KiB
PHP
252 lines
8.5 KiB
PHP
<?php
|
|
/*** Portions created by IT-Solutions4You (ITS4YOU) are Copyright (C) IT-Solutions4You s.r.o.
|
|
* ITS4YOU-CR MaSo 20/1/2014
|
|
* A function for print the total value in words
|
|
* based on http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
|
|
* [CUSTOMFUNCTION|convert_number_to_words|number|CUSTOMFUNCTION]
|
|
* for example:
|
|
* [CUSTOMFUNCTION|convert_number_to_words|$TOTAL$|CUSTOMFUNCTION] *
|
|
*/
|
|
|
|
if (!function_exists('convert_number_to_words')) {
|
|
function convert_number_to_words($number)
|
|
{
|
|
|
|
$data = its4you_formatNumberInfo($number);
|
|
$number = $data['float'];
|
|
|
|
$hyphen = '-';
|
|
$conjunction = ' and ';
|
|
$separator = ', ';
|
|
$negative = 'negative ';
|
|
$decimal = ' point ';
|
|
$dictionary = array(
|
|
0 => 'zero',
|
|
1 => 'one',
|
|
2 => 'two',
|
|
3 => 'three',
|
|
4 => 'four',
|
|
5 => 'five',
|
|
6 => 'six',
|
|
7 => 'seven',
|
|
8 => 'eight',
|
|
9 => 'nine',
|
|
10 => 'ten',
|
|
11 => 'eleven',
|
|
12 => 'twelve',
|
|
13 => 'thirteen',
|
|
14 => 'fourteen',
|
|
15 => 'fifteen',
|
|
16 => 'sixteen',
|
|
17 => 'seventeen',
|
|
18 => 'eighteen',
|
|
19 => 'nineteen',
|
|
20 => 'twenty',
|
|
30 => 'thirty',
|
|
40 => 'fourty',
|
|
50 => 'fifty',
|
|
60 => 'sixty',
|
|
70 => 'seventy',
|
|
80 => 'eighty',
|
|
90 => 'ninety',
|
|
100 => 'hundred',
|
|
1000 => 'thousand',
|
|
1000000 => 'million',
|
|
1000000000 => 'billion',
|
|
1000000000000 => 'trillion',
|
|
1000000000000000 => 'quadrillion',
|
|
1000000000000000000 => 'quintillion'
|
|
);
|
|
|
|
if (!is_numeric($number)) {
|
|
return false;
|
|
}
|
|
|
|
if (($number >= 0 && (int)$number < 0) || (int)$number < 0 - PHP_INT_MAX) {
|
|
// overflow
|
|
trigger_error(
|
|
'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
|
|
E_USER_WARNING
|
|
);
|
|
return false;
|
|
}
|
|
|
|
if ($number < 0) {
|
|
return $negative . convert_number_to_words(abs($number));
|
|
}
|
|
|
|
$string = $fraction = null;
|
|
|
|
if (strpos($number, '.') !== false) {
|
|
list($number, $fraction) = explode('.', $number);
|
|
}
|
|
|
|
switch (true) {
|
|
case $number < 21:
|
|
$string = $dictionary[$number];
|
|
break;
|
|
case $number < 100:
|
|
$tens = ((int)($number / 10)) * 10;
|
|
$units = $number % 10;
|
|
$string = $dictionary[$tens];
|
|
if ($units) {
|
|
$string .= $hyphen . $dictionary[$units];
|
|
}
|
|
break;
|
|
case $number < 1000:
|
|
$hundreds = $number / 100;
|
|
$remainder = $number % 100;
|
|
$string = $dictionary[$hundreds] . ' ' . $dictionary[100];
|
|
if ($remainder) {
|
|
$string .= $conjunction . convert_number_to_words($remainder);
|
|
}
|
|
break;
|
|
default:
|
|
$baseUnit = pow(1000, floor(log($number, 1000)));
|
|
$numBaseUnits = (int)($number / $baseUnit);
|
|
$remainder = $number % $baseUnit;
|
|
$string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
|
|
if ($remainder) {
|
|
$string .= $remainder < 100 ? $conjunction : $separator;
|
|
$string .= convert_number_to_words($remainder);
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (null !== $fraction && is_numeric($fraction)) {
|
|
$string .= $decimal;
|
|
$words = array();
|
|
foreach (str_split((string)$fraction) as $number) {
|
|
$words[] = $dictionary[$number];
|
|
}
|
|
$string .= implode(' ', $words);
|
|
}
|
|
|
|
return $string;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('convert_number_to_words_translated')) {
|
|
function convert_number_to_words_translated($number)
|
|
{
|
|
global $PDFContent;
|
|
|
|
$module = $PDFContent::$module;
|
|
$language = $PDFContent::$language;
|
|
$data = its4you_formatNumberInfo($number);
|
|
$number = $data['float'];
|
|
|
|
$hyphen = '-';
|
|
$conjunction = ' ' . Vtiger_Language_Handler::getTranslatedString('and', $module, $language) . ' ';
|
|
$separator = ', ';
|
|
$negative = Vtiger_Language_Handler::getTranslatedString('negative', $module, $language) . ' ';
|
|
$decimal = ' ' . Vtiger_Language_Handler::getTranslatedString('point', $module, $language) . ' ';
|
|
$dictionary = array(
|
|
0 => 'zero',
|
|
1 => 'one',
|
|
2 => 'two',
|
|
3 => 'three',
|
|
4 => 'four',
|
|
5 => 'five',
|
|
6 => 'six',
|
|
7 => 'seven',
|
|
8 => 'eight',
|
|
9 => 'nine',
|
|
10 => 'ten',
|
|
11 => 'eleven',
|
|
12 => 'twelve',
|
|
13 => 'thirteen',
|
|
14 => 'fourteen',
|
|
15 => 'fifteen',
|
|
16 => 'sixteen',
|
|
17 => 'seventeen',
|
|
18 => 'eighteen',
|
|
19 => 'nineteen',
|
|
20 => 'twenty',
|
|
30 => 'thirty',
|
|
40 => 'fourty',
|
|
50 => 'fifty',
|
|
60 => 'sixty',
|
|
70 => 'seventy',
|
|
80 => 'eighty',
|
|
90 => 'ninety',
|
|
100 => 'hundred',
|
|
1000 => 'thousand',
|
|
1000000 => 'million',
|
|
1000000000 => 'billion',
|
|
1000000000000 => 'trillion',
|
|
1000000000000000 => 'quadrillion',
|
|
1000000000000000000 => 'quintillion'
|
|
);
|
|
|
|
foreach ($dictionary as $dictionaryKey => $dictionaryValue) {
|
|
$dictionary[$dictionaryKey] = Vtiger_Language_Handler::getTranslatedString($dictionaryValue, $module, $language);
|
|
}
|
|
|
|
if (!is_numeric($number)) {
|
|
return false;
|
|
}
|
|
|
|
if (($number >= 0 && (int)$number < 0) || (int)$number < 0 - PHP_INT_MAX) {
|
|
// overflow
|
|
trigger_error(
|
|
'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
|
|
E_USER_WARNING
|
|
);
|
|
return false;
|
|
}
|
|
|
|
if ($number < 0) {
|
|
return $negative . convert_number_to_words(abs($number));
|
|
}
|
|
|
|
$string = $fraction = null;
|
|
|
|
if (strpos($number, '.') !== false) {
|
|
list($number, $fraction) = explode('.', $number);
|
|
}
|
|
|
|
switch (true) {
|
|
case $number < 21:
|
|
$string = $dictionary[$number];
|
|
break;
|
|
case $number < 100:
|
|
$tens = ((int)($number / 10)) * 10;
|
|
$units = $number % 10;
|
|
$string = $dictionary[$tens];
|
|
if ($units) {
|
|
$string .= $hyphen . $dictionary[$units];
|
|
}
|
|
break;
|
|
case $number < 1000:
|
|
$hundreds = $number / 100;
|
|
$remainder = $number % 100;
|
|
$string = $dictionary[$hundreds] . ' ' . $dictionary[100];
|
|
if ($remainder) {
|
|
$string .= $conjunction . convert_number_to_words($remainder);
|
|
}
|
|
break;
|
|
default:
|
|
$baseUnit = pow(1000, floor(log($number, 1000)));
|
|
$numBaseUnits = (int)($number / $baseUnit);
|
|
$remainder = $number % $baseUnit;
|
|
$string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
|
|
if ($remainder) {
|
|
$string .= $remainder < 100 ? $conjunction : $separator;
|
|
$string .= convert_number_to_words($remainder);
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (null !== $fraction && is_numeric($fraction)) {
|
|
$string .= $decimal;
|
|
$words = array();
|
|
foreach (str_split((string)$fraction) as $number) {
|
|
$words[] = $dictionary[$number];
|
|
}
|
|
$string .= implode(' ', $words);
|
|
}
|
|
|
|
return $string;
|
|
}
|
|
} |