Skip to content

Commit

Permalink
FIX : [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
Browse files Browse the repository at this point in the history
- Add DON_CREATE in interface_90_all
- Add new trigger DON_UPDATE, DON_DELETE
  • Loading branch information
KreizIT committed Jul 3, 2014
1 parent 07f2d94 commit 023e7ce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -16,13 +16,15 @@ 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:
- Update language files.

For developers:
- New: Add hook "searchAgendaFrom".
- New: Add trigger DON_UPDATE, DON_DELETE


***** ChangeLog for 3.6 compared to 3.5.* *****
Expand Down
34 changes: 26 additions & 8 deletions htdocs/compta/dons/class/don.class.php
Expand Up @@ -307,6 +307,8 @@ function create($user)
$this->country=($this->country?$this->country:$this->country);

$now=dol_now();

$this->db->begin();

$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (";
$sql.= "datec";
Expand Down Expand Up @@ -360,19 +362,17 @@ function create($user)
{
$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;
}
Expand All @@ -393,6 +393,8 @@ function update($user)
$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");
Expand All @@ -418,10 +420,17 @@ function update($user)
$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;
}
Expand All @@ -435,6 +444,8 @@ function update($user)
*/
function delete($rowid)
{

$this->db-begin();

$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";

Expand All @@ -443,10 +454,17 @@ function delete($rowid)
{
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;
}
}
Expand Down
16 changes: 16 additions & 0 deletions htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
Expand Up @@ -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')
Expand Down

0 comments on commit 023e7ce

Please sign in to comment.