diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 029fb8035c..31ad14c75e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-12-12 Sergio Martin + + * godmode/reporting/reporting_builder.list_items.php: Fixed the + modules/agents shown in the table of report items in inventory + kind + merged from 4.0.2 + 2012-12-12 Miguel de Dios * include/functions_visual_map_editor.php: increased the size of diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 468985f61d..ae4e8c6304 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -294,15 +294,41 @@ foreach ($items as $item) { } if ($item['id_agent'] == 0) { + $is_inventory_item = $item['type'] == 'inventory' || $item['type'] == 'inventory_changes'; // Due to SLA or top N or general report items - if (($item['id_agent_module'] == '') or ($item['id_agent_module'] == 0)) { + if (!$is_inventory_item && ($item['id_agent_module'] == '' || $item['id_agent_module'] == 0)) { $row[2] = ''; $row[3] = ''; } else { - $row[2] = ui_print_truncate_text(agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])), 'agent_small'); - $module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); - $row[3] = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small'); + // The inventory items have the agents and modules in json format in the field external_source + if($is_inventory_item) { + $external_source = json_decode($item['external_source'], true); + $agents = $external_source['id_agents']; + $modules = $external_source['id_agents']; + + $agent_name_db = array(); + foreach($agents as $a) { + $agent_name_db[] = agents_get_name($a); + } + $agent_name_db = implode('
',$agent_name_db); + + $module_name_db = array(); + foreach($modules as $m) { + $module_name_raw = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $m)); + $module_name_db[] = ui_print_truncate_text(io_safe_output($module_name_raw), 'module_small'); + } + $module_name_db = implode('
',$module_name_db); + } + else { + $agent_name_db = agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])); + $agent_name_db = ui_print_truncate_text($agent_name_db, 'agent_small'); + $module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $module_name_db = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small'); + } + + $row[2] = $agent_name_db; + $row[3] = $module_name_db; } } else {