Files
BACHIR SOULDI 2a647b138a feat: Enhance email functionality and PDF generation for Sales Orders
- Enabled SMTP debugging in PHPMailer for better error tracking.
- Added a "Test send email" link in the Inventory Detail View for quick email testing.
- Implemented automatic PDF generation and email sending upon Sales Order creation.
- Created a new action for sending Sales Order emails with attached PDFs.
- Added a new AJAX action for testing outgoing email server configurations.
- Updated outgoing server settings to use new SMTP credentials.
- Improved email templates for better user experience.
- Added test scripts for validating PDF generation and email sending.
2026-02-17 15:59:31 +01:00

117 lines
4.1 KiB
JavaScript

/*+***********************************************************************************
* 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.
*************************************************************************************/
Vtiger_Detail_Js("Inventory_Detail_Js", {
triggerRecordPreview: function(recordId){
var thisInstance = app.controller();
thisInstance.showRecordPreview(recordId);
},
sendEmailPDFClickHandler: function(url) {
var params = app.convertUrlToDataParams(url);
app.helper.showProgress();
app.request.post({data:params}).then(function(err,response){
var callback = function() {
var emailEditInstance = new Emails_MassEdit_Js();
emailEditInstance.registerEvents();
};
var data = {};
data['cb'] = callback;
app.helper.hideProgress();
app.helper.showModal(response,data);
});
},
testSendEmailPDFClickHandler : function(url){
var params = {
module: 'Vtiger',
parent: 'Settings',
action: 'OutgoingServerAjax',
mode: 'sendTestMail'
};
app.helper.showProgress();
app.request.post({ data: params }).then(function (err, data) {
console.log("data",data);
console.log("err",err);
app.helper.hideProgress();
if (err === null) {
if (data && data.success) {
app.helper.showSuccessNotification({
message: data.message || '✅ Test mail sent successfully!'
});
} else if (data && data.error) {
app.helper.showErrorNotification({
message: data.error.message || '❌ Mailer Error.'
});
} else {
app.helper.showErrorNotification({
message: '❌ Unknown error. Check logs.'
});
}
} else {
app.helper.showErrorNotification({ message: '❌ ' + err.message });
}
});
}
},
{
showRecordPreview: function(recordId, templateId) {
var thisInstance = this;
var params = {};
var moduleName = app.getModuleName();
params['module'] = moduleName;
params['record'] = recordId;
params['view'] = 'InventoryQuickPreview';
params['navigation'] = 'false';
params['mode']='Detail';
if (templateId) {
params['templateid'] = templateId;
}
app.helper.showProgress();
app.request.get({data: params}).then(function(err, response) {
app.helper.hideProgress();
if (templateId) {
jQuery('#pdfViewer').html(response);
return;
}
app.helper.showModal(response, {'cb': function(modal) {
jQuery('.modal-dialog').css({"width": "870px"});
thisInstance.registerChangeTemplateEvent(modal, recordId);
}
});
});
},
registerChangeTemplateEvent: function(container, recordId) {
var thisInstance = this;
var select = container.find('#fieldList');
select.on("change", function() {
var templateId = select.val();
thisInstance.showRecordPreview(recordId, templateId);
});
},
registerEvents: function() {
var self = this;
this._super();
this.getDetailViewContainer().find('.inventoryLineItemDetails').popover({html: true});
app.event.on("post.relatedListLoad.click", function() {
self.getDetailViewContainer().find('.inventoryLineItemDetails').popover({html: true});
});
},
});