Merge pull request #1736 from KreizIT/TriggerTask

Trigger task
This commit is contained in:
Juanjo Menent 2014-07-12 08:14:38 +02:00
commit 6fcc33e6d0
4 changed files with 42 additions and 24 deletions

View File

@ -47,6 +47,8 @@ For developers:
- New: Add trigger DON_UPDATE, DON_DELETE
- New: Add country iso code on 3 chars into table of countries.
- Qual: Removed hard coded rowid into data init of table llx_c_action_trigger.
- New: [ Task #1481 ] Add trigger BILL_SUPPLIER_UPDATE.
- New: [ Task #1495 ] Add trigger LINECONTRACT_CREATE.
WARNING: Following change may create regression for some external modules, but was necessary to make
Dolibarr better:

View File

@ -824,6 +824,11 @@ class Contrat extends CommonObject
$error=0;
$this->db->begin();
// Call trigger
$result=$this->call_trigger('CONTRACT_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
if (! $error)
{
@ -909,14 +914,6 @@ class Contrat extends CommonObject
}
}
if (! $error)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
// We remove directory
@ -1078,6 +1075,15 @@ class Contrat extends CommonObject
$result=$this->update_statut($user);
if ($result > 0)
{
// Call trigger
$result=$this->call_trigger('LINECONTRACT_CREATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// End call triggers
$this->db->commit();
return 1;
}
@ -1222,6 +1228,15 @@ class Contrat extends CommonObject
$result=$this->update_statut($user);
if ($result >= 0)
{
// Call trigger
$result=$this->call_trigger('LINECONTRACT_UPDATE',$user);
if ($result < 0)
{
$this->db->rollback();
return -3;
}
// End call triggers
$this->db->commit();
return 1;
}
@ -1257,6 +1272,11 @@ class Contrat extends CommonObject
if ($this->statut >= 0)
{
// Call trigger
$result=$this->call_trigger('LINECONTRACT_DELETE',$user);
if ($result < 0) return -1;
// End call triggers
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
@ -1271,11 +1291,6 @@ class Contrat extends CommonObject
return -1;
}
// Call trigger
$result=$this->call_trigger('LINECONTRACT_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return 1;
}
@ -1734,13 +1749,8 @@ class Contrat extends CommonObject
/**
* Classe permettant la gestion des lignes de contrats
*/
class ContratLigne
class ContratLigne extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
//var $element='contratdet'; //!< Id that identify managed objects
//var $table_element='contratdet'; //!< Name of table without prefix where object is stored
var $id;
var $ref;

View File

@ -417,6 +417,10 @@ class InterfaceDemo
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINECONTRACT_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINECONTRACT_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -484,6 +488,10 @@ class InterfaceDemo
elseif ($action == 'BILL_SUPPLIER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_DELETE')
{

View File

@ -601,11 +601,9 @@ class FactureFournisseur extends CommonInvoice
{
if (! $notrigger)
{
// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('BILL_SUPPLIER_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_UPDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
}