#12696 fix tactical view error 500 and schedule by group

This commit is contained in:
Jonathan 2024-01-16 17:17:07 +01:00
parent a16fa51922
commit ce00c4b9e5
3 changed files with 14 additions and 7 deletions

View File

@ -436,12 +436,16 @@ class Agents extends Element
$percentages = [];
$total = array_sum($data);
foreach ($data as $key => $value) {
$percentage = (($value / $total) * 100);
if ($percentage < 1 && $percentage > 0) {
$percentage = 1;
}
if ($total > 0) {
$percentage = (($value / $total) * 100);
if ($percentage < 1 && $percentage > 0) {
$percentage = 1;
}
$percentages[$key] = format_numeric($percentage, 0);
$percentages[$key] = format_numeric($percentage, 0);
} else {
$percentages[$key] = '0%';
}
}
$data = $percentages;

View File

@ -113,8 +113,9 @@ class Groups extends Element
$id_groups = implode(',', $id_groups);
$modules = modules_get_modules_in_group($id_groups);
$total_groups = count($modules);
$total_groups = ($modules !== false) ? count($modules) : 0;
if ($total_groups === 0) {
include_once $config['homedir'].'/include/functions_graph.php';
return graph_nodata_image(['width' => '400']);
}

View File

@ -156,13 +156,15 @@ class ScheduledDowntime extends Element
'cron_interval_from',
'cron_interval_to',
];
$groups = implode(',', array_keys(users_get_groups($config['user'])));
$columns_str = implode(',', $columns);
$sql = sprintf(
'SELECT %s
FROM tplanned_downtime
WHERE id_group IN (%s)
%s %s',
$columns_str,
$groups,
$order,
$pagination,
);