WIP mail layout

This commit is contained in:
ldestailleur 2025-04-17 01:31:06 +02:00
parent 9f3281cf1d
commit 2b721ba245
5 changed files with 58 additions and 34 deletions

View file

@ -38,9 +38,6 @@ if (!defined('NOREQUIREHTML')) {
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require_once '../../main.inc.php';
require_once '../lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -51,10 +48,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Societe $mysoc
* @var Translate $langs
* @var User $user
*/
/*
* Actions
*/
// None
/*
* View
@ -80,22 +84,43 @@ if (GETPOSTISSET('template')) {
$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')
);
if (!empty($mysoc->logo) && dol_is_file($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
$specificSubstitutionArray['__LOGO_URL__'] = $urlwithroot.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
} else {
$specificSubstitutionArray['__LOGO_URL__'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAIAAABM5OhcAAABGklEQVR4nO3SwQ3AIBDAsNLJb3SWIEJC9gR5ZM3MB6f9twN4k7FIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIuEsUgYi4SxSBiLhLFIGIvEBtxYAkgpLmAeAAAAAElFTkSuQmCC';
}
$specificSubstitutionArray['__USERSIGNATURE__'] = empty($user->signature) ? '' : $user->signature;
if (GETPOST('fromtype') == 'user') {
$specificSubstitutionArray['__SENDEREMAIL_SIGNATURE__'] = empty($user->signature) ? '' : $user->signature;
} elseif (GETPOST('fromtype') == 'company') {
$specificSubstitutionArray['__SENDEREMAIL_SIGNATURE__'] = $mysoc->name.' '.$mysoc->email;
} elseif (GETPOST('fromtype') == 'main_from') {
$specificSubstitutionArray['__SENDEREMAIL_SIGNATURE__'] = $mysoc->name.' '.getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
} else {
// GETPOST('fromtype') is senderprofile_x_y (x = ID profile)
$specificSubstitutionArray['__SENDEREMAIL_SIGNATURE__'] = 'TODO Read database to get the signature of the profile';
}
// Must replace
// __SUBJECT__, __CONTENTOFMAILHOLDER__, __USERSIGNATURE__, __NEWS_LIST__, __PRODUCTS_LIST__
foreach ($specificSubstitutionArray as $key => $val) {
$content = str_replace($key, $val, $content);
}
// Parse all strings __(...)__ to replace with the translated value.
// TODO
$selectedPostsStr = GETPOST('selectedPosts', 'alpha');
$selectedPosts = explode(',', $selectedPostsStr);

View file

@ -133,7 +133,7 @@ class DolEditor
// Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor')
$defaulteditor = 'ckeditor';
$this->tool = !getDolGlobalString('FCKEDITOR_EDITORNAME') ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME;
$this->tool = getDolGlobalString('FCKEDITOR_EDITORNAME', $defaulteditor);
$this->uselocalbrowser = $uselocalbrowser;
$this->readonly = $readonly;
@ -207,7 +207,7 @@ class DolEditor
$fullpage = false;
$extraAllowedContent = 'a[target];section[contenteditable,id];div{background-color,display,float,height,margin,margin-top,margin-bottom,padding,width,border-top-left-radius,border-top-right-radius,box-shadow}';
$extraAllowedContent = 'a[target];section[contenteditable,id];div{background-color,color,display,float,height,margin,margin-top,margin-bottom,padding,width,border-top-left-radius,border-top-right-radius,box-shadow}';
if (is_string($restrictContent)) {
$extraAllowedContent = $restrictContent;
}

View file

@ -1,8 +1,6 @@
<div>
<div">
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
<div>
<img src="__LOGO_URL__" style="height: 100px; max-width: 400px; border-radius: 4px;">
</div>
<h2>__SUBJECT__</h2>
<div class="email-template-text">
@ -12,5 +10,6 @@
<br>
<hr>
__USERSIGNATURE__
__SENDEREMAIL_SIGNATURE__<br>
__CHECK_READ__
</div>

View file

@ -7,22 +7,22 @@ body {
</style>
<div style="background-color: #e2f3fd; padding: 0; margin-top:-10px; margin-bottom:-20px; margin-left:-10px; margin-right:-10px; width:calc(100% + 20px)">
<div style="width: 600px; margin: 0 auto; background-color: #e2f3fd;">
<div style="width: 680px; margin: 0 auto; background-color: #e2f3fd;">
<div style="width: 100%; height: 50px; background-color: unset;">
</div>
<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;">
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
<img src="__LOGO_URL__" style="height: 75px; max-width: 400px; border-radius: 4px;">
</div>
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
Hello
__(Hello)__
</div>
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
<h1>__LAST_NEWS__</h1>
<h2>__CONTENTOFMAILHOLDER__ </h2>
<h1>__(LastNews)__</h1>
<!-- <h2>__CONTENTOFMAILHOLDER__ </h2> -->
<!-- NEWS_START -->
__NEWS_LIST__
@ -30,15 +30,15 @@ body {
</div>
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
Social networks...
__MYCOMPANY_SOCIAL_NETWORKS__
<hr>
Unsubscribe
<hr>
Company address
__MYCOMPANY_ADDRESS__<br>
__MYCOMPANY_EMAIL__
</div>
</div>
<div style="width: 100%; height: 100px; background-color: unset;">
__CHECK_READ__
</div>
</div>

View file

@ -7,38 +7,38 @@ body {
</style>
<div style="background-color: #e2f3fd; padding: 0; margin-top:-10px; margin-bottom:-20px; margin-left:-10px; margin-right:-10px; width:calc(100% + 20px)">
<div style="width: 600px; margin: 0 auto; background-color: #e2f3fd;">
<div style="width: 680px; margin: 0 auto; background-color: #e2f3fd;">
<div style="width: 100%; height: 50px; background-color: unset;">
</div>
<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;">
<img src="__LOGO_URL__" style="height: 150px; max-width: 400px; border-radius: 4px;">
<div style="border-top-left-radius: 20px; border-top-right-radius: 20px; width: calc(100% - 60px); background-color: white; padding: 30px; text-align: center;">
<img src="__LOGO_URL__" style="height: 75px; max-width: 400px; border-radius: 4px;">
</div>
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
Hello
<div style="width: calc(100% - 60px); background-color: #263c5a; color: #fff; padding: 30px;">
__(Hello)__
</div>
<div style="width: calc(100% - 60px); background-color: #fff; padding: 30px;">
<h1>__LAST_NEWS__</h1>
<h2>__CONTENTOFMAILHOLDER__ </h2>
<h1>__(OurProductSelection)__</h1>
<!-- <h2>__CONTENTOFMAILHOLDER__ </h2>-->
<!-- PRODUCTS_START -->
__PRODUCTS_LIST__
<!-- PRODUCTS_END -->
</div>
<div style="width: calc(100% - 60px); background-color: #e2f3fd; padding: 30px;">
Social networks...
<div style="width: calc(100% - 60px); background-color: #263c5a; color: #fff; padding: 30px;">
__MYCOMPANY_SOCIAL_NETWORKS__
<hr>
Unsubscribe
<hr>
Company address
__MYCOMPANY_ADDRESS__<br>
__MYCOMPANY_EMAIL__
</div>
</div>
<div style="width: 100%; height: 100px; background-color: unset;">
__CHECK_READ__
</div>
</div>