- 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.
97 lines
4.2 KiB
PHP
97 lines
4.2 KiB
PHP
<?php
|
||
/*********************************************************************************
|
||
* API-интерфейс для создания Контакта
|
||
* All Rights Reserved.
|
||
* Contributor(s): Илья Руденко itsaturn@yandex.ru
|
||
********************************************************************************/
|
||
|
||
include_once 'include/Webservices/Query.php';
|
||
include_once 'modules/Users/Users.php';
|
||
require_once('include/Webservices/Utils.php');
|
||
require_once 'include/Webservices/Create.php';
|
||
require_once 'include/Webservices/Revise.php';
|
||
require_once 'includes/Loader.php';
|
||
vimport ('includes.runtime.Globals');
|
||
vimport ('includes.runtime.BaseModel');
|
||
vimport ('includes.runtime.LanguageHandler');
|
||
|
||
function vtws_createcontact($lastname, $firstname, $secondname, $email, $mobile, $tgid, $birthday, $birthplace, $mailingstreet, $inn, $requisites, $code, $user = false) {
|
||
|
||
$logstring = date("Y-m-d H:i:s").' '.json_encode($_REQUEST);
|
||
file_put_contents('logs/CreateContact.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
if(empty($firstname) or empty($lastname) or empty($birthday) or empty($mobile) or empty($inn)){
|
||
$logstring = date("Y-m-d H:i:s").' Не указано одно из обязательных полей: имя, фамилия, день рождения, мобила, ИНН';
|
||
file_put_contents('logs/CreateContact.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Не заполнены обязательные поля");
|
||
}
|
||
|
||
$mobile = preg_replace('/[^0-9]/', '', $mobile); //Удаляем всё, что не цифры из телефона
|
||
if (strlen($mobile) == 11) {
|
||
$mobile = "7".substr($mobile, 1);
|
||
} else {
|
||
if (strlen($mobile) == 10) {
|
||
$mobile = "7".$mobile;
|
||
} else {
|
||
$logstring = date("Y-m-d H:i:s").' Некорректный номер телефона: '.$mobile;
|
||
file_put_contents('logs/CreateContact.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Некорректный номер телефона");
|
||
}
|
||
}
|
||
|
||
$output = 'Внутрення ошибка CRM, данные не сохранены';
|
||
|
||
$params = array (
|
||
'firstname' => $firstname,
|
||
'cf_1157' => $secondname,
|
||
'lastname' => $lastname,
|
||
'mobile' => $mobile,
|
||
'email' => $email,
|
||
'phone' => $tgid,
|
||
'birthday' => $birthday,
|
||
'cf_1263' => $birthplace,
|
||
'mailingstreet' => $mailingstreet,
|
||
'cf_1257' => $inn,
|
||
'cf_1849' => $requisites,
|
||
'cf_1580' => $code
|
||
);
|
||
|
||
global $adb, $current_user;
|
||
|
||
$query = "select c.contactid
|
||
from vtiger_contactdetails c
|
||
left join vtiger_crmentity e on e.crmid = c.contactid
|
||
where e.deleted = 0 and c.mobile = ?
|
||
limit 1";
|
||
$result = $adb->pquery($query, array($mobile));
|
||
|
||
if ($adb->num_rows($result) > 0) {
|
||
$params['id'] = '12x'.$adb->query_result($result, 0, 'contactid');
|
||
$logstring = date('Y-m-d H:i:s').' Массив для обновления Контакта: '.json_encode($params).PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
try {
|
||
$contact = vtws_revise($params, $current_user);
|
||
$output = substr($contact['id'], 3);
|
||
$logstring = date('Y-m-d H:i:s').' обновлен Контакт с id '.$output.PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
} catch (WebServiceException $ex) {
|
||
$logstring = date('Y-m-d H:i:s').' '.$ex->getMessage().PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
}
|
||
} else {
|
||
$params['assigned_user_id'] = vtws_getWebserviceEntityId('Users', $current_user->id);
|
||
$logstring = date('Y-m-d H:i:s').' Массив для создания Контакта: '.json_encode($params).PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
try {
|
||
$contact = vtws_create('Contacts', $params, $current_user);
|
||
$output = substr($contact['id'], 3);
|
||
$logstring = date('Y-m-d H:i:s').' создан Контакт с id '.$output.PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
} catch (WebServiceException $ex) {
|
||
$logstring = date('Y-m-d H:i:s').' '.$ex->getMessage().PHP_EOL;
|
||
file_put_contents('logs/CreateContact.log', $logstring, FILE_APPEND);
|
||
}
|
||
}
|
||
|
||
return $output;
|
||
} |