🚀 CRM Files Migration & Real-time Features
✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
This commit is contained in:
@@ -305,13 +305,63 @@ class CRMEntity {
|
||||
require_once __DIR__ . '/../include/Storage/S3StorageService.php';
|
||||
$s3Service = new S3StorageService();
|
||||
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Calling put() method' . PHP_EOL, FILE_APPEND);
|
||||
$log->debug("S3Service loaded, attempting upload to S3");
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Calling put() method' . PHP_EOL, FILE_APPEND);
|
||||
$log->debug("S3Service loaded, attempting upload to S3");
|
||||
|
||||
// Подготовка контекста для универсальной структуры папок
|
||||
$uploadContext = [];
|
||||
|
||||
// Отладка: что у нас есть
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: module=' . $module . ', this->parentid=' . ($this->parentid ?? 'NULL') . ', this->id=' . ($this->id ?? 'NULL') . PHP_EOL, FILE_APPEND);
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: REQUEST[parent_id]=' . ($_REQUEST['parent_id'] ?? 'NULL') . ', REQUEST[sourceRecord]=' . ($_REQUEST['sourceRecord'] ?? 'NULL') . PHP_EOL, FILE_APPEND);
|
||||
|
||||
// Определяем parent record ID
|
||||
$parentRecordId = $this->parentid;
|
||||
if (empty($parentRecordId) && !empty($_REQUEST['sourceRecord'])) {
|
||||
$parentRecordId = $_REQUEST['sourceRecord'];
|
||||
}
|
||||
if (empty($parentRecordId) && !empty($_REQUEST['parent_id'])) {
|
||||
$parentRecordId = $_REQUEST['parent_id'];
|
||||
}
|
||||
|
||||
// Для Documents модуля, получаем информацию о родительской записи (Project)
|
||||
if ($module == 'Documents' && !empty($parentRecordId)) {
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Found parentRecordId=' . $parentRecordId . PHP_EOL, FILE_APPEND);
|
||||
|
||||
// Получаем информацию о родительской записи
|
||||
$parentResult = $adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", [$parentRecordId]);
|
||||
if ($adb->num_rows($parentResult) > 0) {
|
||||
$parentModule = $adb->query_result($parentResult, 0, 'setype');
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Parent module=' . $parentModule . PHP_EOL, FILE_APPEND);
|
||||
|
||||
// Upload to S3
|
||||
$s3Result = $s3Service->put($filetmp_name, $current_id, $filename);
|
||||
$upload_status = true;
|
||||
$s3_metadata = $s3Result;
|
||||
// Получаем имя родительской записи
|
||||
$parentName = null;
|
||||
if ($parentModule == 'Project') {
|
||||
$projectResult = $adb->pquery("SELECT projectname FROM vtiger_project WHERE projectid = ?", [$parentRecordId]);
|
||||
if ($adb->num_rows($projectResult) > 0) {
|
||||
$parentName = $adb->query_result($projectResult, 0, 'projectname');
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Project name=' . $parentName . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
// Получаем title документа
|
||||
$documentTitle = !empty($this->column_fields['notes_title']) ? $this->column_fields['notes_title'] : null;
|
||||
|
||||
$uploadContext = [
|
||||
'module' => $parentModule,
|
||||
'recordId' => $parentRecordId,
|
||||
'recordName' => $parentName,
|
||||
'documentTitle' => $documentTitle
|
||||
];
|
||||
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3: Upload context = ' . json_encode($uploadContext) . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
// Upload to S3
|
||||
$s3Result = $s3Service->put($filetmp_name, $current_id, $filename, 3, $uploadContext);
|
||||
$upload_status = true;
|
||||
$s3_metadata = $s3Result;
|
||||
|
||||
file_put_contents('logs/debug.log', '[' . date('Y-m-d H:i:s') . '] S3 SUCCESS: Upload completed, metadata=' . json_encode($s3_metadata) . PHP_EOL, FILE_APPEND);
|
||||
$log->debug("S3 upload successful for record $current_id, key: " . $s3Result['key']);
|
||||
|
||||
Reference in New Issue
Block a user