From a40aec6029079bda8c21d83fa1eb9bdcd337c5a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Apr 2025 03:56:54 +0200 Subject: [PATCH] Debug v22 --- htdocs/comm/mailing/card.php | 48 +++++++++++++++++--- htdocs/core/class/html.formmail.class.php | 20 ++++---- htdocs/core/class/html.formwebsite.class.php | 1 + htdocs/core/tpl/formlayoutai.tpl.php | 5 ++ 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 093932ee077..9beaa187cd3 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -564,7 +564,7 @@ if (empty($reshook)) { $object->email_replyto = (string) GETPOST("replyto", 'alphawithlgt'); // Must allow 'name ' $object->email_errorsto = (string) GETPOST("errorsto", 'alphawithlgt'); // Must allow 'name ' $object->title = (string) GETPOST("title"); - $object->sujet = (string) GETPOST("sujet"); + $object->sujet = (string) GETPOST("subject"); $object->body = (string) GETPOST("bodyemail", 'restricthtml'); $object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor")); $object->bgimage = (string) GETPOST("bgimage"); @@ -660,7 +660,7 @@ if (empty($reshook)) { $mesgs = array(); //$object->messtype = (string) GETPOST("messtype"); // We must not be able to change the messtype - $object->sujet = (string) GETPOST("sujet"); + $object->sujet = (string) GETPOST("subject"); $object->body = (string) GETPOST("bodyemail", 'restricthtml'); $object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor")); $object->bgimage = (string) GETPOST("bgimage"); @@ -860,7 +860,10 @@ if ($action == 'create') { // aaa print '
'; print ''; - print ''; + + print ''; + print ''; + print ''; @@ -1329,7 +1332,7 @@ if ($action == 'create') { // aaa print '
'.$langs->trans("MailTopic").'
'.$langs->trans("MailTopic").'
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0); print '
'; // Message - print '
'; + print '
'; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') { // CKEditor does not apply the color of the div into its content area $readonly = 1; // wysiwyg editor @@ -1490,8 +1493,8 @@ if ($action == 'create') { // aaa // Subject if ($object->messtype != 'sms') { print ''; - print $langs->trans("MailTopic"); - print ''; + print $form->textwithpicto($langs->trans("MailTopic"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'); + print ''; } $trackid = ''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. @@ -1544,6 +1547,33 @@ if ($action == 'create') { // aaa print ''; } + + // Add editor assistants + $out = ''; + $out .= ''; + $out .= ''; + $out .= $form->textwithpicto($langs->trans('MailText'), $htmltext, 1, 'help', '', 0, 2, 'substittooltipfrombody'); + $out .= ''; + $out .= ''; + + //$formmail = $this; + $showlinktolayout = getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT') ? 'emailing' : ''; + $showlinktolayoutlabel = $langs->trans("FillMessageWithALayout"); + $showlinktoai = isModEnabled('ai') ? 'textgenerationemail' : ''; + $showlinktoailabel = $langs->trans("AIEnhancements"); + $formatforouput = ''; + $htmlname = 'bodyemail'; + //$formai->substit = $this->substit; + //$formai->substit_lines = $this->substit_lines; + + // Fill $out + include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php'; + + $out .= ''; + $out .= ''; + + print $out; + print ''; @@ -1553,6 +1583,11 @@ if ($action == 'create') { // aaa if ($action == 'edit') { // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + if ($object->bgcolor) { + if (!preg_match('/^
/', $object->body)) { + $object->body = '
'.$object->body.'
'; + } + } $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, -1, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '100%'); $doleditor->Create(); } @@ -1571,7 +1606,6 @@ if ($action == 'create') { // aaa print '
'; - print dol_get_fiche_end(); print '
'; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 11a7f21645b..5bc12424751 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -472,14 +472,14 @@ class FormMail extends Form // phpcs:enable global $conf, $langs, $user, $hookmanager, $form; - // Required to show preview wof mail attachments - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($this->db); - if (!is_object($form)) { $form = new Form($this->db); } + // Required to show editor assistants + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($this->db); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formai.class.php'; $formai = new FormAI($this->db); @@ -1494,7 +1494,7 @@ class FormMail extends Form /** * Return HTML code for selection of email layout * - * @param string $htmlContent HTML name of WYSIWYG field to fill + * @param string $htmlContent HTML name of WYSIWYG field to fill once layout has been chosen * @param string $showlinktolayout Show link to layout * @return string HTML for model email boxes */ @@ -1506,10 +1506,6 @@ class FormMail extends Form require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - // Fetch blogs - $websitepage = new WebsitePage($this->db); - $arrayofblogs = $websitepage->fetchAll('', 'DESC', 'date_creation', 0, 0, array('type_container' => 'blogpost')); - $out = ''; // Prepare the array for multiselect + + // Fetch blogs + $websitepage = new WebsitePage($this->db); + $arrayofblogs = $websitepage->fetchAll('', 'DESC', 'date_creation', 0, 0, array('type_container' => 'blogpost')); + $blogArray = array(); if (!empty($arrayofblogs)) { foreach ($arrayofblogs as $blog) { @@ -1559,6 +1560,7 @@ class FormMail extends Form $out .= self::multiselectarray('blogpost-select', $blogArray, array(), 0, 0, 'minwidth200'); $out .= '
'; + $out .= ''."\n"; $out .= '