From 9d083ece0ebbab0b7529a648a65676dca0f942ec Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Fri, 4 Dec 2026 07:36:32 +0100 Subject: [PATCH] Fix: avoid SLA report crash, exclude trash from percentages (#418) --- CHANGELOG.md | 3 +++ inc/helpdeskplus.class.php | 12 +++++++++--- inc/inventory.class.php | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c202b7e..719714b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Inventory percentage reports failing with an SQL placeholder count error +- Fix the "Tickets per SLA ordered by categories" report failing when no ticket has an SLA +- Fix a deprecation warning in the "Computer per age" report +- Fix percentages of the "Computers per manufacturer" and "Computers per type" reports counting computers in the trash ## [1.11.1] - 2026-11-04 diff --git a/inc/helpdeskplus.class.php b/inc/helpdeskplus.class.php index 01109bf1..a264fa66 100644 --- a/inc/helpdeskplus.class.php +++ b/inc/helpdeskplus.class.php @@ -1046,6 +1046,15 @@ public function reportHgbarRespectedSlasByTopCategory($config = []) } } + $datas['labels2'] = [$this->lcl_slaok => $this->lcl_slaok, + $this->lcl_slako => $this->lcl_slako, + ]; + + // No ticket with an SLA: an empty IN would throw + if (!$category && $categories === []) { + return $datas; + } + $query = [ 'SELECT' => [ $this->criteria_select_sla, @@ -1083,9 +1092,6 @@ public function reportHgbarRespectedSlasByTopCategory($config = []) : $this->lcl_slako; $datas['datas'][$data['name']][$value] = $data['nb']; } - $datas['labels2'] = [$this->lcl_slaok => $this->lcl_slaok, - $this->lcl_slako => $this->lcl_slako, - ]; if (isset($datas['datas'])) { foreach ($datas['datas'] as &$data) { diff --git a/inc/inventory.class.php b/inc/inventory.class.php index 5a089582..8e366911 100644 --- a/inc/inventory.class.php +++ b/inc/inventory.class.php @@ -164,6 +164,7 @@ public function computersByFabricant($config = []) ], 'WHERE' => array_merge( [ + Computer::getTable() . '.is_deleted' => 0, Computer::getTable() . '.is_template' => 0, Computer::getTable() . '.entities_id' => PluginMreportingCommon::formatWhereEntitiesArray($this->where_entities), ], @@ -249,6 +250,7 @@ public function computersByType($config = []) ], 'WHERE' => array_merge( [ + Computer::getTable() . '.is_deleted' => 0, Computer::getTable() . '.is_template' => 0, Computer::getTable() . '.entities_id' => PluginMreportingCommon::formatWhereEntitiesArray($this->where_entities), ], @@ -393,7 +395,7 @@ public function computersByAge($config = []) } $query = new QueryUnion($queries); - $result = $DB->request($query); + $result = $DB->request(['FROM' => $query]); foreach ($result as $computer) { $percent = round(floatval($computer['Percent']), 2);