FIX : [ bug #1502 ] DON_CREATE trigger does not intercept trigger action

- Add DON_CREATE in interface_90_all
- Add new trigger DON_UPDATE, DON_DELETE
This commit is contained in:
KreizIT 2014-07-03 16:04:12 +02:00
parent 07f2d9474e
commit 023e7ce8ce
3 changed files with 44 additions and 8 deletions

View File

@ -16,6 +16,7 @@ For users:
- Fix: [ bug #1474, #1475 ] Contract trigger problem - Fix: [ bug #1474, #1475 ] Contract trigger problem
- Fix: [ bug #1496 ] ACTION_DELETE trigger does not show trigger error - Fix: [ bug #1496 ] ACTION_DELETE trigger does not show trigger error
- Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action - Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action
- Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
For translators: For translators:
@ -23,6 +24,7 @@ For translators:
For developers: For developers:
- New: Add hook "searchAgendaFrom". - New: Add hook "searchAgendaFrom".
- New: Add trigger DON_UPDATE, DON_DELETE
***** ChangeLog for 3.6 compared to 3.5.* ***** ***** ChangeLog for 3.6 compared to 3.5.* *****

View File

@ -308,6 +308,8 @@ class Don extends CommonObject
$now=dol_now(); $now=dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."don (";
$sql.= "datec"; $sql.= "datec";
$sql.= ", entity"; $sql.= ", entity";
@ -360,19 +362,17 @@ class Don extends CommonObject
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don");
// Appel des triggers // Call trigger
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $result=$this->call_trigger('DON_CREATE',$user);
$interface=new Interfaces($this->db); if ($result < 0) { $error++; $this->db->rollback(); return -1; }
$result=$interface->run_triggers('DON_CREATE',$this,$user,$langs,$conf); // End call triggers
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
$this->db->commit();
return $this->id; return $this->id;
} }
else else
{ {
$this->db->rollback();
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
@ -393,6 +393,8 @@ class Don extends CommonObject
$this->country_id=($this->country_id>0?$this->country_id:$this->country_id); $this->country_id=($this->country_id>0?$this->country_id:$this->country_id);
$this->country=($this->country?$this->country:$this->country); $this->country=($this->country?$this->country:$this->country);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
$sql .= "amount = " . price2num($this->amount); $sql .= "amount = " . price2num($this->amount);
$sql .= ",fk_paiement = ".($this->modepaiementid?$this->modepaiementid:"null"); $sql .= ",fk_paiement = ".($this->modepaiementid?$this->modepaiementid:"null");
@ -418,10 +420,17 @@ class Don extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
// Call trigger
$result=$this->call_trigger('DON_UPDATE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
@ -436,6 +445,8 @@ class Don extends CommonObject
function delete($rowid) function delete($rowid)
{ {
$this->db-begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -443,10 +454,17 @@ class Don extends CommonObject
{ {
if ( $this->db->affected_rows($resql) ) if ( $this->db->affected_rows($resql) )
{ {
// Call trigger
$result=$this->call_trigger('DON_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
return -1; return -1;
} }
} }

View File

@ -504,6 +504,22 @@ class InterfaceDemo
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
//Donation
elseif ($action == 'DON_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'DON_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'DON_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Interventions // Interventions
elseif ($action == 'FICHINTER_CREATE') elseif ($action == 'FICHINTER_CREATE')
{ {