Merge pull request #14931 from cfoellmann/optimize-mail-templates-screen

optimize mail templates edit screen
This commit is contained in:
Laurent Destailleur 2020-10-05 16:31:42 +02:00 committed by GitHub
commit 120d2cf89f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -458,18 +458,19 @@ $sql .= $db->plimit($listlimit + 1, $offset);
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Form to add a new line if ($action == 'view') {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; // Form to add a new line
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Line to enter new values (title) // Line to enter new values (title)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
@ -500,53 +501,53 @@ foreach ($fieldlist as $field => $value)
} else print $valuetoshow; } else print $valuetoshow;
print '</td>'; print '</td>';
} }
} }
print '<td>'; print '<td>';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$obj = new stdClass(); $obj = new stdClass();
// If data was already input, we define them in obj to populate input fields. // If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd')) if (GETPOST('actionadd'))
{ {
foreach ($fieldlist as $key => $val) { foreach ($fieldlist as $key => $val) {
if (GETPOST($val) != '') if (GETPOST($val) != '')
$obj->$val = GETPOST($val); $obj->$val = GETPOST($val);
} }
} }
$tmpaction = 'create'; $tmpaction = 'create';
$parameters = array( $parameters = array(
'fieldlist' => $fieldlist, 'fieldlist' => $fieldlist,
'tabname' => $tabname[$id] 'tabname' => $tabname[$id]
); );
$reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $error = $hookmanager->error;
$errors = $hookmanager->errors; $errors = $hookmanager->errors;
// Line to enter new values (input fields) // Line to enter new values (input fields)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (empty($reshook)) if (empty($reshook))
{ {
if ($action == 'edit') { if ($action == 'edit') {
fieldList($fieldlist, $obj, $tabname[$id], 'hide'); fieldList($fieldlist, $obj, $tabname[$id], 'hide');
} else { } else {
fieldList($fieldlist, $obj, $tabname[$id], 'add'); fieldList($fieldlist, $obj, $tabname[$id], 'add');
} }
} }
print '<td class="right">'; print '<td class="right">';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
// Show fields for topic, join files and body // Show fields for topic, join files and body
$fieldsforcontent = array('topic', 'joinfiles', 'content'); $fieldsforcontent = array('topic', 'joinfiles', 'content');
if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); }
foreach ($fieldsforcontent as $tmpfieldlist) foreach ($fieldsforcontent as $tmpfieldlist)
{ {
print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">'; print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
// Label // Label
@ -574,7 +575,7 @@ foreach ($fieldsforcontent as $tmpfieldlist)
$okforextended = true; $okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) if (empty($conf->global->FCKEDITOR_ENABLE_MAIL))
$okforextended = false; $okforextended = false;
$doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 120, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
} else print '&nbsp;'; } else print '&nbsp;';
} }
@ -588,18 +589,18 @@ foreach ($fieldsforcontent as $tmpfieldlist)
} }
// else print '<td></td>'; // else print '<td></td>';
print '</tr>'; print '</tr>';
} }
$colspan = count($fieldlist) + 1; $colspan = count($fieldlist) + 1;
//print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height //print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
print '</table>';
print '</div>';
print '</form>';
print '<br>';
print '</table>';
print '</div>';
print '</form>';
print '<br>';
} // END IF not edit
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -644,7 +645,7 @@ if ($resql)
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
if ($value == 'label') { if ($value == 'label') {
print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth200" value="'.dol_escape_htmltag($search_label).'"></td>';
} elseif ($value == 'lang') { } elseif ($value == 'lang') {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
@ -780,7 +781,7 @@ if ($resql)
print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>'; print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
$okforextended = true; $okforextended = true;
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; 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%'); $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
} }
print '</td>'; print '</td>';
@ -1032,7 +1033,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
else { else {
$size = ''; $class = ''; $classtd = ''; $size = ''; $class = ''; $classtd = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
if ($fieldlist[$field] == 'label') $class = 'maxwidth100'; if ($fieldlist[$field] == 'label') $class = 'maxwidth200';
if ($fieldlist[$field] == 'private') { $class = 'maxwidth50'; $classtd = 'center'; } if ($fieldlist[$field] == 'private') { $class = 'maxwidth50'; $classtd = 'center'; }
if ($fieldlist[$field] == 'position') { $class = 'maxwidth50'; $classtd = 'center'; } if ($fieldlist[$field] == 'position') { $class = 'maxwidth50'; $classtd = 'center'; }
if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent'; if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent';