Merge branch 'ent-7582-anadir-selector-horas-eventos' into 'develop'

Ent 7582 anadir selector horas eventos

Closes pandora_enterprise#7582

See merge request artica/pandorafms!4266
This commit is contained in:
Daniel Rodriguez 2021-09-21 13:17:30 +00:00
commit ce40b36923
4 changed files with 172 additions and 67 deletions

View File

@ -0,0 +1,6 @@
START TRANSACTION;
ALTER TABLE `tevent_filter` ADD COLUMN `time_from` TIME NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `time_to` TIME NULL;
COMMIT;

View File

@ -252,7 +252,9 @@ if ($save_event_filter) {
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['time_from'] = get_parameter('time_from');
$values['date_to'] = get_parameter('date_to');
$values['time_to'] = get_parameter('time_to');
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
@ -304,13 +306,15 @@ if ($update_event_filter) {
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['time_from'] = get_parameter('time_from');
$values['date_to'] = get_parameter('date_to');
$values['time_to'] = get_parameter('time_to');
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$values['server_id'] = get_parameter('server_id');
}
@ -355,7 +359,9 @@ if ($get_filter_values) {
'id_extra' => '',
'id_user_ack' => '',
'date_from' => '',
'time_from' => '',
'date_to' => '',
'time_to' => '',
'severity' => '',
'event_type' => '',
'group_rep' => 0,
@ -380,7 +386,7 @@ if ($get_filter_values) {
}
}
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$server_name = db_get_value('server_name', 'tmetaconsole_setup', 'id', $event_filter['server_id']);
if ($server_name !== false) {
$event_filter['server_name'] = $server_name;
@ -543,8 +549,12 @@ function load_form_filter() {
$("#select2-server_id-container").text(val);
if(i == 'date_from')
$("#text-date_from").val(val);
if(i == 'time_from')
$("#text-time_from").val(val);
if(i == 'date_to')
$("#text-date_to").val(val);
if(i == 'time_to')
$("#text-time_to").val(val);
if(i == 'module_search')
$('input[name=module_search]').val(val);
if(i == 'group_name')
@ -767,7 +777,9 @@ function save_new_filter() {
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(),
"date_to": $("#text-date_to").val(),
"time_to": $("#text-time_to").val(),
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
@ -838,7 +850,9 @@ function save_update_filter() {
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"time_from": $("#text-time_from").val(),
"date_to": $("#text-date_to").val(),
"time_to": $("#text-time_to").val(),
"source": $("#text-source").val(),
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
@ -1783,9 +1797,11 @@ if ($get_list_events_agents) {
$tag_without = get_parameter('tag_without');
$filter_only_alert = get_parameter('filter_only_alert');
$date_from = get_parameter('date_from');
$time_from = get_parameter('time_from', '00:00:00');
$date_to = get_parameter('date_to');
$time_to = get_parameter('time_to', '23:59:59');
$id_user = $config['id_user'];
hd('hollllaa', true);
$returned_sql = events_sql_events_grouped_agents(
$id_agent,
$server_id,
@ -1800,7 +1816,9 @@ if ($get_list_events_agents) {
$tag_without,
$filter_only_alert,
$date_from,
$time_from,
$date_to,
$time_to,
$id_user
);

View File

@ -762,7 +762,7 @@ function events_get_all(
}
if (isset($filter['time_from'])) {
$time_from = $filter['time_from'];
$time_from = (empty($filter['time_from']) === true) ? '00:00:00' : $filter['time_from'];
}
if (isset($date_from)) {
@ -785,7 +785,7 @@ function events_get_all(
}
if (isset($filter['time_to'])) {
$time_to = $filter['time_to'];
$time_to = (empty($filter['time_to']) === true) ? '23:59:59' : $filter['time_to'];
}
if (isset($date_to)) {
@ -6193,7 +6193,9 @@ function events_get_events_grouped_by_agent(
* @param array $tag_without Tag_without.
* @param boolean $filter_only_alert Filter_only_alert.
* @param string $date_from Date_from.
* @param string $time_from Time_from.
* @param string $date_to Date_to.
* @param string $time_to Time_to.
* @param boolean $id_user Id_user.
* @param boolean $server_id_search Server_id_search.
*
@ -6213,7 +6215,9 @@ function events_sql_events_grouped_agents(
$tag_without=[],
$filter_only_alert=false,
$date_from='',
$time_from='',
$date_to='',
$time_to='',
$id_user=false,
$server_id_search=false
) {
@ -6320,27 +6324,35 @@ function events_sql_events_grouped_agents(
$sql_post .= " AND id_usuario = '".$id_user_ack."'";
}
if (!isset($date_from)) {
if (isset($date_from) === false) {
$date_from = '';
}
if (!isset($date_to)) {
if (isset($time_from) === false) {
$time_from = '00:00:00';
}
if (isset($date_to) === false) {
$date_to = '';
}
if (isset($time_to) === false || empty($time_to) === true) {
$time_to = '23:59:59';
}
if (($date_from == '') && ($date_to == '')) {
if ($event_view_hr > 0) {
$unixtime = (get_system_time() - ($event_view_hr * SECONDS_1HOUR));
$sql_post .= ' AND (utimestamp > '.$unixtime.')';
}
} else {
if ($date_from != '') {
$udate_from = strtotime($date_from.' 00:00:00');
if (empty($date_from) === false) {
$udate_from = strtotime($date_from.' '.$time_from);
$sql_post .= ' AND (utimestamp >= '.$udate_from.')';
}
if ($date_to != '') {
$udate_to = strtotime($date_to.' 23:59:59');
if (empty($date_to) === false) {
$udate_to = strtotime($date_to.' '.$time_to);
$sql_post .= ' AND (utimestamp <= '.$udate_to.')';
}
}

View File

@ -71,7 +71,7 @@ $access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m ==
$readonly = false;
if (!is_metaconsole()
if (is_metaconsole() === false
&& isset($config['event_replication'])
&& $config['event_replication'] == 1
&& $config['show_events_in_local'] == 1
@ -82,7 +82,7 @@ if (!is_metaconsole()
// Load specific stylesheet.
ui_require_css_file('events');
ui_require_css_file('tables');
if (is_metaconsole()) {
if (is_metaconsole() === true) {
ui_require_css_file('tables_meta', ENTERPRISE_DIR.'/include/styles/');
}
@ -216,7 +216,7 @@ $section = get_parameter('section', false);
$id_source_event = get_parameter(
'filter[id_source_event]',
$filter['id_source_event']
($filter['id_source_event'] ?? '')
);
$server_id = get_parameter(
@ -224,7 +224,7 @@ $server_id = get_parameter(
$filter['id_server_meta']
);
if (is_metaconsole()) {
if (is_metaconsole() === true) {
// Connect to node database.
$id_node = $server_id;
if ($id_node != 0) {
@ -235,16 +235,16 @@ if (is_metaconsole()) {
}
if (empty($text_agent) && !empty($id_agent)) {
if (empty($text_agent) && empty($id_agent) === false) {
$text_agent = agents_get_alias($id_agent);
}
if (empty($text_module) && !empty($id_agent_module)) {
if (empty($text_module) && empty($id_agent_module) === false) {
$text_module = modules_get_agentmodule_name($id_agent_module);
$text_agent = agents_get_alias(modules_get_agentmodule_agent($id_agent_module));
}
if (is_metaconsole()) {
if (is_metaconsole() === true) {
// Return to metaconsole database.
if ($id_node != 0) {
metaconsole_restore_db();
@ -252,7 +252,7 @@ if (is_metaconsole()) {
}
// Ajax responses.
if (is_ajax()) {
if (is_ajax() === true) {
$get_events = get_parameter('get_events', 0);
// Datatables offset, limit.
$start = get_parameter('start', 0);
@ -263,7 +263,7 @@ if (is_ajax()) {
ob_start();
$order = get_datatable_order(true);
if (is_array($order) && $order['field'] == 'mini_severity') {
if (is_array($order) === true && $order['field'] === 'mini_severity') {
$order['field'] = 'te.criticity';
}
@ -295,7 +295,8 @@ if (is_ajax()) {
'tg.nombre as group_name',
'ta.direccion',
];
if (!is_metaconsole()) {
if (is_metaconsole() === false) {
$fields[] = 'am.nombre as module_name';
$fields[] = 'am.id_agente_modulo as id_agentmodule';
$fields[] = 'am.custom_id as module_custom_id';
@ -509,11 +510,13 @@ if ($loaded_filter !== false && $from_event_graph != 1) {
$filter_only_alert = $filter['filter_only_alert'];
$id_group_filter = $filter['id_group_filter'];
$date_from = $filter['date_from'];
$time_from = $filter['time_from'];
$date_to = $filter['date_to'];
$time_to = $filter['time_to'];
$source = $filter['source'];
$id_extra = $filter['id_extra'];
$user_comment = $filter['user_comment'];
$id_source_event = $filter['id_source_event'];
$id_source_event = ($filter['id_source_event'] ?? '');
$server_id = $filter['server_id'];
}
}
@ -565,7 +568,7 @@ $tabletags_with->cellspacing = 4;
$tabletags_with->cellpadding = 4;
$tabletags_with->class = 'noshadow';
$tabletags_with->styleTable = 'border: 0px;';
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$tabletags_with->class = 'nobady';
$tabletags_with->cellspacing = 0;
$tabletags_with->cellpadding = 0;
@ -642,7 +645,7 @@ $tabletags_without->width = '100%';
$tabletags_without->cellspacing = 4;
$tabletags_without->cellpadding = 4;
$tabletags_without->class = 'noshadow';
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$tabletags_without->class = 'nobady';
$tabletags_without->cellspacing = 0;
$tabletags_without->cellpadding = 0;
@ -781,7 +784,7 @@ if ($pure) {
// Floating menu - End.
ui_require_jquery_file('countdown');
} else {
if (is_metaconsole()) {
if (is_metaconsole() === true) {
// Load metaconsole frame.
enterprise_hook('open_meta_frame');
}
@ -892,7 +895,7 @@ if ($pure) {
}
// If the history event is not enabled, dont show the history tab.
if (!isset($config['metaconsole_events_history']) || $config['metaconsole_events_history'] != 1) {
if (isset($config['metaconsole_events_history']) === false || $config['metaconsole_events_history'] != 1) {
unset($onheader['history']);
}
@ -913,7 +916,7 @@ if ($pure) {
break;
}
if (! defined('METACONSOLE')) {
if (is_metaconsole() === false) {
unset($onheader['history']);
ui_print_page_header(
__('Events'),
@ -974,13 +977,16 @@ if (enterprise_installed() === true) {
}
// Error div for ajax messages.
echo "<div id='show_message_error'>";
echo '</div>';
html_print_div(
[
'id' => 'show_message_error',
'content' => '',
]
);
// Controls.
if (is_metaconsole() !== true) {
if (isset($config['event_replication'])
if (isset($config['event_replication']) === true
&& $config['event_replication'] == 1
) {
if ($config['show_events_in_local'] == 0) {
@ -1095,7 +1101,7 @@ $in = '<div class="filter_input"><label>'.__('Free search').'</label>';
$in .= $data.'</div>';
$inputs[] = $in;
if (empty($severity) && $severity !== '0') {
if (empty($severity) === true && $severity !== '0') {
$severity = -1;
}
@ -1207,7 +1213,7 @@ $in .= $data.'</div>';
$adv_inputs[] = $in;
// Mixed. Metaconsole => server, Console => module.
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$title = __('Server');
$data = html_print_select_from_sql(
'SELECT id, server_name FROM tmetaconsole_setup',
@ -1270,16 +1276,20 @@ $data = html_print_select(
-1,
true
);
$in = '<div class="filter_input"><label>'.__('Alert events').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
if (is_metaconsole()) {
if (empty($id_source_event) === true) {
$id_source_event = '';
}
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Alert events'),
$data
),
],
true
);
$input_id_source_event = (empty($id_source_event) === true) ? '' : $id_source_event;
if (is_metaconsole() === true) {
$data = html_print_input_text(
'id_source_event',
$id_source_event,
@ -1288,19 +1298,24 @@ if (is_metaconsole()) {
255,
true
);
$in = '<div class="filter_input"><label>'.__('Id source event').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
}
if ($date_from === '0000-00-00') {
$date_from = '';
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Id source event'),
$data
),
],
true
);
}
// Date from.
$data = html_print_input_text(
$inputDateFrom = html_print_input_text(
'date_from',
$date_from,
($date_from === '0000-00-00') ? '' : $date_from,
'',
false,
10,
@ -1318,22 +1333,69 @@ $data = html_print_input_text(
// Autocomplete.
'off'
);
$in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date from').'</label>';
$in .= $data.'</div>';
$data = '';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Time from.
$inputTimeFrom = html_print_input_text(
'time_from',
$time_from,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
if ($date_to === '0000-00-00') {
$date_to = '';
}
// Date and Time From.
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s<span>:</span>%s',
__('From (date:time)'),
$inputDateFrom,
$inputTimeFrom
),
],
true
);
// Time to.
$inputTimeTo = html_print_input_text(
'time_to',
$time_to,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
// Date to.
$data = html_print_input_text(
$inputDateTo = html_print_input_text(
'date_to',
$date_to,
($date_to === '0000-00-00') ? '' : $date_to,
'',
false,
10,
@ -1351,16 +1413,23 @@ $data = html_print_input_text(
// Autocomplete.
'off'
);
$in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date to').'</label>';
$in .= $data.'</div>';
$data = '';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Date and Time To.
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s<span>:</span>%s',
__('To (date:time)'),
$inputDateTo,
$inputTimeTo
),
],
true
);
// Tags.
if (is_metaconsole()) {
if (is_metaconsole() === true) {
$data = '<fieldset><legend class="pdd_0px">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
$data .= '<fieldset><legend class="pdd_0px">'.__('Events without following tags').'</legend>'.html_print_table($tabletags_without, true).'</fieldset>';
} else {