Files
crm.clientright.ru/crm_extensions/file_storage/rollback_accounts.php
Fedor 9245768987 🚀 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!
2025-10-24 19:59:28 +03:00

36 lines
1.3 KiB
PHP

<?php
/**
* Откат путей файлов контрагентов к оригинальным
*/
require_once '/var/www/fastuser/data/www/crm.clientright.ru/config.inc.php';
echo "🔄 Начинаем откат путей файлов контрагентов...\n\n";
try {
$pdo = new PDO("mysql:host={$dbconfig['db_server']};dbname={$dbconfig['db_name']};charset=utf8", $dbconfig['db_username'], $dbconfig['db_password']);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Откатываем все файлы контрагентов где путь содержит /Accounts/
$sql = "
UPDATE vtiger_notes n
SET
n.s3_key = CONCAT('crm2/CRM_Active_Files/Documents/', n.notesid, '/', SUBSTRING_INDEX(n.filename, '/', -1)),
n.filename = CONCAT('https://s3.twcstorage.ru/f9825c87-4e3558f6-f9b6-405c-ad3d-d1535c49b61c/crm2/CRM_Active_Files/Documents/', n.notesid, '/', SUBSTRING_INDEX(n.filename, '/', -1))
WHERE n.filelocationtype = 'E'
AND n.s3_key LIKE '%/Accounts/%'
";
$stmt = $pdo->prepare($sql);
$result = $stmt->execute();
$count = $stmt->rowCount();
echo "✅ Откачено записей: {$count}\n";
} catch (Exception $e) {
echo "❌ ОШИБКА: " . $e->getMessage() . "\n";
exit(1);
}