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)
{
global $conf;
global $conf, $user;
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE rowid = ".$rowid;
// Call trigger
$result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
if (empty($error))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error=$this->db->lasterror();
$error++;
}
}
if (empty($error)){
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
}else{
$this->db->rollback();
return -1;
}
}

View File

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