From 7670ae46a6437186041168804ca37703388e4604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 28 Dec 2014 18:56:23 +0100 Subject: [PATCH] Fix [ bug #1778 ] Cancel button of edit ref. supplier contract card saves changes instead of cancelling --- htdocs/contrat/card.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 14a43e59f12..f27d47f2dd5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014 Marcos GarcĂ­a * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -718,19 +719,25 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra setEventMessage($object->error,'errors'); } } elseif ($action=='setref_supplier') { - $result = $object->fetch($id); - if ($result < 0) { - setEventMessage($object->errors,'errors'); - } - $object->ref_supplier=GETPOST('ref_supplier','alpha'); - $result = $object->update($user); - if ($result < 0) { - setEventMessage($object->errors,'errors'); - $action='editref_supplier'; - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; + $cancelbutton = GETPOST('cancel'); + + if (!$cancelbutton) { + + $result = $object->fetch($id); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + } + $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); + + $result = $object->update($user); + if ($result < 0) { + setEventMessage($object->errors, 'errors'); + $action = 'editref_supplier'; + } else { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } } } elseif ($action=='setref') { $object->ref=GETPOST('ref','alpha');