Debug v22

This commit is contained in:
Laurent Destailleur 2025-04-17 03:56:54 +02:00
parent 2b721ba245
commit a40aec6029
4 changed files with 58 additions and 16 deletions

View file

@ -564,7 +564,7 @@ if (empty($reshook)) {
$object->email_replyto = (string) GETPOST("replyto", 'alphawithlgt'); // Must allow 'name <email>'
$object->email_errorsto = (string) GETPOST("errorsto", 'alphawithlgt'); // Must allow 'name <email>'
$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 '<br>';
print '<table class="border centpercent">';
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input id="sujet" class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet', 'alphanohtml')).'"></td></tr>';
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td>';
print '<td><input id="subject" class="flat minwidth200 quatrevingtpercent" name="subject" id="subject" value="'.dol_escape_htmltag(GETPOST('subject', 'alphanohtml')).'"></td></tr>';
print '<tr class="fieldsforemail"><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0);
print '</td></tr>';
@ -1329,7 +1332,7 @@ if ($action == 'create') { // aaa
print '</table>';
// Message
print '<div style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor : 'white').'">';
print '<div class="previewemail" style="padding-top: 10px; background: '.($object->bgcolor ? (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor : 'white').'">';
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 '<tr><td class="fieldrequired titlefield">';
print $langs->trans("MailTopic");
print '</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" name="sujet" value="'.$object->sujet.'"></td></tr>';
print $form->textwithpicto($langs->trans("MailTopic"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp');
print '</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" id="subject" name="subject" value="'.$object->sujet.'"></td></tr>';
}
$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 '</td></tr>';
}
// Add editor assistants
$out = '';
$out .= '<tr>';
$out .= '<td class="tdtop">';
$out .= $form->textwithpicto($langs->trans('MailText'), $htmltext, 1, 'help', '', 0, 2, 'substittooltipfrombody');
$out .= '</td>';
$out .= '<td class="tdtop">';
//$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 .= '</td>';
$out .= '</tr>';
print $out;
print '</table>';
@ -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('/^<div style="background-color: #'.$object->bgcolor.'">/', $object->body)) {
$object->body = '<div style="background-color: #'.$object->bgcolor.'; margin-bottom:-20px; margin-left:-10px; margin-right:-10px; margin-top:-10px; padding: 10px;">'.$object->body.'</div>';
}
}
$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 '</div>';
print dol_get_fiche_end();
print '<div class="center">';

View file

@ -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 = '<div id="template-selector" class="template-selector email-layout-container hidden" style="display:none;">';
// Define list of email layouts to use
@ -1546,6 +1542,11 @@ class FormMail extends Form
$out .= '</div>';
// 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 .= '</div>';
$out .= '<!-- Js code to manage choice of an email layout -->'."\n";
$out .= '<script type="text/javascript">
$(document).ready(function() {
$(".template-option").click(function() {

View file

@ -395,6 +395,7 @@ class FormWebsite
$out .= '<input type="hidden" name="sample" value="" />';
$out .= '</div>';
$out .= '<!-- Js code to manage choice of a page layout for website -->'."\n";
$out .= '<script type="text/javascript">
$(document).ready(function() {
$(".template-option").click(function() {

View file

@ -123,6 +123,11 @@ if ($showlinktolayout) {
if (!empty($formwebsite) && is_object($formwebsite)) {
$out .= $formwebsite->getContentPageTemplate($htmlname);
} else {
if (!is_object($formmail)) {
// Create form object
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
}
$out .= $formmail->getModelEmailTemplate($htmlname, $showlinktolayout);
}
} else {