#9473 total_modules all and id

This commit is contained in:
Jonathan 2023-01-16 16:31:13 +01:00
parent 5ea26ad91f
commit 904b505803
1 changed files with 19 additions and 2 deletions

View File

@ -12471,9 +12471,26 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType)
return;
}
$partial = tactical_status_modules_agents($config['id_user'], false, 'AR');
if ($id_group) {
$groups_clause = '1 = 1';
if (!users_is_admin($config['id_user'])) {
$user_groups = implode(',', array_keys(users_get_groups()));
$groups_clause = "(ta.id_grupo IN ($user_groups) OR tasg.id_group IN ($user_groups))";
}
$total = (int) $partial['_monitor_total_'];
$sql = "SELECT COUNT(DISTINCT(id_agente_modulo))
FROM tagente_modulo tam, tagente ta
LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
WHERE tam.id_agente = ta.id_agente AND id_module_group = $id_group
AND delete_pending = 0 AND $groups_clause";
$total = db_get_value_sql($sql);
} else {
$partial = tactical_status_modules_agents($config['id_user'], false, 'AR');
$total = (int) $partial['_monitor_total_'];
}
$data = [
'type' => 'string',