Files
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- 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.
2025-10-16 11:17:21 +03:00

169 lines
4.1 KiB
PHP

<?php
class ITS4YouInstaller_Readonly_Model extends Vtiger_Base_Model
{
/**
* @var Vtiger_Record_Model $recordModel
* @var Vtiger_Module_Model $moduleModel
* @var CRMEntity $moduleFocus
* @var PearDatabase $adb
*/
public $record, $module, $moduleModel, $recordModel, $moduleFocus, $adb;
/**
* @param int $record
* @param string $module
*/
public static function getInstance($module, $record = 0)
{
$self = new self();
$self->retrieveDatabase();
$self->setModule($module);
$self->retrieveModuleModel();
$self->retrieveModuleFocus();
if ($record) {
$self->setRecord($record);
$self->retrieveRecordModel();
}
return $self;
}
public function retrieveDatabase()
{
$this->adb = PearDatabase::getInstance();
}
/**
* @param string $value
*/
public function setModule($value)
{
$this->module = $value;
}
public function retrieveModuleModel()
{
$this->moduleModel = Vtiger_Module_Model::getInstance($this->module);
}
public function retrieveModuleFocus()
{
$this->moduleFocus = CRMEntity::getInstance($this->module);
}
public function retrieveRecordModel()
{
$this->recordModel = Vtiger_Record_Model::getInstanceById($this->record, $this->moduleModel);
}
/**
* @throws Exception
*/
public function save()
{
if (empty($this->getData())) {
throw new AppException(vtranslate('LBL_EMPTY_UPDATE_DATA'));
}
$entityData = $this->getEntityData(true);
$em = new VTEventsManager($this->adb);
$em->triggerEvent('vtiger.entity.beforesave', $entityData);
$this->updateValues();
$entityData = $this->getEntityData(true);
$em->triggerEvent('vtiger.entity.aftersave', $entityData);
$em->triggerEvent('vtiger.entity.aftersave.final', $entityData);
}
/**
* @return VTEntityData
* @throws Exception
*/
public function getEntityData($retrieve = false)
{
if ($retrieve) {
$this->retrieveFocusInfo();
}
$focus = $this->getModuleFocus();
$focus->mode = 'edit';
return VTEntityData::fromCRMEntity($focus);
}
public function retrieveFocusInfo()
{
$this->moduleFocus->retrieve_entity_info($this->getRecord(), $this->module);
$this->moduleFocus->id = $this->getRecord();
}
public function getRecord()
{
return $this->record;
}
/**
* @param int $value
*/
public function setRecord($value)
{
$this->record = $value;
}
/**
* @return CRMEntity
*/
public function getModuleFocus()
{
return $this->moduleFocus;
}
/**
* @throws Exception
*/
public function updateValues()
{
$data = $this->getData();
foreach ($data as $fieldName => $fieldValue) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $this->getModuleModel());
if (!$fieldModel) {
continue;
}
$table = $fieldModel->get('table');
$tableId = $this->getTableIndex($table);
$column = $fieldModel->get('column');
if (empty($table) || empty($column) || empty($tableId)) {
continue;
}
$this->adb->pquery(
sprintf('UPDATE %s SET %s=? WHERE %s=?', $table, $column, $tableId),
array($fieldValue, $this->record)
);
}
}
/**
* @return Vtiger_Module_Model
*/
public function getModuleModel()
{
return $this->moduleModel;
}
/**
* @param string $table
* @return string
*/
public function getTableIndex($table)
{
return isset($this->getModuleFocus()->tab_name_index) ? $this->getModuleFocus()->tab_name_index[$table] : '';
}
}