From be3527abd1cf2ca90ed9bc612cb2e84d686f5593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= <marcosgdf@gmail.com> Date: Sun, 18 Jan 2015 03:23:00 +0100 Subject: [PATCH] Fixed some errors of Bookkeeping class --- .../accountancy/class/bookkeeping.class.php | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6291790d008..a3a760b0570 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -221,7 +221,7 @@ class BookKeeping * Insert line into bookkeeping * * @param User $user User who inserted operation - * @return $result Result + * @return int <0 KO >0 OK */ function create($user='') { @@ -276,8 +276,9 @@ class BookKeeping } $now = dol_now(); - if (empty($this->date_create)) - $this->date_create = $now(); + if (empty($this->date_create)) { + $this->date_create = $now; + } $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; @@ -330,23 +331,19 @@ class BookKeeping $sql .= " WHERE import_key = '" . $importkey . "'"; $resql = $this->db->query($sql); + if (! $resql) { - $error ++; $this->errors[] = "Error " . $this->db->lasterror(); - } - - // Commit or rollback - if ($error) { foreach ( $this->errors as $errmsg ) { dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; - } else { - $this->db->commit(); - return 1; + return - 1; } + + $this->db->commit(); + return 1; } /** @@ -595,16 +592,13 @@ class BookKeeping $this->db->begin(); - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } - } +// if (! $notrigger) +// { +// // Call trigger +// $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); +// if ($result < 0) $error++; +// // End call triggers +// } if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; -- GitLab