Normalize code

This commit is contained in:
Laurent Destailleur 2016-09-28 18:14:44 +02:00
parent 142a2e34db
commit c3f5962058
3 changed files with 13 additions and 11 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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);