diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 55da92ab4a..0e63eb26ef 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -392,12 +392,55 @@ function reporting_make_reporting_data($id_report, $date, $time, $report, $content); break; + case 'inventory_changes': + $report['contents'][] = reporting_inventory_changes( + $report, + $content); + break; } } return reporting_check_structure_report($report); } +function reporting_inventory_changes($report, $content) { + global $config; + + $return['type'] = 'inventory_changes'; + + if (empty($content['name'])) { + $content['name'] = __('Inventory Changes'); + } + + $return['title'] = $content['name']; + $return['subtitle'] = agents_get_name($content['id_agent']); + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text($report, $content); + + $es = json_decode($content['external_source'], true); + + $id_agent = $es['id_agents']; + $module_name = $es['inventory_modules']; + + + + $inventory_changes = inventory_get_changes( + $id_agent, $module_name, + $report["datetime"] - $content['period'], + $report["datetime"], "array"); + + $return['data'] = array(); + + if ($inventory_changes == ERR_NODATA) { + $return['failed'] = __('No changes found.'); + } + else { + $return['data'] = $inventory_changes; + } + + return reporting_check_structure_content($return); +} + function reporting_inventory($report, $content) { global $config; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 4e7dd331be..24cef9c5d9 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -243,6 +243,9 @@ function reporting_html_print_report($report, $mini = false) { case 'inventory': reporting_html_inventory($table, $item); break; + case 'inventory_changes': + reporting_html_inventory_changes($table, $item); + break; } if ($item['type'] == 'agent_module') @@ -255,6 +258,57 @@ function reporting_html_print_report($report, $mini = false) { } } +function reporting_html_inventory_changes($table, $item) { + if (!empty($item['failed'])) { + $table->colspan['failed']['cell'] = 3; + $table->cellstyle['failed']['cell'] = 'text-align: center;'; + $table->data['failed']['cell'] = $item['failed']; + } + else { + foreach ($item['data'] as $module_item) { + $table1 = null; + $table1->width = '99%'; + + $table1->cellstyle[0][0] = + $table1->cellstyle[0][1] = + 'background: #373737; color: #FFF;'; + $table1->data[0][0] = $module_item['agent']; + $table1->data[0][1] = $module_item['module']; + + + $table1->cellstyle[1][0] = + 'background: #373737; color: #FFF;'; + $table1->data[1][0] = $module_item['date']; + $table1->colspan[1][0] = 2; + + + $table1->cellstyle[2][0] = + 'background: #373737; color: #FFF; text-align: center;'; + $table1->data[2][0] = __('Added'); + $table1->colspan[2][0] = 2; + + + $table1->data = array_merge($table1->data, $module_item['added']); + + + $table1->cellstyle[3 + count($module_item['added'])][0] = + 'background: #373737; color: #FFF; text-align: center;'; + $table1->data[3 + count($module_item['added'])][0] = __('Deleted'); + $table1->colspan[3 + count($module_item['added'])][0] = 2; + + + $table1->data = array_merge($table1->data, $module_item['deleted']); + + + $table->colspan[ + $module_item['agent'] . "_" .$module_item['module']]['cell'] = 3; + $table->data[ + $module_item['agent'] . "_" .$module_item['module']]['cell'] = + html_print_table($table1, true); + } + } +} + function reporting_html_inventory($table, $item) { if (!empty($item['failed'])) { $table->colspan['failed']['cell'] = 3; @@ -4869,39 +4923,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f break; - case 'inventory_changes': - if (empty($item_title)) { - $item_title = __('Inventory changes'); - } - reporting_header_content($mini, $content, $report, $table, $item_title); - - $es = json_decode($content['external_source'], true); - - $id_agent = $es['id_agents']; - $module_name = $es['inventory_modules']; - $description = $content['description']; - - $inventory_changes = inventory_get_changes($id_agent, $module_name, $report["datetime"] - $content['period'], $report["datetime"]); - - if ($inventory_changes == ERR_NODATA) { - $inventory_changes = "
".__('No changes found.')."
"; - $inventory_changes .= " "; - } - - $data = array (); - - $table->colspan[1][0] = 2; - - if ($description != '') { - $data[0] = $description; - array_push ($table->data, $data); - } - - $data[0] = $inventory_changes; - $table->colspan[2][0] = 2; - - array_push ($table->data, $data); - break; } //Restore dbconnection if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE') && $remote_connection == 1) {