Fixed an error with the group counters of the tree view

This commit is contained in:
Alejandro Gallardo Escobar 2015-06-30 16:14:04 +02:00
parent 0b2bdfa72d
commit dde4e21e60
1 changed files with 12 additions and 9 deletions

View File

@ -982,7 +982,7 @@ class Tree {
$sql = $this->getSql($item_for_count);
if (empty($sql))
return array();
$data = db_process_sql($sql);
if (empty($data))
return array();
@ -1141,6 +1141,16 @@ class Tree {
if (defined("METACONSOLE") && !empty($server)) {
$processed_item['serverID'] = $server['id'];
}
// Get the counters of the group (special case)
if ($processed_item['type'] == 'group') {
$counters = $this->getCounters($item['id']);
if (!empty($counters)) {
foreach ($counters as $type => $value) {
$item[$type] = $value;
}
}
}
$counters = array();
if (isset($item['total_unknown_count']))
@ -1158,8 +1168,8 @@ class Tree {
if (isset($item['total_fired_count']))
$counters['alerts'] = $item['total_fired_count'];
// Get the children of the group (special case)
if ($processed_item['type'] == 'group') {
$children = $this->getGroupsChildren($items, $items_tmp, $item['id'], $server, $remove_empty);
if (!empty($children)) {
$processed_item['children'] = $children;
@ -1960,13 +1970,6 @@ class Tree {
foreach ($items as $key => $item) {
if (empty($item['parent'])) {
$counters = $this->getCounters($item['id']);
if (!empty($counters)) {
foreach ($counters as $type => $value) {
$item[$type] = $value;
}
}
unset($items[$key]);
$items_tmp = array();
$processed_item = $this->getProcessedItem($item, false, $items, $items_tmp, true);