2
0
forked from Wavyzz/dolibarr

Fix edit of template with back to page

This commit is contained in:
ldestailleur
2025-03-18 17:41:37 +01:00
parent 1698ac0958
commit 302ab362d5
2 changed files with 16 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ $massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$mode = GETPOST('mode', 'aZ09');
$optioncss = GETPOST('optioncss', 'alpha');
$backtopage = GETPOST('backtopage');
$contextpage = GETPOST('contextpage', 'aZ09');
$id = $rowid = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid'));
@@ -287,15 +288,21 @@ if ($rowid > 0) {
* Actions
*/
if (GETPOST('cancel', 'alpha')) {
if (GETPOST('cancel', 'alpha') || GETPOST('actioncancel', 'alpha')) {
$action = 'list';
$massaction = '';
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit(1);
}
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$object = null;
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -439,6 +446,11 @@ if (empty($reshook)) {
if ($result) { // Add is ok
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id' => 25); // Clean $_POST array, we keep only id
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit(1);
}
} else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
@@ -740,6 +752,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';

View File

@@ -1901,6 +1901,8 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu
//var_dump($arraydefaultmessage);
//var_dump($arrayofmessagename);
print $form->selectarray('constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')), $arrayofmessagename, $obj->value.':'.$tmp[1], 'None', 0, 0, '', 0, 0, 0, '', '', 1);
print '<a href="'.DOL_URL_ROOT.'/admin/mails_templates.php?action=create&type_template='.urlencode($tmp[1]).'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('', 'add').'</a>';
} elseif (preg_match('/MAIL_FROM$/i', $const)) {
print img_picto('', 'email', 'class="pictofixedwidth"').'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')).'" value="'.dol_escape_htmltag($obj->value).'">';
} else { // type = 'string' ou 'chaine'