- 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.
98 lines
3.9 KiB
PHP
98 lines
3.9 KiB
PHP
<?php
|
||
|
||
function GetCourt($ws_entity) {
|
||
require_once 'include/Webservices/Utils.php';
|
||
include_once 'modules/Users/Users.php';
|
||
require_once 'include/Webservices/Revise.php';
|
||
require_once 'includes/Loader.php';
|
||
vimport ('includes.runtime.Globals');
|
||
vimport ('includes.runtime.BaseModel');
|
||
vimport ('includes.runtime.LanguageHandler');
|
||
|
||
global $adb;
|
||
$user = Users::getActiveAdminUser(); // Получаем пользователя, под которым будем создавать записи
|
||
|
||
//$logstring = date('Y-m-d H:i:s').' - вошли в кастомный обработчик'.PHP_EOL;
|
||
//file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
|
||
// WS id
|
||
$ws_id = $ws_entity->getId();
|
||
$crmid = vtws_getCRMEntityId($ws_id);
|
||
//$logstring = date('Y-m-d H:i:s').' - получили ID проекта: '.$crmid.PHP_EOL;
|
||
//file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
|
||
$query = 'select a.mailingstreet
|
||
from vtiger_contactaddress a
|
||
left join vtiger_crmentity e on e.crmid = a.contactaddressid
|
||
where e.deleted = 0 and a.contactaddressid = '.$crmid;
|
||
$result = $adb->pquery($query);
|
||
|
||
if ($adb->num_rows($result) == 0) {
|
||
$logstring = date('Y-m-d H:i:s').' - очень странно, но Контакта с там ID нет...'.PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
} else {
|
||
$address = $adb->query_result($result, 0, "mailingstreet");
|
||
|
||
if (empty($address)) {
|
||
$logstring = date('Y-m-d H:i:s').' - Найден Контакт: '.$crmid.'; но в нем не указан адрес - видимо удалили'.PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
} else {
|
||
$enddate = $startdate;
|
||
$endtime= date('H:i:s', strtotime($starttime) + 3600);
|
||
|
||
$logstring = date('Y-m-d H:i:s').' - Найден Контакт: '.$crmid.'; адрес: '.$address.PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
|
||
$host = "https://api.xn----7sbarabva2auedgdkhac2adbeqt1tna3e.xn--p1ai/api"; // адрес сервера api
|
||
$token = "y4kNd3Li2NDxyOgaG37ZDuGTWg5CfF2A2dERwbFUjas"; // указать полученный токен
|
||
|
||
// запрос по адресу
|
||
$url = $host."?token=".$token."&address=".urlencode($address);
|
||
|
||
// запрос по координатам
|
||
//$coords = "49.099524 55.794340"; // координаты точки, разделитель - пробел
|
||
//$url = $host . "?token=" . $token . "&coords=" . urlencode($coords);
|
||
|
||
$curl = curl_init();
|
||
curl_setopt($curl, CURLOPT_URL, $url);
|
||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||
$data = curl_exec($curl);
|
||
curl_close($curl);
|
||
|
||
$logstring = date('Y-m-d H:i:s').' - Ответ от API-сервера: '.$data.PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
|
||
$court = json_decode($data, true);
|
||
$court = $court['request']['court_fs'];
|
||
|
||
$logstring = date('Y-m-d H:i:s').' - Даные суда: '.json_encode($court).PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
|
||
preg_match('/\((.*?)\)/', $court['title'], $matches);
|
||
$region = $matches[1];
|
||
|
||
try {
|
||
$params = array (
|
||
'id' => $ws_id,
|
||
'cf_1782' => $court['title'],
|
||
'cf_1784' => $court['address'],
|
||
'cf_1851' => $court['site'],
|
||
'cf_1857' => $court['email'],
|
||
'cf_1853' => $court['tel'],
|
||
'cf_1992' => $court['code'],
|
||
'mailingstate' => $region
|
||
);
|
||
|
||
$contact = vtws_revise($params, $user);
|
||
$logstring = date("Y-m-d H:i:s").' Контакт обновлен: '.$contact['id'];
|
||
file_put_contents('wfGetCourt.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
$contactid = substr($contact['id'], 3);
|
||
} catch (WebServiceException $ex) {
|
||
$logstring = date('Y-m-d H:i:s').' '.$ex->getMessage().PHP_EOL;
|
||
file_put_contents('wfGetCourt.log', $logstring, FILE_APPEND);
|
||
}
|
||
}
|
||
}
|
||
|
||
return;
|
||
} |