Better error management
This commit is contained in:
parent
81ff145fc9
commit
e6c5f40de3
@ -510,6 +510,7 @@ class Product extends CommonObject
|
|||||||
function delete($id)
|
function delete($id)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
$error=0;
|
||||||
|
|
||||||
if ($user->rights->produit->supprimer)
|
if ($user->rights->produit->supprimer)
|
||||||
{
|
{
|
||||||
@ -531,27 +532,35 @@ class Product extends CommonObject
|
|||||||
$sqld = "DELETE from ".MAIN_DB_PREFIX."categorie_product";
|
$sqld = "DELETE from ".MAIN_DB_PREFIX."categorie_product";
|
||||||
$sqld.= " WHERE fk_product = ".$id;
|
$sqld.= " WHERE fk_product = ".$id;
|
||||||
$resultd = $this->db->query($sqld);
|
$resultd = $this->db->query($sqld);
|
||||||
|
|
||||||
$sqlz = "DELETE from ".MAIN_DB_PREFIX."product";
|
$sqlz = "DELETE from ".MAIN_DB_PREFIX."product";
|
||||||
$sqlz.= " WHERE rowid = ".$id;
|
$sqlz.= " WHERE rowid = ".$id;
|
||||||
$resultz = $this->db->query($sqlz);
|
$resultz = $this->db->query($sqlz);
|
||||||
|
|
||||||
if ( !$resultz ){
|
if ( !$resultz )
|
||||||
dol_syslog('Product::delete error sqlz='.$sqlz, LOG_INFO);
|
{
|
||||||
}
|
dol_syslog('Product::delete error sqlz='.$sqlz, LOG_ERR);
|
||||||
|
}
|
||||||
// Appel des triggers
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
// Appel des triggers
|
||||||
$interface=new Interfaces($this->db);
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$result=$interface->run_triggers('PRODUCT_DELETE',$this,$user,$langs,$conf);
|
$interface=new Interfaces($this->db);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
$result=$interface->run_triggers('PRODUCT_DELETE',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
return 0;
|
|
||||||
|
if ($error)
|
||||||
|
{
|
||||||
|
return -$error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error .= "Impossible de supprimer le produit.\n";
|
$this->error .= "FailedToDeleteProduct. Already used.\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user