New: Add patch from Laurent Bouquet to support trigger events on line updates

This commit is contained in:
Laurent Destailleur 2009-07-01 23:05:51 +00:00
parent 9ce8d0d71c
commit b3c83490f8
3 changed files with 51 additions and 4 deletions

View File

@ -1718,6 +1718,8 @@ class Commande extends CommonObject
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0) function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0)
{ {
global $conf;
dol_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end, $type"); dol_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end, $type");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
@ -1784,6 +1786,13 @@ class Commande extends CommonObject
// Mise a jour info denormalisees // Mise a jour info denormalisees
$this->update_price(); $this->update_price();
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }

View File

@ -3045,7 +3045,9 @@ class FactureLigne
*/ */
function update() function update()
{ {
// Clean parameters global $conf;
// Clean parameters
$this->desc=trim($this->desc); $this->desc=trim($this->desc);
// Check parameters // Check parameters
@ -3082,6 +3084,15 @@ class FactureLigne
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -448,7 +448,20 @@ class Propal extends CommonObject
if ($result > 0) if ($result > 0)
{ {
$this->update_price(); $this->update_price();
$this->db->commit();
$this->fk_propal = $this->id;
$this->rowid = $rowid;
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit();
return $result; return $result;
} }
else else
@ -2168,6 +2181,8 @@ class PropaleLigne
*/ */
function insert() function insert()
{ {
global $conf;
dol_syslog("PropaleLigne::insert rang=".$this->rang); dol_syslog("PropaleLigne::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
@ -2232,6 +2247,18 @@ class PropaleLigne
if ($resql) if ($resql)
{ {
$this->rang=$rangmax; $this->rang=$rangmax;
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet');
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }