Files
crm.clientright.ru/layouts/v7/modules/EMAILMaker/resources/Detail.js
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

236 lines
8.7 KiB
JavaScript

/*********************************************************************************
* The content of this file is subject to the EMAIL Maker 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.
********************************************************************************/
Vtiger_Detail_Js("EMAILMaker_Detail_Js", {
myCodeMirror: false,
changeActiveOrDefault: function (templateid, type) {
if (templateid != "") {
var url = 'index.php?module=EMAILMaker&action=IndexAjax&mode=ChangeActiveOrDefault&templateid=' + templateid + '&subjectChanged=' + type;
AppConnector.request(url).then(function () {
location.reload(true);
});
}
},
setPreviewContent: function (type) {
var previewcontent = jQuery('#previewcontent_' + type).html();
var previewFrame = document.getElementById('preview_' + type);
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
preview.open();
preview.write(previewcontent);
preview.close();
jQuery('#previewcontent_' + type).html('');
},
}, {
registerEditConditionsClickEvent: function () {
jQuery('.editDisplayConditions').on('click', function (e) {
var element = jQuery(e.currentTarget);
window.location.href = element.data('url');
});
},
registerCreateStyleEvent: function (container) {
var self = this;
jQuery('#js-create-style', container).on('click', function () {
var form = container.find('form');
if (form.valid()) {
self._createStyle(form);
}
});
},
_createStyle: function (form) {
var formData = form.serializeFormData();
app.helper.showProgress();
formData["stylecontent"] = this.myCodeMirror.getValue();
app.request.post({'data': formData}).then(function () {
location.reload(true);
});
},
deleteDocumentRelation: function (relatedId) {
var aDeferred = jQuery.Deferred();
var recordId = app.getRecordId();
var params = {};
params['mode'] = "deleteRelation";
params['module'] = "EMAILMaker";
params['action'] = 'RelationAjax';
params['related_module'] = "Documents";
params['relationId'] = recordId;
params['src_record'] = recordId;
params['related_record_list'] = JSON.stringify([relatedId]);
app.request.post({"data": params}).then(
function (err, responseData) {
aDeferred.resolve(responseData);
},
function (textStatus, errorThrown) {
aDeferred.reject(textStatus, errorThrown);
}
);
return aDeferred.promise();
},
deleteStyleRelation: function (relatedStyleId) {
var aDeferred = jQuery.Deferred();
var recordId = app.getRecordId();
var params = {};
params['mode'] = "deleteRelation";
params['module'] = "ITS4YouStyles";
params['action'] = 'RelationAjax';
params['related_module'] = "EMAILMaker";
params['relationId'] = recordId;
params['src_record'] = recordId;
params['related_record_list'] = JSON.stringify([relatedStyleId]);
app.request.post({"data": params}).then(
function (err, responseData) {
aDeferred.resolve(responseData);
},
function (textStatus, errorThrown) {
aDeferred.reject(textStatus, errorThrown);
}
);
return aDeferred.promise();
},
registerStyleRecord: function (container) {
var self = this;
container.on('click', 'a[name="styleEdit"]', function (e) {
var element = jQuery(e.currentTarget);
window.location.href = element.data('url');
});
container.on('click', 'a.relationDelete', function (e) {
e.stopImmediatePropagation();
var element = jQuery(e.currentTarget);
var key = self.getDeleteMessageKey();
var message = app.vtranslate(key);
var row = element.closest('tr');
var relatedId = row.data('id');
var relatedModuleName = row.data('module');
app.helper.showConfirmationBox({'message': message}).then(
function () {
if (relatedModuleName == "Documents") {
self.deleteDocumentRelation(relatedId).then(function () {
location.reload(true);
});
} else {
self.deleteStyleRelation(relatedId).then(function () {
location.reload(true);
});
}
},
function (error, err) {
}
);
});
},
registerCodeMirorEvent: function () {
var TextArea = document.getElementById("ITS4YouStyles_editView_fieldName_stylecontent");
this.myCodeMirror = CodeMirror.fromTextArea(TextArea, {
mode: 'shell',
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
height: 'dynamic'
});
},
registerAddStyleClickEvent: function () {
var self = this;
jQuery('.addStyleContentBtn').on('click', function () {
var recordId = app.getRecordId();
var params = {
module: 'ITS4YouStyles',
view: 'AddStyleAjax',
source_module: 'EMAILMaker',
source_id: recordId
};
app.helper.showProgress();
app.request.get({data: params}).then(function (err, response) {
var callback = function (container) {
self.registerCreateStyleEvent(container);
self.registerCodeMirorEvent(container);
};
var data = {};
data['cb'] = callback;
app.helper.hideProgress();
app.helper.showModal(response, data);
});
});
},
registerEventForSelectingRelatedStyle: function () {
var thisInstance = this;
var detailViewContainer = thisInstance.getDetailViewContainer();
detailViewContainer.on('click', 'button.selectTemplateRelation', function (e) {
var modulename = jQuery(e.currentTarget).attr('data-modulename');
var relatedController = thisInstance.getRelatedController(modulename);
if (relatedController) {
var popupParams = relatedController.getPopupParams();
var popupjs = new Vtiger_Popup_Js();
popupjs.showPopup(popupParams, "post." + modulename + ".List.click");
}
});
},
registerEvents: function () {
var thisInstance = this;
var detailViewContainer = this.getContentHolder();
thisInstance.registerEditConditionsClickEvent();
thisInstance.registerAddStyleClickEvent();
thisInstance.registerStyleRecord(detailViewContainer);
thisInstance.registerEventForSelectingRelatedStyle();
//thisInstance.setPreviewContent('body');
app.event.on("post.Documents.List.click", function (event, data) {
var responseData = JSON.parse(data);
var idList = [];
for (var id in responseData) {
idList.push(id);
}
app.helper.hideModal();
var relatedController = thisInstance.getRelatedController('Documents');
if (relatedController) {
relatedController.addRelations(idList).then(function () {
location.reload();
});
}
});
app.event.on("post.ITS4YouStyles.List.click", function (event, data) {
var responseData = JSON.parse(data);
var idList = [];
for (var id in responseData) {
idList.push(id);
}
app.helper.hideModal();
var relatedController = thisInstance.getRelatedController('ITS4YouStyles');
if (relatedController) {
relatedController.addRelations(idList).then(function () {
location.reload();
});
}
});
}
});