From c60e7a4e6077c0e2c7055206c811af797b939193 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 27 Feb 2020 09:02:59 +0100 Subject: [PATCH] Fix count errror on category view of stocks --- htdocs/categories/index.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index c71be0cd91993..abb0962b1d565 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -182,23 +182,17 @@ $li = $categstatic->getNomUrl(1, '', 60); $desc = dol_htmlcleanlastbr($val['description']); + $counter = ""; + if($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database - if ($type == Categorie::TYPE_PRODUCT) $elements = $categstatic->getObjectsInCateg("product", 1); - if ($type == Categorie::TYPE_SUPPLIER) $elements = $categstatic->getObjectsInCateg("supplier", 1); - if ($type == Categorie::TYPE_CUSTOMER) $elements = $categstatic->getObjectsInCateg("customer", 1); - if ($type == Categorie::TYPE_MEMBER) $elements = $categstatic->getObjectsInCateg("member", 1); - if ($type == Categorie::TYPE_CONTACT) $elements = $categstatic->getObjectsInCateg("contact", 1); - if ($type == Categorie::TYPE_ACCOUNT) $elements = $categstatic->getObjectsInCateg("account", 1); - if ($type == Categorie::TYPE_PROJECT) $elements = $categstatic->getObjectsInCateg("project", 1); - if ($type == Categorie::TYPE_USER) $elements = $categstatic->getObjectsInCateg("user", 1); - - $counter = "".count($elements).""; - } - else - { - $counter = ""; + + $elements = $type == Categorie::TYPE_ACCOUNT + ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" + : $categstatic->getObjectsInCateg($type, 1); + + $counter = "".(is_countable($elements) ? count($elements) : "0").""; } $data[] = array(