2025-09-26 10:43:05 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Simple Document Editor API
|
|
|
|
|
|
* Простой API для редактирования документов без сложной конфигурации
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
|
|
|
|
|
|
|
|
|
|
$recordId = $input['record_id'] ?? '';
|
|
|
|
|
|
$fileName = $input['file_name'] ?? '';
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($recordId) || empty($fileName)) {
|
|
|
|
|
|
throw new Exception('Record ID and file name are required');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
error_log("Simple Editor: Record $recordId, File $fileName");
|
|
|
|
|
|
|
|
|
|
|
|
// Простая версия - пока просто возвращаем ссылку на Nextcloud
|
2025-10-20 17:17:34 +03:00
|
|
|
|
$nextcloudUrl = "https://office.clientright.ru/apps/files/?dir=/CRM_Active_Files/Documents/" . $recordId;
|
2025-09-26 10:43:05 +03:00
|
|
|
|
|
|
|
|
|
|
// В будущем здесь будет:
|
|
|
|
|
|
// 1. Загрузка файла из vTiger в Nextcloud
|
|
|
|
|
|
// 2. Создание прямой ссылки на редактирование
|
|
|
|
|
|
// 3. Синхронизация изменений
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode([
|
|
|
|
|
|
'success' => true,
|
|
|
|
|
|
'edit_url' => $nextcloudUrl,
|
|
|
|
|
|
'message' => 'Файл будет доступен в папке Documents/' . $recordId,
|
|
|
|
|
|
'record_id' => $recordId,
|
|
|
|
|
|
'file_name' => $fileName
|
|
|
|
|
|
], JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
|
error_log("Simple Editor Error: " . $e->getMessage());
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode([
|
|
|
|
|
|
'success' => false,
|
|
|
|
|
|
'error' => $e->getMessage()
|
|
|
|
|
|
], JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
}
|