From ae3847dc38c27c40b6267fe6a430a63bb895656d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 00:48:51 +0100 Subject: [PATCH] FIX Manual deletion of a bookkeeping line Conflicts: htdocs/accountancy/class/bookkeeping.class.php --- .../accountancy/class/bookkeeping.class.php | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9075c241e3b..97387198fcd 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -758,11 +758,10 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * @param string $mode Mode - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @param string $mode Mode ('' or 'tmp_') + * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null, $mode = '') { @@ -1491,17 +1490,18 @@ class BookKeeping extends CommonObject /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @param string $mode Mode - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param string $mode Mode ('' or 'tmp_') + * @return int Return integer <0 if KO, >0 if OK */ - public function delete(User $user, $notrigger = false, $mode = '') + public function delete(User $user, $notrigger = 0, $mode = '') { global $langs; + dol_syslog(__METHOD__, LOG_DEBUG); - $result = $this->canModifyBookkeeping($this->id); + $result = $this->canModifyBookkeeping($this->id, $mode); if ($result < 0) { return -1; } elseif ($result == 0) { @@ -2303,9 +2303,10 @@ class BookKeeping extends CommonObject * Is the bookkeeping can be modified or deleted ? * * @param int $id Bookkeeping ID + * @param string $mode Mode ('' or 'tmp_') * @return int Return integer <0 if KO, == 0 if No, == 1 if Yes */ - public function canModifyBookkeeping($id) + public function canModifyBookkeeping($id, $mode = '') { global $conf; @@ -2317,7 +2318,7 @@ class BookKeeping extends CommonObject } $bookkeeping = new BookKeeping($this->db); - $result = $bookkeeping->fetch($id); + $result = $bookkeeping->fetch($id, null, $mode); if ($result <= 0) { return $result; } @@ -2338,7 +2339,7 @@ class BookKeeping extends CommonObject } $bookkeeping = new BookKeeping($this->db); - $result = $bookkeeping->fetch($id); + $result = $bookkeeping->fetch($id, null, $mode); if ($result <= 0) { return $result; }