From c3f596205815d0db0c35a0364ca9a095b6e64f79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 28 Sep 2016 18:14:44 +0200 Subject: [PATCH] Normalize code --- htdocs/product/stock/card.php | 1 + htdocs/product/stock/class/entrepot.class.php | 21 ++++++++++--------- test/phpunit/EntrepotTest.php | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 4edcbd8728d..60f7938de06 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -111,6 +111,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su $result=$object->delete($user); if ($result > 0) { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); exit; } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 30165a4f732..aee38a67ccf 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -214,20 +214,21 @@ class Entrepot extends CommonObject /** * Delete a warehouse * - * @param User $user Object user that made deletion - * @return int <0 if KO, >0 if OK + * @param User $user Object user that made deletion + * @param int $notrigger 1=No trigger + * @return int <0 if KO, >0 if OK */ - function delete($user) + function delete($user, $notrigger=0) { $this->db->begin(); - if (! $error && empty($notrigger)) - { - // Call trigger - $result=$this->call_trigger('WAREHOUSE_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers - } + if (! $error && empty($notrigger)) + { + // Call trigger + $result=$this->call_trigger('WAREHOUSE_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } $elements = array('stock_mouvement','product_stock','product_warehouse_properties'); foreach($elements as $table) diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index d3d7c300308..e695bff34a3 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -233,7 +233,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase $localobject=new Entrepot($this->savdb); $result=$localobject->fetch($id); - $result=$localobject->delete($id); + $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); -- GitLab