diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6ad1cdc6974..fb3a1ccf702 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -246,11 +246,14 @@ if ($reshook == 0) { } } +$permissiontoadd = 1; + //asort($elementList); $id = 25; + /* * Actions */ @@ -338,6 +341,7 @@ if (empty($reshook)) { } setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + $action = 'add'; } } @@ -411,6 +415,7 @@ if (empty($reshook)) { } else { dol_print_error($db); } + $action = 'add'; } } @@ -489,6 +494,7 @@ if (empty($reshook)) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); } else { setEventMessages($db->error(), null, 'errors'); + $action = 'edit'; } } } @@ -515,7 +521,7 @@ if (empty($reshook)) { if ($action == $acts[0]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -527,7 +533,7 @@ if (empty($reshook)) { if ($action == $acts[1]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -545,18 +551,38 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $help_url = ''; -$title = $langs->trans("EMailsSetup"); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $title = $langs->trans("EMailsSetup"); +} else { + $title = $langs->trans("EMailsTemplates"); +} llxHeader('', $title, $help_url); $linkback = ''; $titlepicto = 'title_setup'; -print load_fiche_titre($title, $linkback, $titlepicto); -$head = email_admin_prepare_head(); +$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add'; +$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); + + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre($title, '', $titlepicto); +} else { + print load_fiche_titre($title, $newcardbutton, $titlepicto); +} + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $head = email_admin_prepare_head(); + + print dol_get_fiche_head($head, 'templates', '', -1); + + if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre('', $newcardbutton, ''); + } +} -print dol_get_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { @@ -599,7 +625,7 @@ $sql .= $db->plimit($listlimit + 1, $offset); $fieldlist = explode(',', $tabfield[$id]); -if ($action == 'view') { +if ($action == 'add') { // Form to add a new line print '
'; -print dol_get_fiche_end(); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print dol_get_fiche_end(); +} + // End of page llxFooter();