Refactor: TVA_* trigger
This commit is contained in:
parent
a7afb5bdae
commit
971ae8ae59
@ -121,13 +121,12 @@ class Tva extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
|
||||||
|
|
||||||
// Start triggers
|
// Call trigger
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
$result=$this->call_trigger('TVA_CREATE',$user);
|
||||||
$interface=new Interfaces($this->db);
|
if ($result < 0) $error++;
|
||||||
$result=$interface->run_triggers('TVA_CREATE',$this,$user,$langs,$conf);
|
// End call triggers
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// End triggers
|
|
||||||
|
|
||||||
|
//FIXME: Add rollback if trigger fail
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -187,12 +186,12 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Start triggers
|
// Call trigger
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
$result=$this->call_trigger('TVA_MODIFY',$user);
|
||||||
$interface=new Interfaces($this->db);
|
if ($result < 0) $error++;
|
||||||
$result=$interface->run_triggers('TVA_MODIFY',$this,$user,$langs,$conf);
|
// End call triggers
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// End triggers
|
//FIXME: Add rollback if trigger fail
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -280,6 +279,11 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
// Call trigger
|
||||||
|
$result=$this->call_trigger('TVA_DELETE',$user);
|
||||||
|
if ($result < 0) return -1;
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
@ -291,12 +295,6 @@ class Tva extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start triggers
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$result=$interface->run_triggers('TVA_DELETE',$this,$user,$langs,$conf);
|
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// End triggers
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -541,12 +539,15 @@ class Tva extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called paiementtva
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called paiementtva
|
||||||
|
|
||||||
// Start triggers
|
// Call trigger
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
//XXX: Should be done just befor commit no ?
|
||||||
$interface=new Interfaces($this->db);
|
$result=$this->call_trigger('TVA_ADDPAYMENT',$user);
|
||||||
$result=$interface->run_triggers('TVA_ADDPAYMENT',$this,$user,$langs,$conf);
|
if ($result < 0)
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
{
|
||||||
// End triggers
|
$this->id = 0;
|
||||||
|
$ok = 0;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
if ($this->id > 0)
|
if ($this->id > 0)
|
||||||
{
|
{
|
||||||
@ -595,7 +596,6 @@ class Tva extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user