forked from Wavyzz/dolibarr
WIP mail layout
This commit is contained in:
@@ -55,6 +55,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
|
|||||||
* @var User $user
|
* @var User $user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@@ -62,8 +63,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
|
|||||||
top_httphead();
|
top_httphead();
|
||||||
|
|
||||||
// TODO Replace with ID of template
|
// TODO Replace with ID of template
|
||||||
if (GETPOSTISSET('content')) {
|
if (GETPOSTISSET('template')) {
|
||||||
$content = filter_input(INPUT_POST, 'content', FILTER_UNSAFE_RAW);
|
$templatefile = DOL_DOCUMENT_ROOT.'/install/doctemplates/maillayout/'.dol_sanitizeFileName(GETPOST('template')).'.html';
|
||||||
|
|
||||||
|
$content = file_get_contents($templatefile);
|
||||||
|
|
||||||
|
if ($content === false) {
|
||||||
|
print 'Failed to load template '.dol_escape_htmltag(GETPOST('template'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define $urlwithroot
|
||||||
|
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||||
|
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||||
|
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||||
|
|
||||||
|
|
||||||
|
$specificSubstitutionArray = array(
|
||||||
|
'__LOGO_URL__' => !empty($mysoc->logo) && dol_is_file($conf->mycompany->dir_output.'/logos/'.$mysoc->logo) ? $urlwithroot.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo) : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
||||||
|
'__TITLEOFMAILHOLDER__' => $langs->trans('TitleOfMailHolder'),
|
||||||
|
'__CONTENTOFMAILHOLDER__' => 'Lorem ipsum ...',
|
||||||
|
'__USERSIGNATURE__' => !empty($user->signature) ? dol_htmlentities($user->signature) : '',
|
||||||
|
'__GRAY_RECTANGLE__' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
||||||
|
'__LAST_NEWS__' => $langs->trans('LastNews'),
|
||||||
|
'__LIST_PRODUCTS___' => $langs->trans('ListProducts'),
|
||||||
|
'__SUBJECT__' => GETPOST('subject')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Must replace
|
||||||
|
// __SUBJECT__, __CONTENTOFMAILHOLDER__, __USERSIGNATURE__, __NEWS_LIST__, __PRODUCTS_LIST__
|
||||||
|
foreach ($specificSubstitutionArray as $key => $val) {
|
||||||
|
$content = str_replace($key, $val, $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$selectedPostsStr = GETPOST('selectedPosts', 'alpha');
|
$selectedPostsStr = GETPOST('selectedPosts', 'alpha');
|
||||||
$selectedPosts = explode(',', $selectedPostsStr);
|
$selectedPosts = explode(',', $selectedPostsStr);
|
||||||
@@ -93,8 +125,7 @@ if (GETPOSTISSET('content')) {
|
|||||||
$content = str_replace('__NEWS_LIST__', 'No articles selected', $content);
|
$content = str_replace('__NEWS_LIST__', 'No articles selected', $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print $content;
|
print $content;
|
||||||
} else {
|
} else {
|
||||||
print 'No content provided or invalid token';
|
print 'No template ID provided or expired token';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1560,25 +1560,20 @@ class FormMail extends Form
|
|||||||
$out .= '</div>';
|
$out .= '</div>';
|
||||||
|
|
||||||
$out .= '<script type="text/javascript">
|
$out .= '<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".template-option").click(function() {
|
$(".template-option").click(function() {
|
||||||
var template = $(this).data("template");
|
var template = $(this).data("template");
|
||||||
var subject = jQuery("#subject").val();
|
var subject = jQuery("#subject").val();
|
||||||
var fromtype = jQuery("#fromtype").val();
|
var fromtype = jQuery("#fromtype").val();
|
||||||
var sendto = jQuery("#sendto").val();
|
var sendto = jQuery("#sendto").val();
|
||||||
var sendtocc = jQuery("#sendtocc").val();
|
var sendtocc = jQuery("#sendtocc").val();
|
||||||
var sendtoccc = jQuery("#sendtoccc").val();
|
var sendtoccc = jQuery("#sendtoccc").val();
|
||||||
|
|
||||||
console.log("We choose a layout for email template=" + template + ", subject="+subject);
|
console.log("We choose a layout for email template=" + template + ", subject="+subject);
|
||||||
|
|
||||||
$(".template-option").removeClass("selected");
|
$(".template-option").removeClass("selected");
|
||||||
$(this).addClass("selected");
|
$(this).addClass("selected");
|
||||||
|
|
||||||
var subject = $("#sujet").val();
|
|
||||||
|
|
||||||
var contentHtml = $(this).data("content");
|
|
||||||
contentHtml = contentHtml.replace(/__SUBJECT__/g, subject);
|
|
||||||
|
|
||||||
if (template === "news") {
|
if (template === "news") {
|
||||||
$("#post-dropdown-container").show();
|
$("#post-dropdown-container").show();
|
||||||
console.log("Displaying dropdown for news template");
|
console.log("Displaying dropdown for news template");
|
||||||
@@ -1631,7 +1626,7 @@ class FormMail extends Form
|
|||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
var selectedPosts = JSON.parse(response);
|
var selectedPosts = JSON.parse(response);
|
||||||
var subject = $("#sujet").val();
|
var subject = $("#subject").val();
|
||||||
|
|
||||||
contentHtml = contentHtml.replace(/__SUBJECT__/g, subject);
|
contentHtml = contentHtml.replace(/__SUBJECT__/g, subject);
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function getHtmlOfLayout($name)
|
|||||||
$specificSubstitutionArray = array(
|
$specificSubstitutionArray = array(
|
||||||
'__LOGO_URL__' => !empty($mysoc->logo) && dol_is_file($conf->mycompany->dir_output.'/logos/'.$mysoc->logo) ? DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo) : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
'__LOGO_URL__' => !empty($mysoc->logo) && dol_is_file($conf->mycompany->dir_output.'/logos/'.$mysoc->logo) ? DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo) : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
||||||
'__TITLEOFMAILHOLDER__' => $langs->trans('TitleOfMailHolder'),
|
'__TITLEOFMAILHOLDER__' => $langs->trans('TitleOfMailHolder'),
|
||||||
'__CONTENOFMAILHOLDER__' => $langs->trans('ContentOfMailHolder'),
|
'__CONTENTOFMAILHOLDER__' => $langs->trans('ContentOfMailHolder'),
|
||||||
'__USERSIGNATURE__' => !empty($user->signature) ? dol_htmlentities($user->signature) : '',
|
'__USERSIGNATURE__' => !empty($user->signature) ? dol_htmlentities($user->signature) : '',
|
||||||
'__GRAY_RECTANGLE__' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
'__GRAY_RECTANGLE__' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC',
|
||||||
'__LAST_NEWS__' => $langs->trans('LastNews'),
|
'__LAST_NEWS__' => $langs->trans('LastNews'),
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div style="text-align:center; padding: 20px;">
|
<div">
|
||||||
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
|
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
|
||||||
</div>
|
</div>
|
||||||
<h2>__SUBJECT__</h2>
|
<h2>__SUBJECT__</h2>
|
||||||
<div class="email-template-text">
|
<div class="email-template-text">
|
||||||
<p>__CONTENOFMAILHOLDER__</p>
|
<p>__CONTENTOFMAILHOLDER__</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ body {
|
|||||||
|
|
||||||
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0px 0px 20px #aaa;">
|
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0px 0px 20px #aaa;">
|
||||||
<div style="width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
|
<div style="width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
|
||||||
Logo
|
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
|
||||||
</div>
|
</div>
|
||||||
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
|
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
|
||||||
Hello
|
Hello
|
||||||
@@ -22,7 +22,7 @@ body {
|
|||||||
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
|
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
|
||||||
|
|
||||||
<h1>__LAST_NEWS__</h1>
|
<h1>__LAST_NEWS__</h1>
|
||||||
<h2>__CONTENOFMAILHOLDER__ </h2>
|
<h2>__CONTENTOFMAILHOLDER__ </h2>
|
||||||
|
|
||||||
<!-- NEWS_START -->
|
<!-- NEWS_START -->
|
||||||
__NEWS_LIST__
|
__NEWS_LIST__
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ body {
|
|||||||
|
|
||||||
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0px 0px 20px #aaa;">
|
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0px 0px 20px #aaa;">
|
||||||
<div style="width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
|
<div style="width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
|
||||||
Logo
|
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
|
||||||
</div>
|
</div>
|
||||||
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
|
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
|
||||||
Hello
|
Hello
|
||||||
@@ -22,7 +22,7 @@ body {
|
|||||||
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
|
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
|
||||||
|
|
||||||
<h1>__LAST_NEWS__</h1>
|
<h1>__LAST_NEWS__</h1>
|
||||||
<h2>__CONTENOFMAILHOLDER__ </h2>
|
<h2>__CONTENTOFMAILHOLDER__ </h2>
|
||||||
|
|
||||||
<!-- PRODUCTS_START -->
|
<!-- PRODUCTS_START -->
|
||||||
__PRODUCTS_LIST__
|
__PRODUCTS_LIST__
|
||||||
|
|||||||
Reference in New Issue
Block a user