Fix [ bug #1778 ] Cancel button of edit ref. supplier contract card saves changes instead of cancelling

This commit is contained in:
Marcos García de La Fuente 2014-12-28 18:56:23 +01:00
parent de137dd012
commit 7670ae46a6

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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');