From c967c5c6d4bf95575eb3ea9c3e746bb74d53b14f Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Tue, 14 Sep 2021 08:46:07 +0200 Subject: [PATCH] fix cancel redirects on product,warehouse cards --- htdocs/product/card.php | 2 +- htdocs/product/stock/card.php | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b4625d5602d..23fc0077c97 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -201,7 +201,7 @@ if ($reshook < 0) { } if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/product/list.php'; + $backurlforlist = DOL_URL_ROOT.'/product/list.php?type='.$type; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 2ffaf43ea90..fc394d6203a 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -104,6 +104,29 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { + $backurlforlist = DOL_URL_ROOT.'/product/stock/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/product/stock/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + + if ($cancel) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = ''; + } + // Ajout entrepot if ($action == 'add' && $user->rights->stock->creer) { $object->ref = (string) GETPOST("ref", "alpha");