From 5c88a77ac1ad07ff15f22b316fbabc101cdbe3fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Aug 2024 18:32:55 +0200 Subject: [PATCH] Enhance the layout email selection --- htdocs/core/class/html.formmail.class.php | 23 ++++++++++++------ .../{commerce.html => products.html} | 12 ++++----- .../maillayout/{commerce.png => products.png} | Bin 3 files changed, 22 insertions(+), 13 deletions(-) rename htdocs/install/doctemplates/maillayout/{commerce.html => products.html} (95%) rename htdocs/theme/common/maillayout/{commerce.png => products.png} (100%) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index f8290e999aa..8b7c851a830 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1518,25 +1518,30 @@ class FormMail extends Form */ public function getModelEmailTemplate($htmlContent = 'message') { + global $langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $out = ''; @@ -1546,6 +1551,10 @@ class FormMail extends Form $(".template-option").click(function() { var template = $(this).data("template"); var subject = jQuery("#subject").val(); + var fromtype = jQuery("#fromtype").val(); + var sendto = jQuery("#sendto").val(); + var sendtocc = jQuery("#sendtocc").val(); + var sendtoccc = jQuery("#sendtoccc").val(); console.log("We choose a layout for email template=" + template + ", subject="+subject); @@ -1562,7 +1571,7 @@ class FormMail extends Form $.ajax({ type: "POST", url: "'.DOL_URL_ROOT.'/core/ajax/mailtemplate.php", - data: { template: template, subject: subject, content: contentHtml, token: csrfToken }, + data: { template: template, subject: subject, fromtype: fromtype, sendto: sendto, sendtocc: sendtocc, sendtoccc: sendtoccc, content: contentHtml, token: csrfToken }, success: function(response) { jQuery("#'.dol_sanitizeKeyCode($htmlContent).'").val(response); var editorInstance = CKEDITOR.instances["'.dol_sanitizeKeyCode($htmlContent).'"]; diff --git a/htdocs/install/doctemplates/maillayout/commerce.html b/htdocs/install/doctemplates/maillayout/products.html similarity index 95% rename from htdocs/install/doctemplates/maillayout/commerce.html rename to htdocs/install/doctemplates/maillayout/products.html index c23571544b0..8c8f9ee6202 100644 --- a/htdocs/install/doctemplates/maillayout/commerce.html +++ b/htdocs/install/doctemplates/maillayout/products.html @@ -2,7 +2,7 @@

Lorem, ipsum dolor sit amet consectetur adipisicing elitsit amet consectetur adipisicing

- + require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -11,7 +11,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $user = new User($db); $product = new Product($db); $products = $product->getProductsToPreviewInEmail(4); - + if (empty($products)){ print '

No Products

'; @@ -20,12 +20,12 @@ $products = $product->getProductsToPreviewInEmail(4); if ($i % 2 == 0) { print '
'; } - + print '
- +
Gray rectangle -
+

'.$product["ref"].'

'.$product["description"].'

@@ -39,6 +39,6 @@ $products = $product->getProductsToPreviewInEmail(4); $i++; } } - +
diff --git a/htdocs/theme/common/maillayout/commerce.png b/htdocs/theme/common/maillayout/products.png similarity index 100% rename from htdocs/theme/common/maillayout/commerce.png rename to htdocs/theme/common/maillayout/products.png