Skip to content

Commit

Permalink
Refactor: various trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
KreizIT committed Jul 11, 2014
1 parent 5093fec commit 5e7c063
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 36 deletions.
10 changes: 4 additions & 6 deletions htdocs/fourn/class/paiementfourn.class.php
Expand Up @@ -201,12 +201,10 @@ function create($user,$closepaidinvoices=0)

if (! $error)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// Call trigger
$result=$this->call_trigger('PAYMENT_SUPPLIER_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
}
}
else
Expand Down
9 changes: 3 additions & 6 deletions htdocs/fourn/commande/dispatch.php
Expand Up @@ -120,12 +120,9 @@
if (! $notrigger)
{
global $conf, $langs, $user;
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result_trigger=$interface->run_triggers('ORDER_SUPPLIER_DISPATCH',$commande,$user,$langs,$conf);
if ($result_trigger < 0) { $error++; $commande->errors=$interface->errors; }
// Fin appel triggers
// Call trigger
$result=$commande->call_trigger('ORDER_SUPPLIER_DISPATCH',$user);
// End call triggers
}

if ($result > 0)
Expand Down
10 changes: 4 additions & 6 deletions htdocs/imports/class/import.class.php
Expand Up @@ -313,12 +313,10 @@ function delete($user, $notrigger=0)
{
if (! $notrigger)
{
// Call triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('IMPORT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
// Call trigger
$result=$this->call_trigger('IMPORT_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
}

Expand Down
20 changes: 8 additions & 12 deletions htdocs/opensurvey/class/opensurveysondage.class.php
Expand Up @@ -142,12 +142,10 @@ function create($user, $notrigger=0)
{
global $langs, $conf;

//// Call triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('OPENSURVEY_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
// Call trigger
$result=$this->call_trigger('OPENSURVEY_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
}
}

Expand Down Expand Up @@ -338,12 +336,10 @@ function delete($user, $notrigger, $numsondage)
{
if (! $notrigger)
{
//// Call triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('OPENSURVEY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
// Call trigger
$result=$this->call_trigger('OPENSURVEY_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
}

Expand Down
12 changes: 6 additions & 6 deletions htdocs/product/stock/class/mouvementstock.class.php
Expand Up @@ -245,17 +245,17 @@ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label

if ($movestock && ! $error)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);

$this->product_id = $fk_product;
$this->entrepot_id = $entrepot_id;
$this->qty = $qty;

$result=$interface->run_triggers('STOCK_MOVEMENT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// Call trigger
$result=$this->call_trigger('STOCK_MOVEMENT',$user);
if ($result < 0) $error++;
// End call triggers

//FIXME: Restore previous value of product_id, entrepot_id, qty if trigger fail
}

if (! $error)
Expand Down

0 comments on commit 5e7c063

Please sign in to comment.