<?php declare(strict_types = 0);
$table = new CTableInfo();
if ($data['error'] !== null) {
$table->setNoDataMessage($data['error']);
}
else {
$sort_div = (new CSpan())->addClass(ZBX_STYLE_ARROW_UP);
$table
->setHeader([
[_x('Host group', 'compact table header'), $sort_div],
_x('Without problems', 'compact table header'),
_x('With problems', 'compact table header'),
_x('Total', 'compact table header')
])
->setHeadingColumn(0);
$url_group = $data['allowed_ui_problems']
? (new CUrl('zabbix.php'))
->setArgument('action', 'problem.view')
->setArgument('filter_set', '1')
->setArgument('show', TRIGGERS_OPTION_RECENT_PROBLEM)
->setArgument('hostids', $data['filter']['hostids'])
->setArgument('name', $data['filter']['problem'])
->setArgument('show_suppressed', ($data['filter']['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE)
? ZBX_PROBLEM_SUPPRESSED_TRUE
: null
)
: null;
$url_host = $data['allowed_ui_problems']
? (new CUrl('zabbix.php'))
->setArgument('action', 'problem.view')
->setArgument('filter_set', '1')
->setArgument('show', TRIGGERS_OPTION_RECENT_PROBLEM)
->setArgument('name', $data['filter']['problem'])
->setArgument('show_suppressed', ($data['filter']['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE)
? ZBX_PROBLEM_SUPPRESSED_TRUE
: null
)
: null;
foreach ($data['groups'] as $group) {
$problematic_count_key = ($data['filter']['ext_ack'] == EXTACK_OPTION_UNACK)
? 'hosts_problematic_unack_count'
: 'hosts_problematic_count';
if ($data['filter']['hide_empty_groups'] && $group[$problematic_count_key] == 0) {
continue;
}
if ($data['allowed_ui_problems']) {
$url_group->setArgument('groupids', [$group['groupid']]);
$url_host->setArgument('groupids', [$group['groupid']]);
$group_row = [new CLink($group['name'], $url_group->getUrl())];
}
else {
$group_row = [$group['name']];
}
$group_row[] = ($group['hosts_total_count'] != $group[$problematic_count_key])
? $group['hosts_total_count'] - $group[$problematic_count_key]
: '';