Skip to content

Commit

Permalink
[ Task #1495 ] Add trigger LINECONTRACT_CREATE
Browse files Browse the repository at this point in the history
  • Loading branch information
KreizIT committed Jul 11, 2014
1 parent ff19a87 commit 9c2aaf7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Expand Up @@ -47,7 +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_MODIFY.
- 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:
Expand Down
48 changes: 29 additions & 19 deletions htdocs/contrat/class/contrat.class.php
Expand Up @@ -824,6 +824,11 @@ function delete($user)
$error=0;

$this->db->begin();

// Call trigger
$result=$this->call_trigger('CONTRACT_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers

if (! $error)
{
Expand Down Expand Up @@ -909,14 +914,6 @@ function delete($user)
}
}

if (! $error)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}

if (! $error)
{
// We remove directory
Expand Down Expand Up @@ -1078,6 +1075,15 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr
$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;
}
Expand Down Expand Up @@ -1222,6 +1228,15 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
$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;
}
Expand Down Expand Up @@ -1257,6 +1272,11 @@ function deleteline($idline,$user)
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";
Expand All @@ -1271,11 +1291,6 @@ function deleteline($idline,$user)
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;
}
Expand Down Expand Up @@ -1734,13 +1749,8 @@ function initAsSpecimen()
/**
* 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;
Expand Down
8 changes: 8 additions & 0 deletions htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
Expand Up @@ -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);
Expand Down Expand Up @@ -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')
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/class/fournisseur.facture.class.php
Expand Up @@ -602,7 +602,7 @@ function update($user=0, $notrigger=0)
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_MODIFY',$user);
$result=$this->call_trigger('BILL_SUPPLIER_UPDATE',$user);
if ($result < 0) $error++;
// End call triggers
}
Expand Down

0 comments on commit 9c2aaf7

Please sign in to comment.