Skip to content

Commit

Permalink
Add triggers on Bookkeeping class (#31204)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-Ngr authored Oct 3, 2024
1 parent 5cb2e23 commit 88879e0
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions htdocs/accountancy/class/bookkeeping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,11 @@ public function create(User $user, $notrigger = 0)
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
}

// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
//if (! $error && ! $notrigger) {

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

// Commit or rollback
if ($error) {
Expand Down Expand Up @@ -716,6 +712,11 @@ public function createStd(User $user, $notrigger = 0, $mode = '')

if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element.$mode);
// Call triggers
if (! $notrigger) {
$result=$this->call_trigger('BOOKKEEPING_CREATE', $user);
if ($result < 0) $error++;
}
}

// Commit or rollback
Expand Down Expand Up @@ -1477,15 +1478,11 @@ public function update(User $user, $notrigger = 0, $mode = '')
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
}

// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//if (! $error && ! $notrigger) {

// // Call triggers
// $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
// if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
// // End call triggers
//}
// Call triggers
if (! $error && ! $notrigger) {
$result=$this->call_trigger('BOOKKEEPING_MODIFY', $user);
if ($result < 0) $error++;
}

// Commit or rollback
if ($error) {
Expand Down Expand Up @@ -1572,15 +1569,11 @@ public function delete(User $user, $notrigger = 0, $mode = '')

$this->db->begin();

// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//if (! $error && ! $notrigger) {

// // Call triggers
// $result=$this->call_trigger('MYOBJECT_DELETE',$user);
// if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
// // End call triggers
//}
// Call triggers
if (! $error && ! $notrigger) {
$result=$this->call_trigger('BOOKKEEPING_DELETE', $user);
if ($result < 0) $error++;
}

if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.$mode;
Expand Down

0 comments on commit 88879e0

Please sign in to comment.