Added the feature to filter by text the event in report item event_report_group. TICKET: #2066

This commit is contained in:
mdtrooper 2015-04-27 16:10:16 +02:00
parent ce1fd47c88
commit 8ec4ef26d7
4 changed files with 119 additions and 23 deletions

View File

@ -104,6 +104,9 @@ $netflow_filter = 0;
$max_values = 0;
$resolution = 0;
//Others
$filter_search = "";
switch ($action) {
case 'new':
$actionParameter = 'save';
@ -412,6 +415,8 @@ switch ($action) {
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search'];
break;
case 'event_report_module':
$description = $item['description'];
@ -1175,6 +1180,14 @@ html_print_input_hidden('id_item', $idItem);
?>
</td>
</tr>
<tr id="row_filter_search" style="" class="datos">
<td><?php echo __('Free search');?></td>
<td>
<?php
html_print_input_text('filter_search', $filter_search);
?>
</td>
</tr>
</tbody>
</table>
<br />
@ -2043,14 +2056,17 @@ function chooseType() {
$("#row_module_multi").hide();
$("#row_event_filter").hide();
$("#row_event_graphs").hide();
$("#row_event_graph_by_agent").hide();
$("#row_event_graph_by_user").hide();
$("#row_event_graph_by_criticity").hide();
$("#row_event_graph_by_validated").hide();
$("#row_netflow_filter").hide();
$("#row_max_values").hide();
$("#row_resolution").hide();
$("#row_last_value").hide();
$("#row_filter_search").hide();
// SLA list default state
$("#sla_list").hide();
@ -2079,6 +2095,8 @@ function chooseType() {
$("#row_event_graph_by_user").show();
$("#row_event_graph_by_criticity").show();
$("#row_event_graph_by_validated").show();
$("#row_filter_search").show();
break;
case 'simple_graph':
$("#row_time_compare_overlapped").show();

View File

@ -927,6 +927,8 @@ switch ($action) {
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
$event_filter_search = get_parameter('filter_search', '');
// If metaconsole is activated
if ($config['metaconsole'] == 1 && defined('METACONSOLE')) {
if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) {
@ -993,6 +995,13 @@ switch ($action) {
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
switch ($values['type']) {
case 'event_report_group':
$style['event_filter_search'] =
$event_filter_search;
break;
}
break;
case 'simple_graph':
// Warning. We are using this column to hold this value to avoid
@ -1213,6 +1222,9 @@ switch ($action) {
$event_graph_by_user_validator = get_parameter('event_graph_by_user_validator', 0);
$event_graph_by_criticity = get_parameter('event_graph_by_criticity', 0);
$event_graph_validated_vs_unvalidated = get_parameter('event_graph_validated_vs_unvalidated', 0);
$event_filter_search = get_parameter('filter_search', '');
//Added for events items
$style['filter_event_no_validated'] = $filter_event_no_validated;
$style['filter_event_validated'] = $filter_event_validated;
@ -1223,6 +1235,14 @@ switch ($action) {
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
switch ($values['type']) {
case 'event_report_group':
$style['event_filter_search'] =
$event_filter_search;
break;
}
break;
case 'simple_graph':
// Warning. We are using this column to hold this value to avoid

View File

@ -1085,7 +1085,8 @@ function events_print_type_description ($type, $return = false) {
*/
function events_get_group_events ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = false) {
global $config;
@ -1115,9 +1116,16 @@ function events_get_group_events ($id_group, $period, $date,
if ($filter_event_no_validated) {
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%'. io_safe_input($filter_event_filter_search) . '%"'.
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
}
$sql_where .= sprintf(' AND id_grupo IN (%s) AND utimestamp > %d
AND utimestamp <= %d ', implode (",", $id_group), $datelimit, $date);
return events_get_events_grouped($sql_where, 0, 1000);
}
@ -2403,7 +2411,9 @@ function events_clean_tags ($tags) {
*/
function events_get_count_events_by_agent ($id_group, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
global $config;
$id_group = groups_safe_acl ($config["id_user"], $id_group, "AR");
@ -2434,6 +2444,11 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_filter_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_filter_search) . '%%")';
}
$sql = sprintf ('SELECT id_agente,
(SELECT t2.nombre
FROM tagente AS t2
@ -2475,7 +2490,9 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
*/
function events_get_count_events_validated_by_user ($filter, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
global $config;
$sql_filter = ' AND 1=1 ';
@ -2516,6 +2533,11 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_filter_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_filter_search) . '%%")';
}
$sql = sprintf ('SELECT id_usuario,
(SELECT t2.fullname
FROM tusuario AS t2
@ -2557,7 +2579,9 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
*/
function events_get_count_events_by_criticity ($filter, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
global $config;
$sql_filter = ' AND 1=1 ';
@ -2598,6 +2622,11 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_filter_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_filter_search) . '%%")';
}
$sql = sprintf ('SELECT criticity,
COUNT(*) AS count
FROM tevento
@ -2632,7 +2661,9 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
*/
function events_get_count_events_validated ($filter, $period, $date,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
global $config;
$sql_filter = ' AND 1=1 ';
@ -2673,6 +2704,11 @@ function events_get_count_events_validated ($filter, $period, $date,
$sql_where .= ' AND estado = 0 ';
}
if (!empty($filter_event_filter_search)) {
$sql_where .= ' AND (evento LIKE "%%'. io_safe_input($filter_event_filter_search) . '%%"'.
' OR id_evento LIKE "%%' . io_safe_input($filter_event_filter_search) . '%%")';
}
$sql = sprintf ('SELECT estado,
COUNT(*) AS count
FROM tevento

View File

@ -3238,10 +3238,13 @@ function reporting_get_agents_detailed_event ($id_agents, $period = 0,
function reporting_get_group_detailed_event ($id_group, $period = 0,
$date = 0, $return = false, $html = true,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
global $config;
if (!is_numeric ($date)) {
$date = strtotime ($date);
}
@ -3268,7 +3271,8 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$events = events_get_group_events($id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
if ($events) {
$note = '';
@ -5025,6 +5029,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated = $style['filter_event_validated'];
$filter_event_critical = $style['filter_event_critical'];
$filter_event_warning = $style['filter_event_warning'];
$filter_event_filter_search = $style['event_filter_search'];
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
@ -5037,10 +5042,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
if(!empty($data[0])) {
$filter_event_no_validated,
$filter_event_filter_search);
if (!empty($data[0])) {
array_push ($table->data, $data);
$table->colspan[$next_row][0] = 3;
$next_row++;
}
@ -5052,7 +5059,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$filter_event_no_validated,
$filter_event_filter_search);
$table_event_graph = null;
$table_event_graph->width = '100%';
@ -5078,7 +5086,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$filter_event_no_validated,
$filter_event_filter_search);
$table_event_graph = null;
$table_event_graph->head[0] = __('Events validated by user');
@ -5104,7 +5113,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$filter_event_no_validated,
$filter_event_filter_search);
$colors = get_criticity_pie_colors($data_graph);
@ -5132,7 +5142,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$filter_event_validated,
$filter_event_critical,
$filter_event_warning,
$filter_event_no_validated);
$filter_event_no_validated,
$filter_event_filter_search);
$table_event_graph = null;
$table_event_graph->head[0] = __('Amount events validated');
@ -5608,6 +5619,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
break;
}
$data = array();
$avg = 0;
@ -5650,6 +5663,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$text = $row['agent'] . " (" . $text . ")";
$monitor_value = reporting_get_agentmodule_sla(
$item['id_agent_module'],
$content['period'],
@ -8237,7 +8251,8 @@ function reporting_template_graphs_get_user ($id_user = 0, $only_names = false,
function reporting_get_count_events_by_agent ($id_group, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = false) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
@ -8248,7 +8263,8 @@ function reporting_get_count_events_by_agent ($id_group, $period = 0,
return events_get_count_events_by_agent($id_group, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
}
/**
@ -8265,7 +8281,8 @@ function reporting_get_count_events_by_agent ($id_group, $period = 0,
function reporting_get_count_events_validated_by_user ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
@ -8276,7 +8293,8 @@ function reporting_get_count_events_validated_by_user ($filter, $period = 0,
return events_get_count_events_validated_by_user($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
}
/**
@ -8293,7 +8311,8 @@ function reporting_get_count_events_validated_by_user ($filter, $period = 0,
function reporting_get_count_events_by_criticity ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
@ -8304,7 +8323,8 @@ function reporting_get_count_events_by_criticity ($filter, $period = 0,
return events_get_count_events_by_criticity($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
}
/**
@ -8321,7 +8341,8 @@ function reporting_get_count_events_by_criticity ($filter, $period = 0,
function reporting_get_count_events_validated ($filter, $period = 0,
$date = 0,
$filter_event_validated = false, $filter_event_critical = false,
$filter_event_warning = false, $filter_event_no_validated = false) {
$filter_event_warning = false, $filter_event_no_validated = false,
$filter_event_filter_search = null) {
if (!is_numeric ($date)) {
$date = strtotime ($date);
@ -8332,7 +8353,8 @@ function reporting_get_count_events_validated ($filter, $period = 0,
return events_get_count_events_validated($filter, $period, $date,
$filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated);
$filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search);
}
/**