From 13e1209c01c4c2b169442b47c9d4b6901bf7cb6f Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 15 Mar 2024 17:15:24 +0100 Subject: [PATCH 01/51] FIX problem for display content in editor --- htdocs/comm/mailing/card.php | 4 ++-- htdocs/core/class/html.formmail.class.php | 25 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 216ec9bbdd8..d0efa85599e 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -895,10 +895,10 @@ if ($action == 'create') { '; } if ($formmail->withfckeditor) { - $out .= $formmail->getModelEmailTemplate(); + $out .= $formmail->getModelEmailTemplate('bodyemail'); } if ($formmail->withaiprompt && isModEnabled('ai')) { - $out .= $formmail->getSectionForAIPrompt(); + $out .= $formmail->getSectionForAIPrompt('', 'bodyemail'); } print $out; print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7557a9d89ce..f9cde0e1d1a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1004,6 +1004,8 @@ class FormMail extends Form $out .= ''; $out .= ''; + $this->withaiprompt = 'html'; + $this->withlayout = 1; // Add link to add layout if ($this->withlayout && $this->withfckeditor) { $out .= ''; @@ -1440,9 +1442,10 @@ class FormMail extends Form * Return Html code for AI instruction of message and autofill result * * @param string $format Format for output ('', 'html', ...) + * @param string $htmlContent HTML name of WYSIWIG field * @return string HTML code to ask AI instruction and autofill result */ - public function getSectionForAIPrompt($format = '') + public function getSectionForAIPrompt($format = '', $htmlContent = 'message') { global $langs; @@ -1473,8 +1476,8 @@ class FormMail extends Form $('#ai_status_message').show(); //editor on readonly - if (CKEDITOR.instances.message) { - CKEDITOR.instances.message.setReadOnly(1); + if (CKEDITOR.instances.".$htmlContent.") { + CKEDITOR.instances.".$htmlContent.".setReadOnly(1); } $.ajax({ @@ -1486,13 +1489,13 @@ class FormMail extends Form 'instructions': instructions, }), success: function(response) { - console.log('Add response into field message: '+response); + console.log('Add response into field ".$htmlContent.": '+response); - jQuery('#message').val(response); + jQuery('#".$htmlContent."').val(response); - if (CKEDITOR.instances && CKEDITOR.instances.message && ".getDolGlobalInt('FCKEDITOR_ENABLE_MAIL', 0).") { - CKEDITOR.instances.message.setReadOnly(0); - CKEDITOR.instances.message.setData(response); + if (CKEDITOR.instances && CKEDITOR.instances.".$htmlContent." && ".getDolGlobalInt('FCKEDITOR_ENABLE_MAIL', 0).") { + CKEDITOR.instances.".$htmlContent.".setReadOnly(0); + CKEDITOR.instances.".$htmlContent.".setData(response); } // remove readonly @@ -1516,10 +1519,10 @@ class FormMail extends Form /** * Return HTML code for selection of email layout - * + * @param string $htmlContent HTML name of WYSIWIG field * @return string HTML for model email boxes */ - public function getModelEmailTemplate() + public function getModelEmailTemplate($htmlContent = 'message') { require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php'; @@ -1551,7 +1554,7 @@ class FormMail extends Form var template = $(this).data('template'); var contentHtml = $(this).data('content'); - var editorInstance = CKEDITOR.instances.message; + var editorInstance = CKEDITOR.instances.".$htmlContent."; if (editorInstance) { editorInstance.setData(contentHtml); } From 7d49d0e20b4fcb976ea8884389b5c5bb76684992 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 15 Mar 2024 18:05:32 +0100 Subject: [PATCH 02/51] NEW annimation for display spinner when waiting response --- htdocs/core/class/html.formmail.class.php | 8 +++- htdocs/theme/eldy/global.inc.php | 46 +++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7557a9d89ce..290c4ffec6d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1454,7 +1454,8 @@ class FormMail extends Form $out .= ''; $out .= ''; $out .= ''; - $out .= '
'.$langs->trans("AIProcessingPleaseWait").'
'; + $out .= '
'; + $out .= ''.$langs->trans("AIProcessingPleaseWait").'
'; $out .= "\n"; $out .= "