Files
crm.clientright.ru/crm_extensions/file_storage/api/simple_edit.php

45 lines
1.5 KiB
PHP
Raw Normal View History

<?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
$nextcloudUrl = "https://office.klientprav.tech/apps/files/?dir=/CRM_Active_Files/Documents/" . $recordId;
// В будущем здесь будет:
// 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);
}