Add trigger into delete line for supplier invoice
This commit is contained in:
parent
d8eafbf068
commit
982b3e9d66
@ -1169,22 +1169,64 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
* Delete a detail line from database
|
* Delete a detail line from database
|
||||||
*
|
*
|
||||||
* @param int $rowid Id of line to delete
|
* @param int $rowid Id of line to delete
|
||||||
|
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function deleteline($rowid)
|
function deleteline($rowid, $notrigger=0)
|
||||||
|
{
|
||||||
|
global $user, $langs, $conf;
|
||||||
|
|
||||||
|
if (! $rowid) $rowid=$this->id;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
if (! $error && ! $notrigger)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('LINEBILL_SUPPLIER_DELETE',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++; $this->errors=$interface->errors;
|
||||||
|
}
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Supprime ligne
|
// Supprime ligne
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
||||||
$sql .= ' WHERE rowid = '.$rowid.';';
|
$sql.= ' WHERE rowid = '.$rowid;
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
dol_print_error($this->db);
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
// Mise a jour prix facture
|
// Mise a jour prix facture
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user