- 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.
342 lines
12 KiB
PHP
342 lines
12 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 Vtiger_DetailView_Model extends Vtiger_Base_Model {
|
|
|
|
protected $module = false;
|
|
protected $record = false;
|
|
|
|
/**
|
|
* Function to get Module instance
|
|
* @return <Vtiger_Module_Model>
|
|
*/
|
|
public function getModule() {
|
|
return $this->module;
|
|
}
|
|
|
|
/**
|
|
* Function to set the module instance
|
|
* @param <Vtiger_Module_Model> $moduleInstance - module model
|
|
* @return Vtiger_DetailView_Model>
|
|
*/
|
|
public function setModule($moduleInstance) {
|
|
$this->module = $moduleInstance;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Function to get the Record model
|
|
* @return <Vtiger_Record_Model>
|
|
*/
|
|
public function getRecord() {
|
|
return $this->record;
|
|
}
|
|
|
|
/**
|
|
* Function to set the record instance3
|
|
* @param <type> $recordModuleInstance - record model
|
|
* @return Vtiger_DetailView_Model
|
|
*/
|
|
public function setRecord($recordModuleInstance) {
|
|
$this->record = $recordModuleInstance;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Function to get the detail view links (links and widgets)
|
|
* @param <array> $linkParams - parameters which will be used to calicaulate the params
|
|
* @return <array> - array of link models in the format as below
|
|
* array('linktype'=>list of link models);
|
|
*/
|
|
public function getDetailViewLinks($linkParams) {
|
|
$linkTypes = array('DETAILVIEWBASIC','DETAILVIEW');
|
|
$moduleModel = $this->getModule();
|
|
$recordModel = $this->getRecord();
|
|
|
|
$moduleName = $moduleModel->getName();
|
|
$recordId = $recordModel->getId();
|
|
|
|
$detailViewLink = array();
|
|
|
|
if(Users_Privileges_Model::isPermitted($moduleName, 'EditView', $recordId)) {
|
|
$detailViewLinks[] = array(
|
|
'linktype' => 'DETAILVIEWBASIC',
|
|
'linklabel' => 'LBL_EDIT',
|
|
'linkurl' => $recordModel->getEditViewUrl(),
|
|
'linkicon' => ''
|
|
);
|
|
|
|
foreach ($detailViewLinks as $detailViewLink) {
|
|
$linkModelList['DETAILVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($detailViewLink);
|
|
}
|
|
}
|
|
|
|
$linkModelListDetails = Vtiger_Link_Model::getAllByType($moduleModel->getId(),$linkTypes,$linkParams);
|
|
//Mark all detail view basic links as detail view links.
|
|
//Since ui will be look ugly if you need many basic links
|
|
$detailViewBasiclinks = $linkModelListDetails['DETAILVIEWBASIC'];
|
|
unset($linkModelListDetails['DETAILVIEWBASIC']);
|
|
|
|
if(Users_Privileges_Model::isPermitted($moduleName, 'Delete', $recordId)) {
|
|
$deletelinkModel = array(
|
|
'linktype' => 'DETAILVIEW',
|
|
'linklabel' => sprintf("%s %s", getTranslatedString('LBL_DELETE', $moduleName), vtranslate('SINGLE_'. $moduleName, $moduleName)),
|
|
'linkurl' => 'javascript:Vtiger_Detail_Js.deleteRecord("'.$recordModel->getDeleteUrl().'")',
|
|
'linkicon' => ''
|
|
);
|
|
$linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($deletelinkModel);
|
|
}
|
|
|
|
if(Users_Privileges_Model::isPermitted($moduleName, 'EditView', $recordId)) {
|
|
$duplicateLinkModel = array(
|
|
'linktype' => 'DETAILVIEWBASIC',
|
|
'linklabel' => 'LBL_DUPLICATE',
|
|
'linkurl' => $recordModel->getDuplicateRecordUrl(),
|
|
'linkicon' => ''
|
|
);
|
|
$linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($duplicateLinkModel);
|
|
}
|
|
|
|
if(!empty($detailViewBasiclinks)) {
|
|
foreach($detailViewBasiclinks as $linkModel) {
|
|
// Remove view history, needed in vtiger5 to see history but not in vtiger6
|
|
if($linkModel->linklabel == 'View History') {
|
|
continue;
|
|
}
|
|
$linkModelList['DETAILVIEW'][] = $linkModel;
|
|
}
|
|
}
|
|
|
|
//SalesPlatform.ru begin - add PDF templates links to DetailView from SPPDFTemplates
|
|
|
|
/* Two cycles - to order */
|
|
$pdfTemplates = new SPPDFTemplates_Module_Model();
|
|
$availableTemplates = $pdfTemplates->getModuleTemplates($this->getModuleName(), $this->record->get('spcompany'));
|
|
|
|
foreach($availableTemplates as $template) {
|
|
|
|
/* Export PDF links */
|
|
$pdfTemplateLink = array(
|
|
'linklabel' => sprintf("%s %s", vtranslate('LBL_EXPORT_TO_PDF',$moduleName), $template->getName()),
|
|
'linkurl' => $recordModel->getExportPDFURL($template),
|
|
);
|
|
$linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($pdfTemplateLink);
|
|
}
|
|
|
|
foreach($availableTemplates as $template) {
|
|
|
|
/* Email link */
|
|
$sendEmailLink = array(
|
|
'linklabel' => sprintf("%s %s", vtranslate('LBL_SEND_MAIL_PDF', $moduleName), $template->getName()),
|
|
'linkurl' => 'javascript:Vtiger_Detail_Js.sendEmailPDFClickHandler(\''
|
|
.$recordModel->getSendEmailPDFUrl($template).'\')',
|
|
);
|
|
$linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($sendEmailLink);
|
|
}
|
|
//SalesPlatform.ru end
|
|
|
|
$relatedLinks = $this->getDetailViewRelatedLinks();
|
|
|
|
foreach($relatedLinks as $relatedLinkEntry) {
|
|
$relatedLink = Vtiger_Link_Model::getInstanceFromValues($relatedLinkEntry);
|
|
$linkModelList[$relatedLink->getType()][] = $relatedLink;
|
|
}
|
|
|
|
$widgets = $this->getWidgets();
|
|
foreach($widgets as $widgetLinkModel) {
|
|
$linkModelList['DETAILVIEWWIDGET'][] = $widgetLinkModel;
|
|
}
|
|
|
|
$currentUserModel = Users_Record_Model::getCurrentUserModel();
|
|
if($currentUserModel->isAdminUser()) {
|
|
$settingsLinks = $moduleModel->getSettingLinks();
|
|
foreach($settingsLinks as $settingsLink) {
|
|
$linkModelList['DETAILVIEWSETTING'][] = Vtiger_Link_Model::getInstanceFromValues($settingsLink);
|
|
}
|
|
}
|
|
|
|
return $linkModelList;
|
|
}
|
|
|
|
/**
|
|
* Function to get the detail view related links
|
|
* @return <array> - list of links parameters
|
|
*/
|
|
public function getDetailViewRelatedLinks() {
|
|
$recordModel = $this->getRecord();
|
|
$moduleName = $recordModel->getModuleName();
|
|
$parentModuleModel = $this->getModule();
|
|
$relatedLinks = array();
|
|
|
|
if($parentModuleModel->isSummaryViewSupported()) {
|
|
$relatedLinks = array(array(
|
|
'linktype' => 'DETAILVIEWTAB',
|
|
'linklabel' => vtranslate('SINGLE_' . $moduleName, $moduleName) . ' ' . vtranslate('LBL_SUMMARY', $moduleName),
|
|
'linkKey' => 'LBL_RECORD_SUMMARY',
|
|
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=summary',
|
|
'linkicon' => ''
|
|
));
|
|
}
|
|
//link which shows the summary information(generally detail of record)
|
|
$relatedLinks[] = array(
|
|
'linktype' => 'DETAILVIEWTAB',
|
|
'linklabel' => vtranslate('SINGLE_'.$moduleName, $moduleName).' '. vtranslate('LBL_DETAILS', $moduleName),
|
|
'linkKey' => 'LBL_RECORD_DETAILS',
|
|
'linkurl' => $recordModel->getDetailViewUrl().'&mode=showDetailViewByMode&requestMode=full',
|
|
'linkicon' => ''
|
|
);
|
|
|
|
$modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');
|
|
if($parentModuleModel->isCommentEnabled() && $modCommentsModel->isPermitted('DetailView')) {
|
|
$relatedLinks[] = array(
|
|
'linktype' => 'DETAILVIEWTAB',
|
|
'linklabel' => 'ModComments',
|
|
'linkurl' => $recordModel->getDetailViewUrl().'&mode=showAllComments',
|
|
'linkicon' => ''
|
|
);
|
|
}
|
|
|
|
if($parentModuleModel->isTrackingEnabled()) {
|
|
$relatedLinks[] = array(
|
|
'linktype' => 'DETAILVIEWTAB',
|
|
'linklabel' => 'LBL_UPDATES',
|
|
'linkurl' => $recordModel->getDetailViewUrl().'&mode=showRecentActivities&page=1',
|
|
'linkicon' => ''
|
|
);
|
|
}
|
|
|
|
|
|
$relationModels = $parentModuleModel->getRelations();
|
|
|
|
foreach($relationModels as $relation) {
|
|
//TODO : Way to get limited information than getting all the information
|
|
$link = array(
|
|
'linktype' => 'DETAILVIEWRELATED',
|
|
'linklabel' => $relation->get('label'),
|
|
'linkurl' => $relation->getListUrl($recordModel),
|
|
'linkicon' => '',
|
|
'relatedModuleName' => $relation->get('relatedModuleName')
|
|
);
|
|
$relatedLinks[] = $link;
|
|
}
|
|
|
|
return $relatedLinks;
|
|
}
|
|
|
|
/**
|
|
* Function to get the detail view widgets
|
|
* @return <Array> - List of widgets , where each widget is an Vtiger_Link_Model
|
|
*/
|
|
public function getWidgets() {
|
|
$moduleModel = $this->getModule();
|
|
$widgets = array();
|
|
|
|
$modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');
|
|
if($moduleModel->isCommentEnabled() && $modCommentsModel->isPermitted('DetailView')) {
|
|
$widgets[] = array(
|
|
'linktype' => 'DETAILVIEWWIDGET',
|
|
'linklabel' => 'ModComments',
|
|
'linkurl' => 'module='.$this->getModuleName().'&view=Detail&record='.$this->getRecord()->getId().
|
|
'&mode=showRecentComments&page=1&limit=5'
|
|
);
|
|
}
|
|
|
|
if($moduleModel->isTrackingEnabled()) {
|
|
$widgets[] = array(
|
|
'linktype' => 'DETAILVIEWWIDGET',
|
|
'linklabel' => 'LBL_UPDATES',
|
|
'linkurl' => 'module='.$this->getModuleName().'&view=Detail&record='.$this->getRecord()->getId().
|
|
'&mode=showRecentActivities&page=1&limit=5',
|
|
);
|
|
}
|
|
|
|
$widgetLinks = array();
|
|
foreach ($widgets as $widgetDetails) {
|
|
$widgetLinks[] = Vtiger_Link_Model::getInstanceFromValues($widgetDetails);
|
|
}
|
|
return $widgetLinks;
|
|
}
|
|
|
|
/**
|
|
* Function to get the Quick Links for the Detail view of the module
|
|
* @param <Array> $linkParams
|
|
* @return <Array> List of Vtiger_Link_Model instances
|
|
*/
|
|
public function getSideBarLinks($linkParams) {
|
|
$currentUser = Users_Record_Model::getCurrentUserModel();
|
|
|
|
$linkTypes = array('SIDEBARLINK', 'SIDEBARWIDGET');
|
|
$moduleLinks = $this->getModule()->getSideBarLinks($linkTypes);
|
|
|
|
$listLinkTypes = array('DETAILVIEWSIDEBARLINK', 'DETAILVIEWSIDEBARWIDGET');
|
|
$listLinks = Vtiger_Link_Model::getAllByType($this->getModule()->getId(), $listLinkTypes);
|
|
|
|
if($listLinks['DETAILVIEWSIDEBARLINK']) {
|
|
foreach($listLinks['DETAILVIEWSIDEBARLINK'] as $link) {
|
|
$link->linkurl = $link->linkurl.'&record='.$this->getRecord()->getId().'&source_module='.$this->getModule()->getName();
|
|
$moduleLinks['SIDEBARLINK'][] = $link;
|
|
}
|
|
}
|
|
|
|
if($currentUser->getTagCloudStatus()) {
|
|
$tagWidget = array(
|
|
'linktype' => 'DETAILVIEWSIDEBARWIDGET',
|
|
'linklabel' => 'LBL_TAG_CLOUD',
|
|
'linkurl' => 'module='.$this->getModule()->getName().'&view=ShowTagCloud&mode=showTags',
|
|
'linkicon' => '',
|
|
);
|
|
$linkModel = Vtiger_Link_Model::getInstanceFromValues($tagWidget);
|
|
if($listLinks['DETAILVIEWSIDEBARWIDGET']) array_push($listLinks['DETAILVIEWSIDEBARWIDGET'], $linkModel);
|
|
else $listLinks['DETAILVIEWSIDEBARWIDGET'][] = $linkModel;
|
|
}
|
|
|
|
if($listLinks['DETAILVIEWSIDEBARWIDGET']) {
|
|
foreach($listLinks['DETAILVIEWSIDEBARWIDGET'] as $link) {
|
|
$link->linkurl = $link->linkurl.'&record='.$this->getRecord()->getId().'&source_module='.$this->getModule()->getName();
|
|
$moduleLinks['SIDEBARWIDGET'][] = $link;
|
|
}
|
|
}
|
|
|
|
return $moduleLinks;
|
|
}
|
|
|
|
/**
|
|
* Function to get the module label
|
|
* @return <String> - label
|
|
*/
|
|
public function getModuleLabel() {
|
|
return $this->getModule()->get('label');
|
|
}
|
|
|
|
/**
|
|
* Function to get the module name
|
|
* @return <String> - name of the module
|
|
*/
|
|
public function getModuleName() {
|
|
return $this->getModule()->get('name');
|
|
}
|
|
|
|
/**
|
|
* Function to get the instance
|
|
* @param <String> $moduleName - module name
|
|
* @param <String> $recordId - record id
|
|
* @return <Vtiger_DetailView_Model>
|
|
*/
|
|
public static function getInstance($moduleName,$recordId) {
|
|
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'DetailView', $moduleName);
|
|
$instance = new $modelClassName();
|
|
|
|
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
|
|
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
|
|
|
|
return $instance->setModule($moduleModel)->setRecord($recordModel);
|
|
}
|
|
}
|