From ec1f12b9ead7d2283f214592e759acb0561cc15a Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Mon, 14 Oct 2013 14:22:52 +0000 Subject: [PATCH] 2013-10-14 Sergio Martin * include/functions_events.php include/functions_reporting.php godmode/reporting/reporting_builder.item_editor.php: Fixed filters of event reports filters and some visual issues git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8910 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++ .../reporting_builder.item_editor.php | 4 +- pandora_console/include/functions_events.php | 52 +++++++--- .../include/functions_reporting.php | 97 +++++++++++++------ 4 files changed, 117 insertions(+), 43 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ddf2062032..c7839674da 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2013-10-14 Sergio Martin + + * include/functions_events.php + include/functions_reporting.php + godmode/reporting/reporting_builder.item_editor.php: Fixed filters + of event reports filters and some visual issues + 2013-10-14 Miguel de Dios * include/functions_groups.php: into the function diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 7b904bd0b2..d79f14afbe 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -892,11 +892,11 @@ html_print_input_hidden('id_item', $idItem); ?> - + - + diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index a25ef33454..6f851e2896 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1152,11 +1152,15 @@ function events_get_group_events ($id_group, $period, $date, $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; + } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; } if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; @@ -1209,11 +1213,15 @@ function events_get_group_events_steps ($begin, &$result, $id_group, $period, $d $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; + } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; } if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; @@ -2402,12 +2410,17 @@ function events_get_count_events_by_agent ($id_group, $period, $date, $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + } + if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; } @@ -2479,12 +2492,17 @@ function events_get_count_events_validated_by_user ($filter, $period, $date, $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + } + if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; } @@ -2556,12 +2574,17 @@ function events_get_count_events_by_criticity ($filter, $period, $date, $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + } + if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; } @@ -2626,12 +2649,17 @@ function events_get_count_events_validated ($filter, $period, $date, $datelimit = $date - $period; $sql_where = ' AND 1 = 1 '; + $criticities = array(); if ($filter_event_critical) { - $sql_where .= ' AND criticity = 4 '; + $criticities[] = 4; } if ($filter_event_warning) { - $sql_where .= ' AND criticity = 3 '; + $criticities[] = 3; } + if (!empty($criticities)) { + $sql_where .= ' AND criticity IN (' . implode(', ', $criticities) . ')'; + } + if ($filter_event_validated) { $sql_where .= ' AND estado = 1 '; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e07e902d34..d311597d81 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2483,7 +2483,7 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0, $table->align = array(); $table->align[0] = 'center'; - $table->align[2] = 'center'; + $table->align[1] = 'center'; $table->align[3] = 'center'; $table->data = array (); @@ -2510,12 +2510,14 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0, array_push ($events, $event); } } - + if ($events) foreach ($events as $eventRow) { - foreach ($eventRow as $event) { + foreach ($eventRow as $k => $event) { //First pass along the class of this row - $table->rowclass[] = + $table->cellclass[$k][1] = $table->cellclass[$k][2] = + $table->cellclass[$k][4] = $table->cellclass[$k][5] = + $table->cellclass[$k][6] = get_priority_class ($event["criticity"]); $data = array (); @@ -2609,9 +2611,11 @@ function reporting_get_group_detailed_event ($id_group, $period = 0, $filter_event_warning, $filter_event_no_validated); if ($events) { - foreach ($events as $event) { + foreach ($events as $k => $event) { //First pass along the class of this row - $table->rowclass[] = + $table->cellclass[$k][1] = $table->cellclass[$k][3] = + $table->cellclass[$k][4] = $table->cellclass[$k][5] = + $table->cellclass[$k][6] = get_priority_class ($event["criticity"]); $data = array (); @@ -3699,16 +3703,20 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $event_graph_by_criticity = $style['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated']; + $next_row = 1; + // Put description at the end of the module (if exists) - $table->colspan[1][0] = 3; if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); + $table->colspan[$next_row][0] = 3; + $next_row++; } $data = array (); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; $data[0] = reporting_get_agents_detailed_event( $content['id_agent'], $content['period'], $report["datetime"], true, @@ -3717,7 +3725,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_warning, $filter_event_no_validated); - array_push ($table->data, $data); + if(!empty($data[0])) { + array_push ($table->data, $data); + + $table->colspan[$next_row][0] = 3; + $next_row++; + } if ($event_graph_by_user_validator) { @@ -3739,7 +3752,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } @@ -3762,7 +3776,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } @@ -3785,7 +3800,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } break; @@ -3793,27 +3809,36 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f reporting_header_content($mini, $content, $report, $table, __('Text'), "", ""); + $next_row = 1; + if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); + $table->colspan[$next_row][0] = 3; + $next_row++; } $data[0] = html_entity_decode($content['text']); array_push($table->data, $data); - $table->colspan[2][0] = 2; + $table->colspan[$next_row][0] = 3; break; case 'sql': reporting_header_content($mini, $content, $report, $table, __('SQL'), "", ""); + $next_row = 1; // Put description at the end of the module (if exists) - $table->colspan[0][0] = 2; if ($content["description"] != ""){ $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); + + $table->colspan[$next_row][0] = 3; + $next_row++; } + $table->colspan[$next_row][0] = 3; + $table2->class = 'databox'; $table2->width = '100%'; @@ -3918,17 +3943,19 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f ui_print_truncate_text( groups_get_name($content['id_group'], true), 60, false)); + + $next_row = 1; // Put description at the end of the module (if exists) - $table->colspan[1][0] = 3; if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); + $table->colspan[$next_row][0] = 3; + $next_row++; } $data = array (); - $table->colspan[2][0] = 3; $style = json_decode(io_safe_output($content['style']), true); @@ -3949,7 +3976,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $filter_event_critical, $filter_event_warning, $filter_event_no_validated); - array_push ($table->data, $data); + if(!empty($data[0])) { + array_push ($table->data, $data); + + $table->colspan[$next_row][0] = 3; + $next_row++; + } if ($event_graph_by_agent) { $data_graph = reporting_get_count_events_by_agent( @@ -3970,7 +4002,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } @@ -3993,7 +4026,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } @@ -4016,7 +4050,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } @@ -4039,7 +4074,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = html_print_table($table_event_graph, true); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; + $next_row++; array_push ($table->data, $data); } break; @@ -4121,16 +4157,18 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f reporting_header_content($mini, $content, $report, $table, __('Import text from URL'), ui_print_truncate_text($content["external_source"], 'description', false)); + $next_row = 1; // Put description at the end of the module (if exists) - $table->colspan[1][0] = 3; if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); + $table->colspan[$next_row][0] = 3; + $next_row++; } $data = array(); - $table->colspan[2][0] = 3; + $table->colspan[$next_row][0] = 3; $data[0] = ''; // TODO: make this dynamic and get the height if the iframe to resize this item $data[0] .= '