From 581efd084773c724d9c8f1f1f523ea9229104f2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Aug 2021 19:40:04 +0200 Subject: [PATCH] Fix the cancel action (good practices recommended by modulebuilder). --- htdocs/societe/card.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index f5cd9cc8de7..8e8ab5c2d1f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -154,12 +154,27 @@ if ($reshook < 0) { } if (empty($reshook)) { + $backurlforlist = DOL_URL_ROOT.'/societe/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.'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); + } + } + } + if ($cancel) { - $action = ''; - if (!empty($backtopage)) { + if (!empty($backtopageforcancel)) { + header("Location: ".$backtopageforcancel); + exit; + } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } + $action = ''; } if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) {