Merge pull request #19077 from polkiko/email_contentlines

FIX Content line substitution in email
This commit is contained in:
Laurent Destailleur 2021-10-22 15:37:45 +02:00 committed by GitHub
commit d54423990d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 31 deletions

View File

@ -894,7 +894,7 @@ if ($resql) {
$valuetoshow = $langs->trans("Content"); $showfield = 0;
}
if ($fieldlist[$field] == 'content_lines') {
$valuetoshow = $langs->trans("ContentLines"); $showfield = 0;
$valuetoshow = $langs->trans("ContentForLines"); $showfield = 0;
}
// Show fields
@ -973,6 +973,14 @@ if ($resql) {
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
print $doleditor->Create(1);
}
if ($tmpfieldlist == 'content_lines') {
print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
$okforextended = false;
$doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
print $doleditor->Create(1);
}
print '</td>';
print '<td></td>';
print '<td></td>';
@ -1114,35 +1122,6 @@ if ($resql) {
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
}
print '</td>';
/*
$fieldsforcontent = array('content');
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
$fieldsforcontent = array('content', 'content_lines');
}
foreach ($fieldsforcontent as $tmpfieldlist)
{
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$tmpfieldlist};
$class = 'tddict';
// Show value for field
if ($showfield) {
print '</tr><tr class="oddeven" nohover tr-'.$tmpfieldlist.'-'.$i.' "><td colspan="5">'; // To create an artificial CR for the current tr we are on
$okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
$okforextended = false;
$doleditor = new DolEditor($tmpfieldlist.'-'.$i, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%', 1);
print $doleditor->Create(1);
print '</td>';
print '<td></td><td></td><td></td>';
}
}*/
print "</tr>\n";
}

View File

@ -1526,7 +1526,7 @@ class FormMail extends Form
$product = new Product($this->db);
$product->fetch($line->fk_product, '', '', 1);
$product->fetch_optionals();
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
if (is_array($extrafields->attributes[$product->table_element]['label']) && count($extrafields->attributes[$product->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key];
}

View File

@ -210,6 +210,9 @@ if ($action == 'presend') {
}
// Make substitution in email content
if ($object) {
$formmail->setSubstitFromObject($object, $langs);
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.urlencode($object->thirdparty->tag).'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; // deprecated

View File

@ -279,6 +279,7 @@ SpaceX=Space X
SpaceY=Space Y
FontSize=Font size
Content=Content
ContentForLines=Content to display for each product or service (from variable __LINES__ of Content)
NoticePeriod=Notice period
NewByMonth=New by month
Emails=Emails

View File

@ -280,6 +280,7 @@ SpaceX=Área X
SpaceY=Área Y
FontSize=Tamaño de fuente
Content=Contenido
ContentForLines=Contenido a mostrar por cada línea de producto o servicio (de la variable __LINES__ definida en Contenido)
NoticePeriod=Plazo de aviso
NewByMonth=Nuevo por mes
Emails=E-Mails