From 84d73086eac01aa328b01c04cee99a8db7d01b86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2018 22:53:56 +0100 Subject: [PATCH] Fix bookkeeping list was empty --- .../accountancy/class/bookkeeping.class.php | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6074a49f537..31a54aafc3b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -866,14 +866,13 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int <0 if KO, >0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit Offset limit + * @param int $offset Offset limit + * @param array $filter Filter array + * @param string $filtermode Filter mode (AND or OR) + * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -932,7 +931,7 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')'; + $sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } @@ -950,7 +949,8 @@ class BookKeeping extends CommonObject $num = $this->db->num_rows($resql); $i = 0; - while ($obj = $this->db->fetch_object($resql) && (empty($limit) || $i < min($limit, $num))) { + while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) + { $line = new BookKeepingLine(); $line->id = $obj->rowid; @@ -989,8 +989,7 @@ class BookKeeping extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - - return - 1; + return -1; } }