- 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.
105 lines
4.7 KiB
PHP
105 lines
4.7 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 'includes/Loader.php';
|
||
vimport ('includes.runtime.Globals');
|
||
vimport ('includes.runtime.BaseModel');
|
||
vimport ('includes.runtime.LanguageHandler');
|
||
|
||
function vtws_createervticket($title, $contactid, $projectid, $user = false) {
|
||
|
||
$logstring = date("Y-m-d H:i:s").' '.json_encode($_REQUEST);
|
||
file_put_contents('logs/CreateTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
if(empty($title) or empty($contactid) or empty($projectid)){
|
||
$logstring = date("Y-m-d H:i:s").' Не указано одно из обязательных полей: Название Заявик, ID Контакта или ID Проекта';
|
||
file_put_contents('logs/CreateTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Не заполнены обязательные поля");
|
||
}
|
||
|
||
try {
|
||
$params = array (
|
||
'ticket_title' => $title,
|
||
'parent_id' => '11x67458',
|
||
'ticketcategories' => 'Цифровой адвокат ЕРВ',
|
||
'ticketstatus' => 'рассмотрение',
|
||
'contact_id' => '12x'.$contactid,
|
||
'cf_2066' => '33x'.$projectid,
|
||
'ticketpriorities' => 'High',
|
||
'assigned_user_id' => '19x8'
|
||
);
|
||
$logstring = date('Y-m-d H:i:s').' массив для создания Заявки: '.json_encode($params).PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
|
||
$result = vtws_create('HelpDesk', $params, $user);
|
||
$logstring = date('Y-m-d H:i:s').' сохранена Заявка id = '.$result['id'].PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
$output = substr($result['id'], 3);
|
||
} catch (WebServiceException $ex) {
|
||
$output = $ex->getMessage();
|
||
$logstring = date('Y-m-d H:i:s').' '.$output.PHP_EOL;
|
||
file_put_contents('logs/CreateTicket.log', $logstring, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, $output);
|
||
}
|
||
|
||
return $output;
|
||
}
|
||
|
||
/**
|
||
* Создание заявки для RAG системы
|
||
* @param string $title - тема заявки
|
||
* @param int $contactid - ID контакта в CRM
|
||
* @param string $question - вопрос для RAG
|
||
* @param int $parentid - ID организации (parent_id)
|
||
* @param object $user - пользователь CRM (опционально)
|
||
* @return int - ID созданной заявки
|
||
*/
|
||
function vtws_createRAGTicket($title, $contactid, $question, $parentid, $user = false) {
|
||
|
||
$logstring = date("Y-m-d H:i:s").' '.json_encode($_REQUEST);
|
||
file_put_contents('logs/CreateRAGTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
if(empty($title) or empty($contactid) or empty($question) or empty($parentid)){
|
||
$logstring = date("Y-m-d H:i:s").' Не указано одно из обязательных полей: Название, ID Контакта, Вопрос или ID Организации';
|
||
file_put_contents('logs/CreateRAGTicket.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Не заполнены обязательные поля");
|
||
}
|
||
|
||
try {
|
||
$params = array (
|
||
'ticket_title' => $title,
|
||
'parent_id' => '11x'.$parentid,
|
||
'ticketcategories' => 'Прочее',
|
||
'ticketstatus' => 'В прогрессе',
|
||
'contact_id' => '12x'.$contactid,
|
||
'description' => $question, // Вопрос сохраняем в описании
|
||
'ticketpriorities' => 'High',
|
||
'assigned_user_id' => '19x8',
|
||
'source' => 'RAG SYSTEM' // Указываем источник
|
||
);
|
||
|
||
$logstring = date('Y-m-d H:i:s').' массив для создания RAG заявки: '.json_encode($params).PHP_EOL;
|
||
file_put_contents('logs/CreateRAGTicket.log', $logstring, FILE_APPEND);
|
||
|
||
$result = vtws_create('HelpDesk', $params, $user);
|
||
$logstring = date('Y-m-d H:i:s').' сохранена RAG заявка id = '.$result['id'].PHP_EOL;
|
||
file_put_contents('logs/CreateRAGTicket.log', $logstring, FILE_APPEND);
|
||
$output = substr($result['id'], 3);
|
||
|
||
} catch (WebServiceException $ex) {
|
||
$output = $ex->getMessage();
|
||
$logstring = date('Y-m-d H:i:s').' '.$output.PHP_EOL;
|
||
file_put_contents('logs/CreateRAGTicket.log', $logstring, FILE_APPEND);
|
||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID, $output);
|
||
}
|
||
|
||
return $output;
|
||
} |