Merge pull request #3784 from All-3kcis/develop-patch-11

NEW Add trigger "SUPPLIER_PRODUCT_BUYPRICE_DELETE"
This commit is contained in:
Laurent Destailleur 2015-11-02 11:23:49 +01:00
commit 72915aa16d
2 changed files with 29 additions and 12 deletions

View File

@ -121,26 +121,38 @@ class ProductFournisseur extends Product
*/ */
function remove_product_fournisseur_price($rowid) function remove_product_fournisseur_price($rowid)
{ {
global $conf; global $conf, $user;
$this->db->begin(); $this->db->begin();
// Call trigger
$result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
if (empty($error))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE rowid = ".$rowid; $sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if (!$resql)
{
$this->db->commit();
return 1;
}
else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$error++;
}
}
if (empty($error)){
$this->db->commit();
return 1;
}else{
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }

View File

@ -95,9 +95,14 @@ if (empty($reshook))
{ {
if ($rowid) if ($rowid)
{ {
$result=$object->remove_product_fournisseur_price($rowid);
$action = ''; $action = '';
$result=$product->remove_product_fournisseur_price($rowid);
if($result > 0){
setEventMessage($langs->trans("PriceRemoved")); setEventMessage($langs->trans("PriceRemoved"));
}else{
$error++;
setEventMessages($product->error, $product->errors, 'errors');
}
} }
} }