- 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.
203 lines
8.3 KiB
PHP
203 lines
8.3 KiB
PHP
<?php
|
||
|
||
include_once 'modules/Users/Users.php';
|
||
require_once 'include/Webservices/Create.php';
|
||
require_once 'includes/Loader.php';
|
||
vimport('includes.runtime.Globals');
|
||
vimport('includes.runtime.BaseModel');
|
||
vimport('includes.runtime.LanguageHandler');
|
||
|
||
// Путь к лог-файлу
|
||
$logFile = 'logs/logaudit.log';
|
||
|
||
// Функция логирования
|
||
function writeLog($message, $logFile) {
|
||
$time = date('Y-m-d H:i:s');
|
||
file_put_contents($logFile, "[$time] $message\n", FILE_APPEND);
|
||
}
|
||
|
||
// Получаем JSON-данные из тела запроса
|
||
$data = json_decode(file_get_contents('php://input'), true);
|
||
|
||
// Проверка полученных данных
|
||
$inn = $data['inn'] ?? null;
|
||
$test_id = $data['test_id'] ?? null;
|
||
$name = $data['name'] ?? null;
|
||
$email = $data['email'] ?? null;
|
||
$phone = $data['phone'] ?? null;
|
||
$percentage = $data['percentage'] ?? null;
|
||
$test_results = $data['results'] ?? null; // Добавляем результаты теста
|
||
$solution = $data['solutions'] ?? null; // Добавляем поле "solution"
|
||
$totalfine = $data['totalFine'] ?? null; // Добавляем поле "totalFine"
|
||
|
||
writeLog("Полученные данные: " . json_encode($data), $logFile);
|
||
|
||
// Проверка обязательных параметров
|
||
if (empty($inn) || empty($test_id) || empty($name) || empty($email) || empty($phone) || empty($percentage) || empty($test_results)) {
|
||
$errorMessage = "Ошибка: Одно из обязательных полей отсутствует.";
|
||
writeLog($errorMessage, $logFile);
|
||
http_response_code(400);
|
||
echo json_encode(['success' => false, 'error' => $errorMessage]);
|
||
exit;
|
||
}
|
||
|
||
try {
|
||
// Получение пользователя
|
||
$user = Users::getActiveAdminUser();
|
||
|
||
// Подготовка данных для CRM
|
||
$crmData = array(
|
||
'ticket_title' => 'Самообследование_' . $inn,
|
||
'ticketstatus' => 'Открыто',
|
||
'ticketpriorities' => 'Высокий',
|
||
'cf_2526' => $test_id,
|
||
'cf_2516' => $name,
|
||
'cf_2518' => $inn,
|
||
'cf_2514' => $email,
|
||
'cf_2512' => $phone,
|
||
'cf_2528' => $percentage,
|
||
'cf_2564' => $totalfine,
|
||
'cf_2524' => '00001',
|
||
'description' => generateTestResultsDescription($test_results), // Формируем описание из результатов
|
||
'cf_2562' => generateSolutionDescription($solution), // Добавляем решение
|
||
'assigned_user_id' => vtws_getWebserviceEntityId('Users', $user->id),
|
||
);
|
||
|
||
writeLog("Отправка данных в CRM: " . json_encode($crmData), $logFile);
|
||
|
||
// Создание записи в CRM
|
||
$lead = vtws_create('HelpDesk', $crmData, $user);
|
||
|
||
writeLog("Запись успешно создана в CRM: " . json_encode($lead), $logFile);
|
||
|
||
echo json_encode(['success' => true, 'message' => 'Запись успешно создана.']);
|
||
} catch (WebServiceException $ex) {
|
||
$errorMessage = "Ошибка CRM: " . $ex->getMessage();
|
||
writeLog($errorMessage, $logFile);
|
||
http_response_code(500);
|
||
echo json_encode(['success' => false, 'error' => $errorMessage]);
|
||
}
|
||
|
||
// Функция для формирования описания на основе результатов теста
|
||
function generateTestResultsDescription($testResults) {
|
||
$description = "Результаты теста:\n";
|
||
foreach ($testResults as $result) {
|
||
$description .= "Вопрос: {$result['question']}\n";
|
||
$description .= "Правильный ответ: {$result['correct_answer']}\n";
|
||
$description .= "Ответ пользователя: {$result['user_answer']}\n\n";
|
||
}
|
||
return $description;
|
||
}
|
||
|
||
// Функция для формирования описания решений
|
||
function generateSolutionDescription($solutions) {
|
||
if (empty($solutions)) {
|
||
return "Решений для неверных ответов не найдено.";
|
||
}
|
||
|
||
$description = "Рекомендации и ответственность по неверным ответам:\n";
|
||
foreach ($solutions as $solution) {
|
||
|
||
/*
|
||
$description .= "=== Вопрос: === {$solution['question']}\n";
|
||
$description .= "--- Ответ пользователя: --- {$solution['user_answer']}\n";
|
||
$description .= "*** Рекомендация: *** {$solution['recommendation']}\n";
|
||
$description .= ">>> Ответственность: <<< {$solution['responsibility']}\n\n";
|
||
*/
|
||
$description .= "<b>Вопрос:</b> {$solution['question']}\n";
|
||
$description .= "<b>Ответ пользователя:</b> {$solution['user_answer']}\n";
|
||
$description .= "<b>Рекомендация:</b> {$solution['recommendation']}\n";
|
||
$description .= "<b>Ответственность:</b> {$solution['responsibility']}\n\n";
|
||
|
||
}
|
||
|
||
return $description;
|
||
}
|
||
|
||
|
||
/*
|
||
include_once 'modules/Users/Users.php';
|
||
require_once 'include/Webservices/Create.php';
|
||
require_once 'includes/Loader.php';
|
||
vimport('includes.runtime.Globals');
|
||
vimport('includes.runtime.BaseModel');
|
||
vimport('includes.runtime.LanguageHandler');
|
||
|
||
// Путь к лог-файлу
|
||
$logFile = 'logs/logaudit.log';
|
||
|
||
// Функция логирования
|
||
function writeLog($message, $logFile) {
|
||
$time = date('Y-m-d H:i:s');
|
||
file_put_contents($logFile, "[$time] $message\n", FILE_APPEND);
|
||
}
|
||
|
||
// Получаем JSON-данные из тела запроса
|
||
$data = json_decode(file_get_contents('php://input'), true);
|
||
|
||
// Проверка полученных данных
|
||
$inn = $data['inn'] ?? null;
|
||
$test_id = $data['test_id'] ?? null;
|
||
$name = $data['name'] ?? null;
|
||
$email = $data['email'] ?? null;
|
||
$phone = $data['phone'] ?? null;
|
||
$percentage = $data['percentage'] ?? null;
|
||
$test_results = $data['results'] ?? null; // Добавляем результаты теста
|
||
|
||
writeLog("Полученные данные: " . json_encode($data), $logFile);
|
||
|
||
// Проверка обязательных параметров
|
||
if (empty($inn) || empty($test_id) || empty($name) || empty($email) || empty($phone) || empty($percentage) || empty($test_results)) {
|
||
$errorMessage = "Ошибка: Одно из обязательных полей отсутствует.";
|
||
writeLog($errorMessage, $logFile);
|
||
http_response_code(400);
|
||
echo json_encode(['success' => false, 'error' => $errorMessage]);
|
||
exit;
|
||
}
|
||
|
||
try {
|
||
// Получение пользователя
|
||
$user = Users::getActiveAdminUser();
|
||
|
||
// Подготовка данных для CRM
|
||
$crmData = array(
|
||
'ticket_title' => 'Самообследование_' . $inn,
|
||
'ticketstatus' => 'Открыто',
|
||
'ticketpriorities' => 'Высокий',
|
||
'cf_2526' => $test_id,
|
||
'cf_2516' => $name,
|
||
'cf_2518' => $inn,
|
||
'cf_2514' => $email,
|
||
'cf_2512' => $phone,
|
||
'cf_2528' => $percentage,
|
||
'cf_2524' => '00001',
|
||
'description' => generateTestResultsDescription($test_results), // Формируем описание из результатов
|
||
'assigned_user_id' => vtws_getWebserviceEntityId('Users', $user->id),
|
||
);
|
||
|
||
writeLog("Отправка данных в CRM: " . json_encode($crmData), $logFile);
|
||
|
||
// Создание записи в CRM
|
||
$lead = vtws_create('HelpDesk', $crmData, $user);
|
||
|
||
writeLog("Запись успешно создана в CRM: " . json_encode($lead), $logFile);
|
||
|
||
echo json_encode(['success' => true, 'message' => 'Запись успешно создана.']);
|
||
} catch (WebServiceException $ex) {
|
||
$errorMessage = "Ошибка CRM: " . $ex->getMessage();
|
||
writeLog($errorMessage, $logFile);
|
||
http_response_code(500);
|
||
echo json_encode(['success' => false, 'error' => $errorMessage]);
|
||
}
|
||
|
||
// Функция для формирования описания на основе результатов теста
|
||
function generateTestResultsDescription($testResults) {
|
||
$description = "Результаты теста:\n";
|
||
foreach ($testResults as $result) {
|
||
$description .= "Вопрос: {$result['question']}\n";
|
||
$description .= "Правильный ответ: {$result['correct_answer']}\n";
|
||
$description .= "Ответ пользователя: {$result['user_answer']}\n\n";
|
||
}
|
||
return $description;
|
||
}
|
||
*/ |