Skip to content
Snippets Groups Projects
Commit 023e7ce8 authored by Cédric Gross's avatar Cédric Gross
Browse files

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
parent 07f2d947
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ For users:
- Fix: [ bug #1474, #1475 ] Contract trigger problem
- 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 #1502 ] DON_CREATE trigger does not intercept trigger action
For translators:
......@@ -23,6 +24,7 @@ For translators:
For developers:
- New: Add hook "searchAgendaFrom".
- New: Add trigger DON_UPDATE, DON_DELETE
***** ChangeLog for 3.6 compared to 3.5.* *****
......
......@@ -307,6 +307,8 @@ class Don extends CommonObject
$this->country=($this->country?$this->country:$this->country);
$now=dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (";
$sql.= "datec";
......@@ -360,19 +362,17 @@ class Don extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don");
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('DON_CREATE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
// Call trigger
$result=$this->call_trigger('DON_CREATE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
dol_print_error($this->db);
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=($this->country?$this->country:$this->country);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
$sql .= "amount = " . price2num($this->amount);
$sql .= ",fk_paiement = ".($this->modepaiementid?$this->modepaiementid:"null");
......@@ -418,10 +420,17 @@ class Don extends CommonObject
$result = $this->db->query($sql);
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;
}
else
{
$this->db->rollback();
dol_print_error($this->db);
return -1;
}
......@@ -435,6 +444,8 @@ class Don extends CommonObject
*/
function delete($rowid)
{
$this->db-begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
......@@ -443,10 +454,17 @@ class Don extends CommonObject
{
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;
}
else
{
$this->db->rollback();
return -1;
}
}
......
......@@ -503,6 +503,22 @@ class InterfaceDemo
{
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
elseif ($action == 'FICHINTER_CREATE')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment