Enhance the layout email selection
This commit is contained in:
parent
af779ead51
commit
5c88a77ac1
3 changed files with 22 additions and 13 deletions
|
|
@ -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 = '<div id="template-selector" class="template-container hidden">';
|
||||
$templates = array(
|
||||
'empty' => 'empty',
|
||||
'basic' => 'basic',
|
||||
);
|
||||
//if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 1) {
|
||||
$templates['news'] = 'news';
|
||||
$templates['commerce'] = 'commerce';
|
||||
//$templates['text'] = 'text';
|
||||
|
||||
$arrayoflayoutemplates = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/doctemplates/maillayout/', 'files', 0, '\.html$');
|
||||
foreach ($arrayoflayoutemplates as $layouttemplatefile) {
|
||||
$layoutname = preg_replace('/\.html$/i', '', $layouttemplatefile['name']);
|
||||
$templates[$layoutname] = ucfirst($layoutname);
|
||||
}
|
||||
//}
|
||||
// TODO Add a hook to allow to complete the list
|
||||
|
||||
foreach ($templates as $template => $templateFunction) {
|
||||
$contentHtml = getHtmlOfLayout($template);
|
||||
|
||||
$out .= '<div class="template-option" data-template="'.$template.'" data-content="'.htmlentities($contentHtml).'">';
|
||||
$out .= '<img class="maillayout" alt="'.$template.'" src="'.DOL_URL_ROOT.'/theme/common/maillayout/'.$template.'.png" />';
|
||||
$out .= '<span class="template-option-text">'.ucfirst($template).'</span>';
|
||||
$out .= '<span class="template-option-text">'.$langs->trans($templateFunction).'</span>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
$out .= '</div>';
|
||||
|
|
@ -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).'"];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2 style="margin-left:120px;">Lorem, ipsum dolor sit amet consectetur adipisicing elitsit amet consectetur adipisicing </h2>
|
||||
|
||||
<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 16px; max-width: 600px; margin: 0 auto; box-sizing: border-box;">
|
||||
|
||||
|
||||
<!-- PHP_START -->
|
||||
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 '<p>No Products</p>';
|
||||
|
|
@ -20,12 +20,12 @@ $products = $product->getProductsToPreviewInEmail(4);
|
|||
if ($i % 2 == 0) {
|
||||
print '<div style="display: flex; justify-content: space-between; margin-bottom: 20px;">';
|
||||
}
|
||||
|
||||
|
||||
print '<div style="flex: 1; padding-right: 10px;">
|
||||
|
||||
|
||||
<div>
|
||||
<img alt="Gray rectangle" style="margin-left: 120px; margin-top: 30px;" width="350px" height="100px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=produit&file='.$product['ref'].'/'.$product['filename'].'" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-left: 120px; background-color: #e0e0e0; padding: 8px; margin-bottom: 8px; text-indent: 50px;">
|
||||
<h3>'.$product["ref"].'</h3>
|
||||
<p>'.$product["description"].'</p>
|
||||
|
|
@ -39,6 +39,6 @@ $products = $product->getProductsToPreviewInEmail(4);
|
|||
$i++;
|
||||
}
|
||||
}
|
||||
<!-- PHP_END -->
|
||||
<!-- PHP_END -->
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in a new issue