- 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.
231 lines
5.5 KiB
PHP
231 lines
5.5 KiB
PHP
<?php
|
||
/*+***********************************************************************************
|
||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||
* ("License"); You may not use this file except in compliance with the License
|
||
* The Original Code is: vtiger CRM Open Source
|
||
* The Initial Developer of the Original Code is vtiger.
|
||
* Portions created by vtiger are Copyright (C) vtiger.
|
||
* All Rights Reserved.
|
||
*************************************************************************************/
|
||
|
||
class VtigerCRMObject{
|
||
|
||
private $moduleName ;
|
||
private $moduleId ;
|
||
private $instance ;
|
||
|
||
function VtigerCRMObject($moduleCredential, $isId=false){
|
||
|
||
if($isId){
|
||
$this->moduleId = $moduleCredential;
|
||
$this->moduleName = $this->getObjectTypeName($this->moduleId);
|
||
}else{
|
||
$this->moduleName = $moduleCredential;
|
||
$this->moduleId = $this->getObjectTypeId($this->moduleName);
|
||
}
|
||
$this->instance = null;
|
||
$this->getInstance();
|
||
}
|
||
|
||
public function getModuleName(){
|
||
return $this->moduleName;
|
||
}
|
||
|
||
public function getModuleId(){
|
||
return $this->moduleId;
|
||
}
|
||
|
||
public function getInstance(){
|
||
if($this->instance == null){
|
||
$this->instance = $this->getModuleClassInstance($this->moduleName);
|
||
}
|
||
return $this->instance;
|
||
}
|
||
|
||
public function getObjectId(){
|
||
if($this->instance==null){
|
||
$this->getInstance();
|
||
}
|
||
return $this->instance->id;
|
||
}
|
||
|
||
public function setObjectId($id){
|
||
if($this->instance==null){
|
||
$this->getInstance();
|
||
}
|
||
$this->instance->id = $id;
|
||
}
|
||
|
||
private function titleCase($str){
|
||
$first = substr($str, 0, 1);
|
||
return strtoupper($first).substr($str,1);
|
||
}
|
||
|
||
private function getObjectTypeId($objectName){
|
||
|
||
// Use getTabid API
|
||
$tid = getTabid($objectName);
|
||
|
||
if($tid === false) {
|
||
global $adb;
|
||
|
||
$sql = "select * from vtiger_tab where name=?;";
|
||
$params = array($objectName);
|
||
$result = $adb->pquery($sql, $params);
|
||
$data1 = $adb->fetchByAssoc($result,1,false);
|
||
|
||
$tid = $data1["tabid"];
|
||
}
|
||
// END
|
||
|
||
return $tid;
|
||
|
||
}
|
||
|
||
private function getModuleClassInstance($moduleName){
|
||
return CRMEntity::getInstance($moduleName);
|
||
}
|
||
|
||
private function getObjectTypeName($moduleId){
|
||
|
||
return getTabModuleName($moduleId);
|
||
|
||
}
|
||
|
||
private function getTabName(){
|
||
if($this->moduleName == 'Events'){
|
||
return 'Calendar';
|
||
}
|
||
return $this->moduleName;
|
||
}
|
||
|
||
public function read($id){
|
||
global $adb;
|
||
|
||
$error = false;
|
||
$adb->startTransaction();
|
||
$this->instance->retrieve_entity_info($id,$this->getTabName());
|
||
$error = $adb->hasFailedTransaction();
|
||
$adb->completeTransaction();
|
||
return !$error;
|
||
}
|
||
|
||
public function create($element){
|
||
global $adb;
|
||
|
||
$error = false;
|
||
foreach($element as $k=>$v){
|
||
$this->instance->column_fields[$k] = $v;
|
||
}
|
||
|
||
$adb->startTransaction();
|
||
$this->instance->Save($this->getTabName());
|
||
$error = $adb->hasFailedTransaction();
|
||
$adb->completeTransaction();
|
||
return !$error;
|
||
}
|
||
|
||
public function update($element){
|
||
|
||
global $adb;
|
||
$error = false;
|
||
$error = $this->read($this->getObjectId());
|
||
if ($error == false) {
|
||
return $error;
|
||
}
|
||
|
||
foreach($element as $k=>$v){
|
||
$this->instance->column_fields[$k] = $v;
|
||
}
|
||
|
||
$adb->startTransaction();
|
||
$this->instance->mode = "edit";
|
||
$this->instance->Save($this->getTabName());
|
||
$error = $adb->hasFailedTransaction();
|
||
$adb->completeTransaction();
|
||
return !$error;
|
||
}
|
||
|
||
public function revise($element){
|
||
global $adb;
|
||
$error = false;
|
||
|
||
// Устанавливаем правильную кодировку для соединения с базой данных
|
||
$adb->database->query("SET NAMES utf8");
|
||
|
||
// Читаем текущие данные из базы
|
||
$error = $this->read($this->getObjectId());
|
||
if($error == false){
|
||
return $error;
|
||
}
|
||
|
||
// Обновляем только переданные поля, остальные остаются без изменений
|
||
foreach($element as $k=>$v){
|
||
// Обновляем поле только если оно было передано явно в запросе
|
||
if ($k !== 'id' && isset($element[$k])) {
|
||
$this->instance->column_fields[$k] = $v;
|
||
}
|
||
}
|
||
|
||
//added to fix the issue of utf8 characters
|
||
foreach($this->instance->column_fields as $key=>$value){
|
||
if (!is_array($value)) {
|
||
$value = decode_html($value);
|
||
}
|
||
$this->instance->column_fields[$key] = $value;
|
||
}
|
||
|
||
$adb->startTransaction();
|
||
$this->instance->mode = "edit";
|
||
$this->instance->Save($this->getTabName());
|
||
$error = $adb->hasFailedTransaction();
|
||
$adb->completeTransaction();
|
||
return !$error;
|
||
}
|
||
|
||
public function delete($id){
|
||
global $adb;
|
||
$error = false;
|
||
$adb->startTransaction();
|
||
DeleteEntity($this->getTabName(), $this->getTabName(), $this->instance, $id,$returnid);
|
||
$error = $adb->hasFailedTransaction();
|
||
$adb->completeTransaction();
|
||
return !$error;
|
||
}
|
||
|
||
public function getFields(){
|
||
return $this->instance->column_fields;
|
||
}
|
||
|
||
function exists($id){
|
||
global $adb;
|
||
|
||
$exists = false;
|
||
$sql = "select * from vtiger_crmentity where crmid=? and deleted=0";
|
||
$result = $adb->pquery($sql , array($id));
|
||
if($result != null && isset($result)){
|
||
if($adb->num_rows($result)>0){
|
||
$exists = true;
|
||
}
|
||
}
|
||
return $exists;
|
||
}
|
||
|
||
function getSEType($id){
|
||
global $adb;
|
||
|
||
$seType = null;
|
||
$sql = "select * from vtiger_crmentity where crmid=? and deleted=0";
|
||
$result = $adb->pquery($sql , array($id));
|
||
if($result != null && isset($result)){
|
||
if($adb->num_rows($result)>0){
|
||
$seType = $adb->query_result($result,0,"setype");
|
||
}
|
||
}
|
||
return $seType;
|
||
}
|
||
|
||
}
|
||
|
||
?>
|