Files
crm.clientright.ru/modules/ITS4YouGoogleCalendarSync/views/List.php
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

189 lines
7.7 KiB
PHP

<?php
/*+**********************************************************************************
* The content of this file is subject to the ITS4GoogleCalendarSync license.
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is IT-Solutions4You s.r.o.
* Portions created by IT-Solutions4You s.r.o. are Copyright(C) IT-Solutions4You s.r.o.
* All Rights Reserved.
************************************************************************************/
class ITS4YouGoogleCalendarSync_List_View extends Vtiger_PopupAjax_View
{
protected $noRecords = false;
public function __construct()
{
$this->exposeMethod('Calendar');
}
function checkPermission(Vtiger_Request $request)
{
return true;
}
public function preProcess(Vtiger_Request $request, $display = true)
{
vtws_addDefaultModuleTypeEntity($request->getModule());
return parent::preProcess($request);
}
function process(Vtiger_Request $request)
{
switch ($request->get('operation')) {
case "sync" :
$this->renderSyncUI($request);
break;
default:
$this->renderWidgetUI($request);
break;
}
}
function renderSyncUI(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
try {
$records = $this->invokeExposedMethod('Calendar');
} catch (Zend_Gdata_App_HttpException $e) {
$errorCode = $e->getResponse()->getStatus();
if ($errorCode == 401) {
$this->removeSynchronization($request);
$response = new Vtiger_Response();
$response->setError(401);
$response->emit();
return false;
}
}
$current_user = Users_Record_Model::getCurrentUserModel();
$isUserConnected = ITS4YouGoogleCalendarSync_Utils_Helper::isUserConnected($current_user);
$viewer->assign('IS_USER_CONNECTED', $isUserConnected);
$viewer->assign('RECORDS', $records);
$viewer->assign('NORECORDS', $this->noRecords);
$viewer->assign('SYNCTIME', ITS4YouGoogleCalendarSync_Utils_Helper::getLastSyncTime());
$viewer->assign('MODULE_NAME', $request->getModule(false));
$viewer->view('ContentDetails.tpl', 'ITS4YouGoogleCalendarSync');
}
function renderWidgetUI(Vtiger_Request $request)
{
$current_user = Users_Record_Model::getCurrentUserModel();
$moduleName = $request->getModule();
$viewer = $this->getViewer($request);
$List = array();
$googleSettings = array(
"name" => "calendarSettings",
"label" => "LBL_CALENDAR_SETTINGS",
"id" => "calendar_settings",
"href" => "javascript:CalendarSidebarWidget.getInstance().initCalendarSettings()"
);
$List['settings '] = $googleSettings;
$viewer->assign("ACTION_LIST", $List);
$viewer->assign('SCRIPTS', $this->getHeaderScripts($request));
$isUserConnected = ITS4YouGoogleCalendarSync_Utils_Helper::isUserConnected($current_user);
$viewer->assign('IS_USER_CONNECTED', $isUserConnected);
$userCredentials = ITS4YouGoogleCalendarSync_UserCredentials_Model::getInstanceForCurrentUser();
if (!$userCredentials) {
$userCredentials = 'not_set';
}
$viewer->assign('USER_CREDENTIALS', $userCredentials);
$viewer->assign("QUALIFIED_MODULE", $moduleName);
$viewer->assign('SCRIPTS', $this->getHeaderScripts($request));
$viewer->assign('SYNCTIME', ITS4YouGoogleCalendarSync_Utils_Helper::getLastSyncTime());
$viewer->assign('VERSION', ITS4YouGoogleCalendarSync_Version_Helper::$version);
$viewer->view("CalendarSidebarWidget.tpl", $moduleName);
}
/**
* Function to get the list of Script models to be included
* @param Vtiger_Request $request
* @return <Array> - List of Vtiger_JsScript_Model instances
*/
public function getHeaderScripts(Vtiger_Request $request)
{
$moduleName = $request->getModule();
return $this->checkAndConvertJsScripts(array("~libraries/bootstrap/js/bootstrap-popover.js", "modules.$moduleName.resources.CalendarSidebarWidget"));
}
/**
* Sync Calendar Records
* @return <array> Count of Calendar Records
*/
public function Calendar($userId = false)
{
$user = Users_Record_Model::getCurrentUserModel();
$isUserConnected = ITS4YouGoogleCalendarSync_Utils_Helper::isUserConnected($user);
if ($isUserConnected) {
$controller = new ITS4YouGoogleCalendarSync_Calendar_Controller($user);
$records = $controller->getSynchronizedRecords();
$syncRecords = $this->getSyncRecordsCount($records);
$syncRecords['vtiger']['more'] = $controller->targetConnector->moreRecordsExits();
$syncRecords['google']['more'] = $controller->sourceConnector->moreRecordsExits();
return $syncRecords;
} else {
return false;
}
}
public function getSyncRecordsCount($syncRecords)
{
$pullRecord = $pushRecord = array();
$countRecords = array('vtiger' => array('update' => 0, 'create' => 0, 'delete' => 0), 'google' => array('update' => 0, 'create' => 0, 'delete' => 0));
foreach ($syncRecords as $key => $records) {
if ($key == 'push') {
$pushRecord = false;
if (count($records) == 0) {
$pushRecord = true;
}
foreach ($records as $record) {
foreach ($record as $type => $data) {
if ($type == 'source') {
if ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_UPDATE_MODE) {
$countRecords['vtiger']['update']++;
} elseif ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_CREATE_MODE) {
$countRecords['vtiger']['create']++;
} elseif ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_DELETE_MODE) {
$countRecords['vtiger']['delete']++;
}
}
}
}
} else {
if ($key == 'pull') {
$pullRecord = false;
if (count($records) == 0) {
$pullRecord = true;
}
foreach ($records as $type => $record) {
foreach ($record as $type => $data) {
if ($type == 'target') {
if ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_UPDATE_MODE) {
$countRecords['google']['update']++;
} elseif ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_CREATE_MODE) {
$countRecords['google']['create']++;
} elseif ($data->getMode() == WSAPP_SyncRecordModel::WSAPP_DELETE_MODE) {
$countRecords['google']['delete']++;
}
}
}
}
}
}
}
if ($pullRecord && $pushRecord) {
$this->noRecords = true;
}
return $countRecords;
}
}