2006-07-19 20:29:12 +02:00
< ? php
2019-03-25 12:53:50 +01:00
/**
2019-06-20 11:46:01 +02:00
* Event list .
2019-03-25 12:53:50 +01:00
*
* @ category Events
* @ package Pandora FMS
* @ subpackage Community
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
2019-03-25 12:53:50 +01:00
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright ( c ) 2005 - 2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https :// pandorafms . com / community / for full contribution list
2019-03-25 12:53:50 +01:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
// Load global vars.
2010-03-02 20:25:51 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_events.php' ;
2019-03-25 12:53:50 +01:00
// Event processing functions.
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_alerts.php' ;
2019-03-25 12:53:50 +01:00
// Alerts processing functions.
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
2019-03-25 12:53:50 +01:00
// Agents functions.
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
2019-03-25 12:53:50 +01:00
// Users functions.
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_graph.php' ;
require_once $config [ 'homedir' ] . '/include/functions_ui.php' ;
2019-06-06 17:50:47 +02:00
// Check access.
2019-01-30 16:18:44 +01:00
check_login ();
2021-05-24 17:35:15 +02:00
enterprise_include_once ( '/include/class/CommandCenter.class.php' );
2021-03-11 15:40:23 +01:00
2022-04-11 15:22:37 +02:00
$event_a = ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'ER' );
$event_w = ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'EW' );
$event_m = ( bool ) check_acl ( $config [ 'id_user' ], 0 , 'EM' );
2019-06-20 19:23:13 +02:00
2022-04-11 15:22:37 +02:00
if ( $event_a === false
&& $event_w === false
&& $event_m === false
2019-03-25 12:53:50 +01:00
) {
2019-01-30 16:18:44 +01:00
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_ACL_VIOLATION ,
2019-01-30 16:18:44 +01:00
'Trying to access event viewer'
);
2022-04-11 15:22:37 +02:00
if ( is_ajax () === true ) {
2019-06-13 12:30:09 +02:00
return [ 'error' => 'noaccess' ];
}
2019-01-30 16:18:44 +01:00
include 'general/noaccess.php' ;
return ;
2007-02-05 18:45:14 +01:00
}
2013-01-16 13:57:11 +01:00
2022-04-11 15:22:37 +02:00
$access = ( $event_a === true ) ? 'ER' : (( $event_w === true ) ? 'EW' : (( $event_m === true ) ? 'EM' : 'ER' ));
2019-06-06 17:50:47 +02:00
2019-06-13 19:41:21 +02:00
$readonly = false ;
2019-06-06 17:50:47 +02:00
// Load specific stylesheet.
ui_require_css_file ( 'events' );
2019-06-18 19:17:21 +02:00
ui_require_css_file ( 'tables' );
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2023-02-28 17:47:49 +01:00
ui_require_css_file ( 'tables' );
// ui_require_css_file('meta_tables', ENTERPRISE_DIR.'/meta/styles/');
2023-02-28 09:50:42 +01:00
ui_require_css_file ( 'meta_events' , ENTERPRISE_DIR . '/meta/styles/' );
2019-06-19 08:43:37 +02:00
}
2019-06-06 17:50:47 +02:00
2019-06-10 15:18:35 +02:00
// Load extra javascript.
ui_require_javascript_file ( 'pandora_events' );
2019-06-06 17:50:47 +02:00
// Get requests.
2019-06-20 14:18:49 +02:00
$default_filter = [
'status' => EVENT_NO_VALIDATED ,
'event_view_hr' => $config [ 'event_view_hr' ],
2022-09-27 15:08:09 +02:00
'group_rep' => EVENT_GROUP_REP_EVENTS ,
2019-06-20 14:18:49 +02:00
'tag_with' => [],
'tag_without' => [],
'history' => false ,
];
$fb64 = get_parameter ( 'fb64' , null );
2022-04-11 15:22:37 +02:00
if ( isset ( $fb64 ) === true ) {
2019-06-20 14:18:49 +02:00
$filter = json_decode ( base64_decode ( $fb64 ), true );
2021-12-01 11:13:28 +01:00
$filter [ 'tag_with' ] = [];
$filter [ 'tag_without' ] = [];
2019-06-20 14:18:49 +02:00
} else {
$filter = get_parameter (
'filter' ,
$default_filter
);
}
2023-08-28 12:27:45 +02:00
$event_list_widget_filter = get_parameter ( 'event_list_widget_filter' , null );
if ( isset ( $event_list_widget_filter ) === true ) {
$filter = $event_list_widget_filter ;
}
2023-07-27 10:47:51 +02:00
$settings_modal = get_parameter ( 'settings' , 0 );
$parameters_modal = get_parameter ( 'parameters' , 0 );
2022-12-14 11:08:24 +01:00
$id_group_filter = get_parameter (
'filter[id_group_filter]' ,
( $filter [ 'id_group_filter' ] ? ? '' )
);
2019-06-20 14:18:49 +02:00
$id_group = get_parameter (
'filter[id_group]' ,
2022-12-14 11:08:24 +01:00
( $filter [ 'id_group' ] ? ? $id_group_filter )
2019-06-20 14:18:49 +02:00
);
2022-12-14 11:08:24 +01:00
2019-06-20 14:18:49 +02:00
$event_type = get_parameter (
'filter[event_type]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'event_type' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$severity = get_parameter (
'filter[severity]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'severity' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2023-09-28 10:11:55 +02:00
$regex = get_parameter (
'filter[regex]' ,
2023-11-07 08:35:49 +01:00
( io_safe_output ( $filter [ 'regex' ]) ? ? '' )
2023-09-28 10:11:55 +02:00
);
unset ( $filter [ 'regex' ]);
2019-06-20 14:18:49 +02:00
$status = get_parameter (
'filter[status]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'status' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$search = get_parameter (
'filter[search]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'search' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2022-11-18 14:04:54 +01:00
$not_search = get_parameter (
'filter[not_search]' ,
0
);
2019-06-20 14:18:49 +02:00
$text_agent = get_parameter (
'filter[text_agent]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'text_agent' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$id_agent = get_parameter (
'filter[id_agent]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'id_agent' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2020-01-13 18:19:50 +01:00
$text_module = get_parameter (
2020-09-04 12:38:46 +02:00
'filter[module_search]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'module_search' ] ? ? '' )
2020-01-13 18:19:50 +01:00
);
2019-06-20 14:18:49 +02:00
$id_agent_module = get_parameter (
2020-12-09 18:15:01 +01:00
'id_agent_module' ,
get_parameter (
'filter[id_agent_module]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'id_agent_module' ] ? ? '' )
2020-12-09 18:15:01 +01:00
)
2019-06-20 14:18:49 +02:00
);
$pagination = get_parameter (
'filter[pagination]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'pagination' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$event_view_hr = get_parameter (
'filter[event_view_hr]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'event_view_hr' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$id_user_ack = get_parameter (
'filter[id_user_ack]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'id_user_ack' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2022-11-03 12:00:58 +01:00
$owner_user = get_parameter (
'filter[owner_user]' ,
( $filter [ 'owner_user' ] ? ? '' )
);
2019-06-20 14:18:49 +02:00
$group_rep = get_parameter (
'filter[group_rep]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'group_rep' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$tag_with = get_parameter (
'filter[tag_with]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'tag_with' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$tag_without = get_parameter (
'filter[tag_without]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'tag_without' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$filter_only_alert = get_parameter (
'filter[filter_only_alert]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'filter_only_alert' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2022-07-05 17:02:40 +02:00
$search_secondary_groups = get_parameter (
'filter[search_secondary_groups]' ,
0
);
2022-09-29 12:54:46 +02:00
$search_recursive_groups = get_parameter (
'filter[search_recursive_groups]' ,
2022-12-14 11:08:24 +01:00
( $filter [ 'search_recursive_groups' ] ? ? '' )
2022-09-29 12:54:46 +02:00
);
2023-08-07 14:43:50 +02:00
$search_recursive_groups = get_parameter (
'filter[private_filter_event]' ,
( $filter [ 'private_filter_event' ] ? ? '' )
);
2019-06-20 14:18:49 +02:00
$id_group_filter = get_parameter (
'filter[id_group_filter]' ,
2022-07-15 11:38:46 +02:00
( $filter [ 'id_group' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$date_from = get_parameter (
'filter[date_from]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'date_from' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$date_to = get_parameter (
'filter[date_to]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'date_to' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2019-12-10 15:29:35 +01:00
$time_from = get_parameter (
'filter[time_from]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'time_from' ] ? ? '' )
2019-12-10 15:29:35 +01:00
);
$time_to = get_parameter (
'filter[time_to]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'time_to' ] ? ? '' )
2019-12-10 15:29:35 +01:00
);
2019-06-20 14:18:49 +02:00
$source = get_parameter (
'filter[source]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'source' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$id_extra = get_parameter (
'filter[id_extra]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'id_extra' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$user_comment = get_parameter (
'filter[user_comment]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'user_comment' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
$history = get_parameter (
'history' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'history' ] ? ? '' )
2019-06-20 14:18:49 +02:00
);
2019-06-19 12:56:16 +02:00
$section = get_parameter ( 'section' , false );
2019-06-06 17:50:47 +02:00
2019-11-22 13:38:08 +01:00
$id_source_event = get_parameter (
'filter[id_source_event]' ,
2021-07-05 17:42:45 +02:00
( $filter [ 'id_source_event' ] ? ? '' )
2019-11-22 13:38:08 +01:00
);
2019-12-10 15:29:35 +01:00
2020-01-13 18:19:50 +01:00
$server_id = get_parameter (
'filter[server_id]' ,
2022-11-22 11:35:38 +01:00
( $filter [ 'server_id' ] ? ? '' )
2020-01-13 18:19:50 +01:00
);
2023-02-20 13:10:00 +01:00
if ( empty ( $id_agent ) === true ) {
$id_agent = get_parameter (
'id_agent' ,
( $filter [ 'id_agent' ] ? ? '' )
);
}
2022-09-29 09:17:37 +02:00
if ( is_metaconsole () === true ) {
$servers = metaconsole_get_servers ();
if ( is_array ( $servers ) === true ) {
$servers = array_reduce (
$servers ,
function ( $carry , $item ) {
$carry [ $item [ 'id' ]] = $item [ 'server_name' ];
return $carry ;
}
);
} else {
$servers = [];
}
$servers [ 0 ] = __ ( 'Metaconsola' );
2022-11-22 11:35:38 +01:00
if ( empty ( $server_id ) === true ) {
2022-09-29 09:17:37 +02:00
$server_id = array_keys ( $servers );
2022-11-22 11:35:38 +01:00
} else {
if ( is_array ( $server_id ) === false ) {
if ( is_numeric ( $server_id ) === true ) {
if ( $server_id !== 0 ) {
$server_id = [ $filter [ 'server_id' ]];
} else {
$server_id = array_keys ( $servers );
}
} else {
$server_id = explode ( ',' , $filter [ 'server_id' ]);
}
2022-09-29 09:17:37 +02:00
}
}
}
2022-03-29 18:09:19 +02:00
$custom_data_filter_type = get_parameter (
'filter[custom_data_filter_type]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'custom_data_filter_type' ] ? ? '' )
2022-03-29 18:09:19 +02:00
);
$custom_data = get_parameter (
'filter[custom_data]' ,
2022-06-01 17:27:44 +02:00
( $filter [ 'custom_data' ] ? ? '' )
2022-03-29 18:09:19 +02:00
);
2022-10-10 17:08:20 +02:00
if ( is_metaconsole () === true
&& is_array ( $server_id ) === false
) {
2020-01-13 18:19:50 +01:00
// Connect to node database.
2022-04-11 15:22:37 +02:00
$id_node = ( int ) $server_id ;
if ( $id_node !== 0 ) {
if ( metaconsole_connect ( null , $id_node ) !== NOERR ) {
2020-01-13 18:19:50 +01:00
return false ;
}
}
}
2022-06-03 09:28:18 +02:00
if ( empty ( $text_agent ) === true
&& empty ( $id_agent ) === false
) {
2019-12-10 15:29:35 +01:00
$text_agent = agents_get_alias ( $id_agent );
}
2022-04-11 15:22:37 +02:00
if ( empty ( $text_module ) === true && empty ( $id_agent_module ) === false ) {
2020-01-13 18:19:50 +01:00
$text_module = modules_get_agentmodule_name ( $id_agent_module );
$text_agent = agents_get_alias ( modules_get_agentmodule_agent ( $id_agent_module ));
}
2022-10-10 17:08:20 +02:00
if ( is_metaconsole () === true
&& is_array ( $server_id ) === false
) {
2020-01-13 18:19:50 +01:00
// Return to metaconsole database.
if ( $id_node != 0 ) {
metaconsole_restore_db ();
}
}
2019-06-07 22:44:02 +02:00
// Ajax responses.
2021-07-05 17:42:45 +02:00
if ( is_ajax () === true ) {
2022-06-07 17:25:51 +02:00
$get_events = ( int ) get_parameter ( 'get_events' , 0 );
2023-10-10 15:15:43 +02:00
$external_url = ( bool ) get_parameter ( 'external_url' , 0 );
2022-06-21 11:17:18 +02:00
$table_id = get_parameter ( 'table_id' , '' );
$groupRecursion = ( bool ) get_parameter ( 'groupRecursion' , false );
2023-09-27 13:30:56 +02:00
$compact_date = ( int ) get_parameter ( 'compact_date' , 0 );
2023-11-07 13:18:44 +01:00
$compact_name_event = ( int ) get_parameter ( 'compact_name_event' , 0 );
2022-06-21 11:17:18 +02:00
2019-06-07 22:44:02 +02:00
// Datatables offset, limit.
2023-07-07 12:53:14 +02:00
$start = ( int ) get_parameter ( 'start' , 0 );
2022-06-07 17:25:51 +02:00
$length = get_parameter (
'length' ,
$config [ 'block_size' ]
);
2019-06-07 22:44:02 +02:00
2023-07-10 09:04:07 +02:00
if ( $length === 'null' ) {
$length = $config [ 'block_size' ];
}
2022-06-07 17:25:51 +02:00
if ( $get_events !== 0 ) {
2019-06-17 18:33:39 +02:00
try {
2019-06-18 19:17:21 +02:00
$fields = [
'te.id_evento' ,
'te.id_agente' ,
'te.id_usuario' ,
'te.id_grupo' ,
'te.estado' ,
'te.timestamp' ,
'te.evento' ,
'te.utimestamp' ,
'te.event_type' ,
'te.id_alert_am' ,
'te.criticity' ,
'te.tags' ,
'te.source' ,
'te.id_extra' ,
'te.critical_instructions' ,
'te.warning_instructions' ,
'te.unknown_instructions' ,
'te.owner_user' ,
2023-02-09 11:42:42 +01:00
'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp' ,
2019-06-18 19:17:21 +02:00
'te.custom_data' ,
2023-09-25 10:32:23 +02:00
'te.event_custom_id' ,
2019-06-18 19:17:21 +02:00
'te.data' ,
'te.module_status' ,
'ta.alias as agent_name' ,
'tg.nombre as group_name' ,
2021-07-07 16:07:08 +02:00
'ta.direccion' ,
2019-06-18 19:17:21 +02:00
];
2021-07-05 17:42:45 +02:00
2021-12-16 16:35:31 +01:00
$order = get_datatable_order ( true );
if ( is_array ( $order ) === true && $order [ 'field' ] === 'mini_severity' ) {
$order [ 'field' ] = 'te.criticity' ;
}
// Find the order field and set the table and field name.
foreach ( $fields as $field ) {
if ( str_contains ( $field , $order [ 'field' ]) === true ) {
2022-06-07 17:25:51 +02:00
switch ( $field ) {
case 'ta.alias as agent_name' :
$order [ 'field' ] = 'agent_name' ;
break ;
2023-02-09 11:42:42 +01:00
case 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp' :
2022-10-14 09:31:45 +02:00
$order [ 'field' ] = 'ack_utimestamp' ;
break ;
2022-06-07 17:25:51 +02:00
default :
$order [ 'field' ] = $field ;
break ;
}
continue ;
2021-12-16 16:35:31 +01:00
}
}
2022-06-01 17:27:44 +02:00
$fields [] = 'am.nombre as module_name' ;
$fields [] = 'am.id_agente_modulo as id_agentmodule' ;
$fields [] = 'am.custom_id as module_custom_id' ;
$fields [] = 'ta.server_name as server_name' ;
2019-06-18 19:17:21 +02:00
2019-06-17 18:33:39 +02:00
$events = events_get_all (
2019-06-19 12:56:16 +02:00
// Fields.
2019-06-18 19:17:21 +02:00
$fields ,
2019-06-19 12:56:16 +02:00
// Filter.
2019-06-17 18:33:39 +02:00
$filter ,
// Offset.
$start ,
// Limit.
$length ,
// Order.
$order [ 'direction' ],
// Sort field.
2019-06-19 12:56:16 +02:00
$order [ 'field' ],
// History.
2022-06-21 11:17:18 +02:00
$history ,
false ,
'' ,
false ,
$groupRecursion
2019-06-17 18:33:39 +02:00
);
2019-06-07 22:44:02 +02:00
2022-06-17 12:50:40 +02:00
$buffers = [];
2022-06-13 17:06:09 +02:00
if ( is_metaconsole () === false
|| ( is_metaconsole () === true
2022-09-29 09:17:37 +02:00
&& empty ( $filter [ 'server_id' ]) === false
&& is_array ( $filter [ 'server_id' ]) === false )
2022-06-13 17:06:09 +02:00
) {
2022-06-07 17:25:51 +02:00
$count = events_get_all (
'count' ,
$filter ,
null ,
null ,
null ,
null ,
2022-06-21 11:17:18 +02:00
$history ,
false ,
'' ,
false ,
$groupRecursion
2022-06-07 17:25:51 +02:00
);
if ( $count !== false ) {
$count = $count [ '0' ][ 'nitems' ];
}
} else {
2022-06-17 12:50:40 +02:00
$buffers = $events [ 'buffers' ];
2022-06-07 17:25:51 +02:00
$count = $events [ 'total' ];
$events = $events [ 'data' ];
2019-06-17 18:33:39 +02:00
}
2019-06-07 22:44:02 +02:00
2022-06-07 17:25:51 +02:00
if ( empty ( $events ) === false ) {
2023-05-05 13:04:02 +02:00
$redirection_form_id = 0 ;
2019-06-17 18:33:39 +02:00
$data = array_reduce (
$events ,
2023-11-08 15:29:14 +01:00
function ( $carry , $item ) use ( $table_id , & $redirection_form_id , $filter , $compact_date , $external_url , $compact_name_event , $regex ) {
2020-03-13 14:03:50 +01:00
global $config ;
2019-06-17 18:33:39 +02:00
$tmp = ( object ) $item ;
2019-09-30 13:31:15 +02:00
$tmp -> meta = is_metaconsole ();
2022-06-21 11:17:18 +02:00
2021-12-16 16:35:31 +01:00
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
2022-07-01 13:54:33 +02:00
$server_url = '' ;
$hashdata = '' ;
2021-12-16 16:35:31 +01:00
if ( $tmp -> meta === true ) {
2019-09-30 13:31:15 +02:00
if ( $tmp -> server_name !== null ) {
2022-06-28 16:56:25 +02:00
$data_server = metaconsole_get_servers (
2022-06-07 17:25:51 +02:00
$tmp -> server_id
);
2022-07-01 13:54:33 +02:00
// Url to go to node from meta.
if ( isset ( $data_server ) === true
&& $data_server !== false
) {
$server_url = $data_server [ 'server_url' ];
$hashdata = metaconsole_get_servers_url_hash (
$data_server
);
}
2019-09-30 13:31:15 +02:00
}
}
2024-01-17 12:25:57 +01:00
if ( isset ( $tmp -> server_name ) === true && strlen ( $tmp -> server_name ) >= 10 ) {
2023-07-28 10:39:46 +02:00
$tmp -> server_name = ui_print_truncate_text (
$tmp -> server_name ,
10 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2023-09-22 12:56:01 +02:00
$output_event_name = str_replace ( '"' , '' , io_safe_output ( $tmp -> evento ));
$tmp -> event_title = $output_event_name ;
$tmp -> b64 = base64_encode ( json_encode ( $tmp ));
$tmp -> evento = $output_event_name ;
2023-12-18 16:32:39 +01:00
$tmp -> event_force_title = ( strlen ( $output_event_name ) >= 300 ) ? substr ( $output_event_name , 0 , 300 ) . '...' : $output_event_name ;
2023-09-11 11:41:30 +02:00
if ( empty ( $tmp -> module_name ) === false ) {
$tmp -> module_name = ui_print_truncate_text (
$tmp -> module_name ,
'module_medium' ,
2023-07-28 10:39:46 +02:00
false ,
true ,
false ,
'…' ,
true ,
2022-06-07 17:25:51 +02:00
true ,
);
2019-07-29 08:59:56 +02:00
}
2023-12-13 19:53:14 +01:00
if ( empty ( $tmp -> tags ) === false ) {
$tmp -> tags = ui_print_truncate_text (
$tmp -> tags ,
30 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
if ( empty ( $tmp -> event_custom_id ) === false ) {
$tmp -> event_custom_id = ui_print_truncate_text (
$tmp -> event_custom_id ,
30 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
if ( empty ( $tmp -> module_custom_id ) === false ) {
$tmp -> module_custom_id = ui_print_truncate_text (
$tmp -> module_custom_id ,
30 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2022-06-07 17:25:51 +02:00
if ( empty ( $tmp -> comments ) === false ) {
2023-07-28 10:39:46 +02:00
$tmp -> comments = ui_print_comments ( $tmp -> comments , 20 );
2019-06-20 21:11:56 +02:00
}
2020-10-29 12:53:09 +01:00
// Show last event.
2022-06-07 17:25:51 +02:00
if ( isset ( $tmp -> max_id_evento ) === true
&& $tmp -> max_id_evento !== $tmp -> id_evento
) {
2020-10-29 12:53:09 +01:00
$max_event = db_get_row_sql (
sprintf (
2022-06-07 17:25:51 +02:00
' SELECT criticity ,
`timestamp`
FROM tevento
2020-10-29 12:53:09 +01:00
WHERE id_evento = % s ' ,
$tmp -> max_id_evento
)
);
2022-06-08 17:01:15 +02:00
if ( $max_event !== false
&& empty ( $max_event ) === false
) {
$tmp -> timestamp = $max_event [ 'timestamp' ];
$tmp -> criticity = $max_event [ 'criticity' ];
}
2020-10-29 12:53:09 +01:00
}
2023-09-11 11:41:30 +02:00
$tmp -> agent_name = ui_print_truncate_text (
$tmp -> agent_name ,
'agent_medium' ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
2023-07-28 10:39:46 +02:00
$tmp -> id_extra = io_safe_output ( $tmp -> id_extra );
if ( strlen ( $tmp -> id_extra ) >= 10 ) {
$tmp -> id_extra = ui_print_truncate_text (
$tmp -> id_extra ,
10 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2021-02-04 14:54:11 +01:00
2023-02-22 11:36:09 +01:00
$tmp -> ack_utimestamp_raw = $tmp -> ack_utimestamp ;
2021-02-04 14:54:11 +01:00
2019-06-18 17:40:31 +02:00
$tmp -> ack_utimestamp = ui_print_timestamp (
2023-02-01 14:56:30 +01:00
( empty ( $tmp -> ack_utimestamp ) === true ) ? 0 : $tmp -> ack_utimestamp ,
2019-06-18 17:40:31 +02:00
true
);
2023-02-01 16:57:48 +01:00
$user_timezone = users_get_user_by_id ( $_SESSION [ 'id_usuario' ])[ 'timezone' ];
2023-09-27 13:30:56 +02:00
if ( $compact_date === 1 ) {
$options = [ 'prominent' => 'compact' ];
} else {
$options = [];
}
2023-04-13 12:25:18 +02:00
if ( empty ( $user_timezone ) === true ) {
2023-12-20 13:54:20 +01:00
$user_timezone = $config [ 'timezone' ];
if ( empty ( $user_timezone ) === true ) {
$user_timezone = date_default_timezone_get ();
2023-04-13 12:25:18 +02:00
}
2023-02-01 16:57:48 +01:00
}
2023-12-20 13:54:20 +01:00
date_default_timezone_set ( $user_timezone );
$title = date ( $config [ 'date_format' ], $tmp -> utimestamp );
$value = ui_print_timestamp ( $tmp -> utimestamp , true , $options );
$last_contact_value = '<span title="' . $title . '">' . $value . '</span>' ;
2023-03-06 12:12:36 +01:00
$tmp -> timestamp = $last_contact_value ;
2019-06-18 17:40:31 +02:00
2021-06-08 16:09:37 +02:00
if ( is_numeric ( $tmp -> data ) === true ) {
$tmp -> data = format_numeric (
$tmp -> data ,
$config [ 'graph_precision' ]
);
2021-06-08 16:48:01 +02:00
} else {
$tmp -> data = ui_print_truncate_text ( $tmp -> data , 10 );
2021-06-08 16:09:37 +02:00
}
2019-06-25 12:49:17 +02:00
2023-11-29 10:27:55 +01:00
$tmp -> instructions = events_get_instructions ( $item , 15 );
2019-09-24 15:14:17 +02:00
2023-07-07 12:53:14 +02:00
$tmp -> user_comment = ui_print_comments (
event_get_last_comment (
$item ,
2023-07-10 16:26:33 +02:00
$filter
2023-07-07 12:53:14 +02:00
)
);
2022-06-21 11:17:18 +02:00
// Grouped events.
if ( isset ( $tmp -> max_id_evento ) === true
&& empty ( $tmp -> max_id_evento ) === false
) {
$tmp -> id_evento = $tmp -> max_id_evento ;
}
// Event severity prepared.
switch ( $tmp -> criticity ) {
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_CRITICAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'CRITICAL' );
$color = COL_CRITICAL ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_MAINTENANCE :
2022-06-21 11:17:18 +02:00
$text = __ ( 'MAINTENANCE' );
$color = COL_MAINTENANCE ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_INFORMATIONAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'INFORMATIONAL' );
$color = COL_INFORMATIONAL ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_MAJOR :
2022-06-21 11:17:18 +02:00
$text = __ ( 'MAJOR' );
$color = COL_MAJOR ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_MINOR :
2022-06-21 11:17:18 +02:00
$text = __ ( 'MINOR' );
$color = COL_MINOR ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_NORMAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'NORMAL' );
$color = COL_NORMAL ;
break ;
2023-02-22 12:35:34 +01:00
case EVENT_CRIT_WARNING :
2022-06-21 11:17:18 +02:00
$text = __ ( 'WARNING' );
$color = COL_WARNING ;
break ;
default :
$color = COL_UNKNOWN ;
$text = __ ( 'UNKNOWN' );
break ;
}
$output = '<div data-title="' ;
$output .= $text ;
$output .= '" data-use_title_for_force_title="1" ' ;
$output .= 'class="forced_title mini-criticity h100p" ' ;
$output .= ( 'style="background: ' . $color . '">' );
$output .= '</div>' ;
$tmp -> mini_severity = '<div class="event flex-row h100p nowrap">' ;
$tmp -> mini_severity .= $output ;
$tmp -> mini_severity .= '</div>' ;
2023-02-22 13:08:15 +01:00
$criticity = '<div class="criticity forced_title" style="background: ' ;
$criticity .= $color . '" data-title="' . $text . '" data-use_title_for_force_title="1">' . $text . '</div>' ;
2022-06-21 11:17:18 +02:00
$tmp -> criticity = $criticity ;
2023-10-10 15:15:43 +02:00
if ( isset ( $external_url ) === true && $external_url === true ) {
$url = ui_get_full_url ( 'index.php?sec=eventos&sec2=operation/events/events' );
$evn = '<a href="' . $url . '&show_event_dialog=' . $tmp -> b64 . '">' ;
} else {
// Add event severity to end of text.
$evn = '<a href="javascript:" onclick="show_event_dialog(\'' . $tmp -> b64 . '\')">' ;
}
2022-06-21 11:17:18 +02:00
2023-12-14 19:08:34 +01:00
$number = '' ;
2022-06-21 11:17:18 +02:00
// Grouped events.
2023-07-07 12:53:14 +02:00
if (( int ) $filter [ 'group_rep' ] === EVENT_GROUP_REP_EXTRAIDS ) {
2023-07-10 16:26:33 +02:00
$counter_extra_id = event_get_counter_extraId ( $item , $filter );
2023-07-19 13:28:53 +02:00
if ( empty ( $counter_extra_id ) === false && $counter_extra_id > 1 ) {
2023-12-14 19:08:34 +01:00
$number = '(' . $counter_extra_id . ') ' ;
2023-07-10 16:26:33 +02:00
}
} else {
if ( isset ( $tmp -> event_rep ) === true && $tmp -> event_rep > 1 ) {
2023-12-14 19:08:34 +01:00
$number = '(' . $tmp -> event_rep . ') ' ;
2023-07-10 16:26:33 +02:00
}
2022-06-21 11:17:18 +02:00
}
2023-12-14 19:08:34 +01:00
$tmp -> evento = $number . $tmp -> evento ;
$tmp -> evento = ui_print_truncate_text (
$tmp -> evento ,
( empty ( $compact_name_event ) === true ) ? 'description' : GENERIC_SIZE_TEXT ,
false ,
true ,
false ,
'…' ,
true ,
true ,
2023-12-18 16:32:39 +01:00
$tmp -> event_force_title
2023-12-14 19:08:34 +01:00
);
2022-06-21 11:17:18 +02:00
$evn .= $tmp -> evento . '</a>' ;
// Add event severity format to itself.
$tmp -> evento = $evn ;
// Grouped events.
if ( isset ( $item -> max_timestamp ) === true
&& ( $item -> max_timestamp ) === false
) {
$item -> timestamp = $item -> max_timestamp ;
}
// Event type prepared.
switch ( $tmp -> event_type ) {
2023-02-22 12:35:34 +01:00
case EVENTS_ALERT_FIRED :
case EVENTS_ALERT_RECOVERED :
case EVENTS_ALERT_CEASED :
case EVENTS_ALERT_MANUAL_VALIDATION :
2022-06-21 11:17:18 +02:00
$text = __ ( 'ALERT' );
$color = COL_ALERTFIRED ;
break ;
2023-02-22 12:35:34 +01:00
case EVENTS_RECON_HOST_DETECTED :
case EVENTS_SYSTEM :
case EVENTS_ERROR :
case EVENTS_NEW_AGENT :
case EVENTS_CONFIGURATION_CHANGE :
2022-06-21 11:17:18 +02:00
$text = __ ( 'SYSTEM' );
$color = COL_MAINTENANCE ;
break ;
2023-02-22 12:35:34 +01:00
case EVENTS_GOING_UP_WARNING :
case EVENTS_GOING_DOWN_WARNING :
2022-06-21 11:17:18 +02:00
$text = __ ( 'WARNING' );
$color = COL_WARNING ;
break ;
2023-02-22 12:35:34 +01:00
case EVENTS_GOING_DOWN_NORMAL :
case EVENTS_GOING_UP_NORMAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'NORMAL' );
$color = COL_NORMAL ;
break ;
2023-02-22 12:35:34 +01:00
case EVENTS_GOING_DOWN_CRITICAL :
case EVENTS_GOING_UP_CRITICAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'CRITICAL' );
$color = COL_CRITICAL ;
break ;
2023-02-22 12:35:34 +01:00
case EVENTS_UNKNOWN :
case EVENTS_GOING_UNKNOWN :
2022-06-21 11:17:18 +02:00
default :
$text = __ ( 'UNKNOWN' );
$color = COL_UNKNOWN ;
break ;
}
2023-07-03 12:13:27 +02:00
$tmp -> event_type = '<div class="mrgn_lft_25px">' . events_print_type_img ( $tmp -> event_type , true ) . '</div>' ;
2022-06-21 11:17:18 +02:00
// Module status.
// Event severity prepared.
switch ( $tmp -> module_status ) {
2023-02-22 12:35:34 +01:00
case AGENT_MODULE_STATUS_NORMAL :
2022-06-21 11:17:18 +02:00
$text = __ ( 'NORMAL' );
$color = COL_NORMAL ;
break ;
2023-02-22 12:35:34 +01:00
case AGENT_MODULE_STATUS_CRITICAL_BAD :
2022-06-21 11:17:18 +02:00
$text = __ ( 'CRITICAL' );
$color = COL_CRITICAL ;
break ;
2023-02-22 12:35:34 +01:00
case AGENT_MODULE_STATUS_NO_DATA :
2022-06-21 11:17:18 +02:00
$text = __ ( 'NOT INIT' );
$color = COL_NOTINIT ;
break ;
2023-02-22 12:35:34 +01:00
case AGENT_MODULE_STATUS_CRITICAL_ALERT :
case AGENT_MODULE_STATUS_NORMAL_ALERT :
case AGENT_MODULE_STATUS_WARNING_ALERT :
2022-06-21 11:17:18 +02:00
$text = __ ( 'ALERT' );
$color = COL_ALERTFIRED ;
break ;
2023-02-22 12:35:34 +01:00
case AGENT_MODULE_STATUS_WARNING :
2022-06-21 11:17:18 +02:00
$text = __ ( 'WARNING' );
$color = COL_WARNING ;
break ;
default :
$text = __ ( 'UNKNOWN' );
$color = COL_UNKNOWN ;
break ;
}
2023-02-22 13:08:15 +01:00
$module_status = '<div class="status_rounded_rectangles forced_title" style="background: ' ;
$module_status .= $color . '" data-title="' . $text . '" data-use_title_for_force_title="1"> </div>' ;
2022-06-21 11:17:18 +02:00
$tmp -> module_status = $module_status ;
// Status.
switch ( $tmp -> estado ) {
case EVENT_STATUS_NEW :
$img = html_print_image (
2023-02-09 16:13:30 +01:00
'images/star@svg.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'New event' ),
2023-03-17 13:20:58 +01:00
'class' => 'forced-title invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$state = 0 ;
break ;
case EVENT_STATUS_VALIDATED :
$state = 1 ;
$img = html_print_image (
2023-02-09 16:13:30 +01:00
'images/validate.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Event validated' ),
2023-02-09 16:13:30 +01:00
'class' => 'forced-title invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
break ;
case EVENT_STATUS_INPROCESS :
$state = 2 ;
$img = html_print_image (
2023-02-09 16:13:30 +01:00
'images/clock.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Event in process' ),
2023-02-22 13:08:15 +01:00
'class' => 'forced-title invert_filter height_20px' ,
2022-06-21 11:17:18 +02:00
]
);
break ;
default :
$img = html_print_image (
2023-02-09 16:13:30 +01:00
'images/star@svg.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Unknown' ),
2023-12-04 15:05:01 +01:00
'class' => 'forced-title main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$state = 0 ;
break ;
}
2023-12-11 17:01:40 +01:00
$draw_state = '<div class="content-status">' ;
2022-06-21 11:17:18 +02:00
$draw_state .= '<span class="invisible">' ;
$draw_state .= $state ;
$draw_state .= '</span>' ;
$draw_state .= $img ;
$draw_state .= '</div>' ;
$tmp -> estado = $draw_state ;
// Owner.
if ( empty ( $tmp -> owner_user ) === true ) {
$tmp -> owner_user = __ ( 'System' );
2022-09-16 11:04:01 +02:00
} else {
$tmp -> owner_user = get_user_fullname ( $tmp -> owner_user ) . ' (' . $tmp -> owner_user . ')' ;
2022-06-21 11:17:18 +02:00
}
2023-07-28 10:39:46 +02:00
if ( strlen ( $tmp -> owner_user ) >= 10 ) {
$tmp -> owner_user = ui_print_truncate_text (
$tmp -> owner_user ,
10 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2022-06-21 11:17:18 +02:00
// Group name.
if ( empty ( $tmp -> id_grupo ) === true ) {
$tmp -> id_grupo = __ ( 'All' );
} else {
$tmp -> id_grupo = $tmp -> group_name ;
}
2023-07-28 10:39:46 +02:00
if ( strlen ( $tmp -> id_grupo ) >= 10 ) {
$tmp -> id_grupo = ui_print_truncate_text (
$tmp -> id_grupo ,
10 ,
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2022-06-21 11:17:18 +02:00
// Module name.
$tmp -> id_agentmodule = $tmp -> module_name ;
2023-09-11 11:41:30 +02:00
/*
if ( strlen ( $tmp -> id_agentmodule ) >= 10 ) {
2023-07-28 10:39:46 +02:00
$tmp -> id_agentmodule = ui_print_truncate_text (
$tmp -> id_agentmodule ,
2023-09-11 11:41:30 +02:00
'module_small' ,
2023-07-28 10:39:46 +02:00
false ,
true ,
false ,
'…' ,
true ,
true ,
);
2023-09-11 11:41:30 +02:00
} */
2022-06-21 11:17:18 +02:00
// Options.
// Show more.
$tmp -> options = '<a href="javascript:" onclick="show_event_dialog(\'' . $tmp -> b64 . '\')">' ;
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/details.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Show more' ),
'class' => 'invert_filter' ,
]
);
$tmp -> options .= '</a>' ;
2022-06-22 10:29:19 +02:00
if ( isset ( $tmp -> server_id ) === false ) {
$tmp -> server_id = 0 ;
}
2022-06-21 11:17:18 +02:00
if (( int ) $tmp -> user_can_write === 1 ) {
if (( int ) $tmp -> estado !== 1 ) {
// Validate.
$tmp -> options .= '<a href="javascript:" onclick="validate_event(\'' . $table_id . '\',' ;
if ( isset ( $tmp -> max_id_evento ) === true
&& empty ( $tmp -> max_id_evento ) === false
) {
$id_val = $tmp -> max_id_evento ;
if ( is_metaconsole () === true ) {
$id_val .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> max_id_evento . ', ' ;
$tmp -> options .= $tmp -> event_rep . ', this, ' . $tmp -> server_id . ')"' ;
$tmp -> options .= ' id="val-' . $id_val . '">' ;
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/validate.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Validate events' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$tmp -> options .= '</a>' ;
} else {
$id_val = $tmp -> id_evento ;
if ( is_metaconsole () === true ) {
$id_val .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> id_evento . ', 0, this, ' ;
$tmp -> options .= $tmp -> server_id . ')" id="val-' . $id_val . '">' ;
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/validate.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Validate event' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$tmp -> options .= '</a>' ;
}
}
if (( int ) $tmp -> estado !== 2 ) {
// In process.
$tmp -> options .= '<a href="javascript:" onclick="in_process_event(\'' . $table_id . '\',' ;
if ( isset ( $tmp -> max_id_evento ) === true
&& empty ( $tmp -> max_id_evento ) === false
) {
$id_proc = $tmp -> max_id_evento ;
if ( is_metaconsole () === true ) {
$id_proc .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> max_id_evento . ', ' . $tmp -> event_rep . ', this, ' ;
$tmp -> options .= $tmp -> server_id . ')" id="proc-' . $id_proc . '">' ;
} else {
$id_proc = $tmp -> id_evento ;
if ( is_metaconsole () === true ) {
$id_proc .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> id_evento . ', 0, this, ' ;
$tmp -> options .= $tmp -> server_id . ')" id="proc-' . $id_proc . '">' ;
}
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/clock.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Change to in progress status' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$tmp -> options .= '</a>' ;
}
}
if (( int ) $tmp -> user_can_manage === 1 ) {
// Delete.
$tmp -> options .= '<a href="javascript:" onclick="delete_event(\'' . $table_id . '\',' ;
if ( isset ( $tmp -> max_id_evento ) === true
&& empty ( $tmp -> max_id_evento ) === false
) {
$id_del = $tmp -> max_id_evento ;
if ( is_metaconsole () === true ) {
$id_del .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> max_id_evento . ', ' . $tmp -> event_rep ;
$tmp -> options .= ', this, ' . $tmp -> server_id . ')" id="del-' . $id_del . '">' ;
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/delete.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Delete events' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$tmp -> options .= '</a>' ;
} else {
$id_del = $tmp -> id_evento ;
if ( is_metaconsole () === true ) {
$id_del .= '-' . $tmp -> server_id ;
}
$tmp -> options .= $tmp -> id_evento . ', 0, this, ' ;
$tmp -> options .= $tmp -> server_id . ')" id="del-' . $id_del . '">' ;
$tmp -> options .= html_print_image (
2023-02-09 16:13:30 +01:00
'images/delete.svg' ,
2022-06-21 11:17:18 +02:00
true ,
[
'title' => __ ( 'Delete event' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2022-06-21 11:17:18 +02:00
]
);
$tmp -> options .= '</a>' ;
}
}
// Multi select.
$value_checkbox = $tmp -> id_evento ;
if ( is_metaconsole () === true ) {
$value_checkbox .= '|' . $tmp -> server_id ;
}
$tmp -> m = '<input name="checkbox-multi[]" type="checkbox" value="' ;
$tmp -> m .= $value_checkbox . '" id="checkbox-multi-' . $tmp -> id_evento . '" ' ;
if ( isset ( $tmp -> max_id_evento ) === true
&& empty ( $tmp -> max_id_evento ) === false
) {
$tmp -> m .= ' event_rep="' . $tmp -> event_rep . '" ' ;
} else {
$tmp -> m .= ' event_rep="0" ' ;
}
$tmp -> m .= 'class="candeleted chk_val">' ;
// Url to agent view.
$url_link = ui_get_full_url (
'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='
);
$url_link_hash = '' ;
if ( $tmp -> meta === true ) {
$url_link = $server_url ;
$url_link .= '/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' ;
$url_link_hash = $hashdata ;
2023-05-05 13:04:02 +02:00
parse_str ( $url_link_hash , $url_hash_array );
2023-12-26 16:55:14 +01:00
$redirection_form = " <form id='agent-table-redirection- " . $redirection_form_id . " ' class='invisible' method='POST' action=' " . $url_link . $tmp -> id_agente . " '> " ;
2023-05-05 13:04:02 +02:00
$redirection_form .= html_print_input_hidden (
'loginhash' ,
$url_hash_array [ 'loginhash' ],
true
);
$redirection_form .= html_print_input_hidden (
'loginhash_data' ,
$url_hash_array [ 'loginhash_data' ],
true
);
$redirection_form .= html_print_input_hidden (
'loginhash_user' ,
$url_hash_array [ 'loginhash_user' ],
true
);
$redirection_form .= '</form>' ;
2022-06-21 11:17:18 +02:00
}
// Agent name link.
if ( $tmp -> id_agente > 0 ) {
2023-05-05 13:04:02 +02:00
if ( $tmp -> meta === true ) {
$draw_agent_name = $redirection_form ;
$draw_agent_name .= " <a target=_blank onclick='event.preventDefault(); document.getElementById( \" agent-table-redirection- " . $redirection_form_id . " \" ).submit();' href='#'> " ;
} else {
$draw_agent_name = '<a href="' . $url_link . $tmp -> id_agente . $url_link_hash . '">' ;
}
2023-06-28 09:35:49 +02:00
2022-06-21 11:17:18 +02:00
$draw_agent_name .= $tmp -> agent_name ;
$draw_agent_name .= '</a>' ;
$tmp -> agent_name = $draw_agent_name ;
} else {
$tmp -> agent_name = '' ;
}
// Agent ID link.
if ( $tmp -> id_agente > 0 ) {
2023-06-28 09:35:49 +02:00
if ( $tmp -> meta === true ) {
$draw_agent_id = " <a target=_blank onclick='event.preventDefault(); document.getElementById( \" agent-table-redirection- " . $redirection_form_id . " \" ).submit();' href='#'> " ;
$redirection_form_id ++ ;
} else {
$draw_agent_id = '<a href="' . $url_link . $tmp -> id_agente . $url_link_hash . '">' ;
}
2022-06-21 11:17:18 +02:00
$draw_agent_id .= $tmp -> id_agente ;
$draw_agent_id .= '</a>' ;
$tmp -> id_agente = $draw_agent_id ;
} else {
$tmp -> id_agente = '' ;
}
if ( empty ( $tmp -> custom_data ) === false ) {
$custom_data = json_decode ( io_safe_output ( $tmp -> custom_data ), true );
$custom_data_str = '' ;
if ( isset ( $custom_data ) === true && empty ( $custom_data ) === false ) {
foreach ( $custom_data as $key => $value ) {
2022-07-22 10:11:14 +02:00
$custom_data_str .= $key . ' = ' . $value . '<br>' ;
2022-06-21 11:17:18 +02:00
}
}
$tmp -> custom_data = $custom_data_str ;
2023-12-04 15:05:01 +01:00
if ( strlen ( $tmp -> custom_data ) >= 50 ) {
2023-07-28 10:39:46 +02:00
$tmp -> custom_data = ui_print_truncate_text (
$tmp -> custom_data ,
2023-12-04 15:05:01 +01:00
50 ,
2023-07-28 10:39:46 +02:00
false ,
true ,
false ,
'…' ,
true ,
true ,
);
}
2022-06-21 11:17:18 +02:00
}
2024-01-29 13:38:29 +01:00
$regex_validation = false ;
2023-11-08 15:24:47 +01:00
if ( empty ( $tmp ) === false && $regex !== '' ) {
foreach ( json_decode ( json_encode ( $tmp ), true ) as $key => $field ) {
2024-01-29 13:38:29 +01:00
if ( $key === 'b64' ) {
continue ;
}
$field = strip_tags ( $field );
2023-11-08 15:24:47 +01:00
if ( preg_match ( '/' . $regex . '/' , $field )) {
$regex_validation = true ;
}
}
2024-01-29 13:38:29 +01:00
if ( $regex_validation === true ) {
$carry [] = $tmp ;
2023-11-08 15:24:47 +01:00
}
2023-12-15 11:34:27 +01:00
} else {
2024-01-29 13:38:29 +01:00
$carry [] = $tmp ;
2023-12-11 17:01:40 +01:00
}
2024-01-29 13:38:29 +01:00
return $carry ;
2019-06-17 18:33:39 +02:00
}
);
}
2024-01-30 09:25:17 +01:00
if ( $regex !== '' ) {
$data = array_values (
array_filter (
( $data ? ? []),
function ( $item ) {
return ( bool ) ( array ) $item ;
}
)
);
}
2019-06-17 18:33:39 +02:00
// RecordsTotal && recordsfiltered resultados totales.
echo json_encode (
[
2024-01-29 13:38:29 +01:00
'data' => ( $data ? ? []),
'buffers' => $buffers ,
'recordsTotal' => $count ,
'recordsFiltered' => $count ,
'showAlwaysPagination' => ( empty ( $regex ) === false ) ? true : false ,
2019-06-17 18:33:39 +02:00
]
);
} catch ( Exception $e ) {
echo json_encode (
[ 'error' => $e -> getMessage ()]
2019-06-07 22:44:02 +02:00
);
}
}
// AJAX section ends.
2023-10-19 17:06:01 +02:00
return ;
2019-06-07 22:44:02 +02:00
}
2019-07-09 17:54:23 +02:00
/*
* Load user default form .
*/
2021-04-21 13:05:18 +02:00
$load_filter_id = ( int ) get_parameter ( 'filter_id' , 0 );
2023-02-23 09:48:13 +01:00
$fav_menu = [];
2021-04-21 13:05:18 +02:00
if ( $load_filter_id === 0 ) {
// Load user filter.
2023-05-22 12:08:27 +02:00
if ( is_metaconsole () === true ) {
$loaded_filter = db_get_row_sql (
sprintf (
' SELECT f . id_filter , f . id_name
FROM tevent_filter f
INNER JOIN tusuario u
ON u . metaconsole_default_event_filter = f . id_filter
WHERE u . id_user = " %s " ' ,
$config [ 'id_user' ]
)
);
} else {
$loaded_filter = db_get_row_sql (
sprintf (
' SELECT f . id_filter , f . id_name
FROM tevent_filter f
INNER JOIN tusuario u
ON u . default_event_filter = f . id_filter
WHERE u . id_user = " %s " ' ,
$config [ 'id_user' ]
)
);
}
2021-04-21 13:05:18 +02:00
} else {
// Load filter selected by user.
$loaded_filter [ 'id_filter' ] = $load_filter_id ;
$loaded_filter [ 'id_name' ] = db_get_value (
'id_name' ,
'tevent_filter' ,
'id_filter' ,
$load_filter_id
);
2023-02-23 09:48:13 +01:00
// Fav menu
$fav_menu = [
'id_element' => $load_filter_id ,
'url' => 'operation/events/events&pure=&load_filter=1&filter_id=' . $load_filter_id ,
'label' => $loaded_filter [ 'id_name' ],
'section' => 'Events' ,
];
2021-04-21 13:05:18 +02:00
}
2020-03-24 10:12:14 +01:00
2020-10-29 15:06:01 +01:00
// Do not load the user filter if we come from the 24h event graph.
2022-06-01 17:27:44 +02:00
$from_event_graph = get_parameter ( 'filter[from_event_graph]' , ( $filter [ 'from_event_graph' ] ? ? '' ));
2022-04-11 15:22:37 +02:00
if ( $loaded_filter !== false && $from_event_graph != 1 && isset ( $fb64 ) === false ) {
2021-04-21 13:05:18 +02:00
$filter = events_get_event_filter ( $loaded_filter [ 'id_filter' ]);
2019-07-09 17:54:23 +02:00
if ( $filter !== false ) {
$id_group = $filter [ 'id_group' ];
$event_type = $filter [ 'event_type' ];
$severity = $filter [ 'severity' ];
$status = $filter [ 'status' ];
$search = $filter [ 'search' ];
2023-11-29 11:14:40 +01:00
$regex = $filter [ 'regex' ];
2022-11-18 14:04:54 +01:00
$not_search = $filter [ 'not_search' ];
2019-07-09 17:54:23 +02:00
$text_agent = $filter [ 'text_agent' ];
$id_agent = $filter [ 'id_agent' ];
$id_agent_module = $filter [ 'id_agent_module' ];
2020-10-29 15:06:01 +01:00
$text_module = io_safe_output (
db_get_value_filter (
'nombre' ,
'tagente_modulo' ,
[ 'id_agente_modulo' => $filter [ 'id_agent_module' ]]
)
);
2019-07-09 17:54:23 +02:00
$pagination = $filter [ 'pagination' ];
$event_view_hr = $filter [ 'event_view_hr' ];
$id_user_ack = $filter [ 'id_user_ack' ];
2022-11-03 12:00:58 +01:00
$owner_user = $filter [ 'owner_user' ];
2019-07-09 17:54:23 +02:00
$group_rep = $filter [ 'group_rep' ];
$tag_with = json_decode ( io_safe_output ( $filter [ 'tag_with' ]));
$tag_without = json_decode ( io_safe_output ( $filter [ 'tag_without' ]));
$tag_with_base64 = base64_encode ( json_encode ( $tag_with ));
$tag_without_base64 = base64_encode ( json_encode ( $tag_without ));
$filter_only_alert = $filter [ 'filter_only_alert' ];
2022-07-05 17:02:40 +02:00
$search_secondary_groups = ( $filter [ 'search_secondary_groups' ] ? ? 0 );
2023-08-07 14:43:50 +02:00
$private_filter_event = ( $filter [ 'private_filter_user' ] ? ? 0 );
2022-09-29 12:54:46 +02:00
$search_recursive_groups = ( $filter [ 'search_recursive_groups' ] ? ? 0 );
2019-07-09 17:54:23 +02:00
$id_group_filter = $filter [ 'id_group_filter' ];
$date_from = $filter [ 'date_from' ];
2021-07-05 17:42:45 +02:00
$time_from = $filter [ 'time_from' ];
2019-07-09 17:54:23 +02:00
$date_to = $filter [ 'date_to' ];
2021-07-05 17:42:45 +02:00
$time_to = $filter [ 'time_to' ];
2019-07-09 17:54:23 +02:00
$source = $filter [ 'source' ];
$id_extra = $filter [ 'id_extra' ];
$user_comment = $filter [ 'user_comment' ];
2021-07-05 17:42:45 +02:00
$id_source_event = ( $filter [ 'id_source_event' ] ? ? '' );
2022-11-22 11:35:38 +01:00
$server_id = '' ;
if ( empty ( $filter [ 'server_id' ]) === false ) {
if ( is_array ( $server_id ) === false ) {
if ( is_numeric ( $server_id ) === true ) {
if ( $server_id !== 0 ) {
$server_id = [ $filter [ 'server_id' ]];
} else {
$server_id = array_keys ( $servers );
}
} else {
$server_id = explode ( ',' , $filter [ 'server_id' ]);
}
}
}
2022-03-29 18:09:19 +02:00
$custom_data = $filter [ 'custom_data' ];
$custom_data_filter_type = $filter [ 'custom_data_filter_type' ];
2019-07-09 17:54:23 +02:00
}
}
2019-06-07 17:35:13 +02:00
// TAGS.
2019-06-07 21:22:07 +02:00
// Get the tags where the user have permissions in Events reading tasks.
$tags = tags_get_user_tags ( $config [ 'id_user' ], $access );
2019-06-07 17:35:13 +02:00
$tags_select_with = [];
$tags_select_without = [];
$tag_with_temp = [];
$tag_without_temp = [];
2020-09-18 11:47:50 +02:00
if ( is_array ( $tag_with ) === false ) {
$tag_with = json_decode ( base64_decode ( $tag_with ), true );
}
if ( is_array ( $tag_without ) === false ) {
$tag_without = json_decode ( base64_decode ( $tag_without ), true );
}
2020-09-04 12:38:46 +02:00
2021-12-16 16:35:31 +01:00
foreach (( array ) $tags as $id_tag => $tag ) {
2020-09-07 14:38:43 +02:00
if ( is_array ( $tag_with ) === true
&& (( array_search ( $id_tag , $tag_with ) === false ) || ( array_search ( $id_tag , $tag_with ) === null ))
2019-06-07 17:35:13 +02:00
) {
2023-04-12 11:02:35 +02:00
$tags_select_with [ $id_tag ] = $tag ;
2019-06-07 17:35:13 +02:00
} else {
2023-04-12 11:02:35 +02:00
$tag_with_temp [ $id_tag ] = $tag ;
2019-06-07 17:35:13 +02:00
}
2020-09-07 14:38:43 +02:00
if ( is_array ( $tag_without ) === true
&& (( array_search ( $id_tag , $tag_without ) === false ) || ( array_search ( $id_tag , $tag_without ) === null ))
2019-06-07 17:35:13 +02:00
) {
2023-04-12 11:02:35 +02:00
$tags_select_without [ $id_tag ] = $tag ;
2019-06-07 17:35:13 +02:00
} else {
2023-04-12 11:02:35 +02:00
$tag_without_temp [ $id_tag ] = $tag ;
2019-06-07 17:35:13 +02:00
}
}
$add_with_tag_disabled = empty ( $tags_select_with );
$remove_with_tag_disabled = empty ( $tag_with_temp );
$add_without_tag_disabled = empty ( $tags_select_without );
$remove_without_tag_disabled = empty ( $tag_without_temp );
$tabletags_with = html_get_predefined_table ( 'transparent' , 2 );
$tabletags_with -> id = 'filter_events_tags_with' ;
$tabletags_with -> width = '100%' ;
$tabletags_with -> cellspacing = 4 ;
$tabletags_with -> cellpadding = 4 ;
$tabletags_with -> class = 'noshadow' ;
$tabletags_with -> styleTable = 'border: 0px;' ;
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2019-06-07 17:35:13 +02:00
$tabletags_with -> class = 'nobady' ;
$tabletags_with -> cellspacing = 0 ;
$tabletags_with -> cellpadding = 0 ;
}
$data = [];
$data [ 0 ] = html_print_select (
$tags_select_with ,
'select_with' ,
'' ,
'' ,
'' ,
0 ,
true ,
true ,
true ,
2022-05-31 17:09:15 +02:00
'select_tags' ,
2023-04-12 11:02:35 +02:00
false ,
false ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
25
2019-06-07 17:35:13 +02:00
);
$data [ 1 ] = html_print_image (
'images/darrowright.png' ,
true ,
[
'id' => 'button-add_with' ,
'style' => 'cursor: pointer;' ,
'title' => __ ( 'Add' ),
2021-03-11 15:40:23 +01:00
'class' => 'invert_filter' ,
2019-06-07 17:35:13 +02:00
]
);
$data [ 1 ] .= html_print_input_hidden (
'tag_with' ,
2022-06-01 17:27:44 +02:00
( $tag_with_base64 ? ? '' ),
2019-06-07 17:35:13 +02:00
true
);
$data [ 1 ] .= '<br><br>' . html_print_image (
'images/darrowleft.png' ,
true ,
[
'id' => 'button-remove_with' ,
'style' => 'cursor: pointer;' ,
'title' => __ ( 'Remove' ),
2021-03-11 15:40:23 +01:00
'class' => 'invert_filter' ,
2019-06-07 17:35:13 +02:00
]
);
$data [ 2 ] = html_print_select (
$tag_with_temp ,
'tag_with_temp' ,
[],
'' ,
'' ,
0 ,
true ,
true ,
true ,
2022-05-31 17:09:15 +02:00
'select_tags' ,
2023-04-12 11:02:35 +02:00
false ,
false ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
25
2019-06-07 17:35:13 +02:00
);
$tabletags_with -> data [] = $data ;
$tabletags_with -> rowclass [] = '' ;
$tabletags_without = html_get_predefined_table ( 'transparent' , 2 );
$tabletags_without -> id = 'filter_events_tags_without' ;
$tabletags_without -> width = '100%' ;
$tabletags_without -> cellspacing = 4 ;
$tabletags_without -> cellpadding = 4 ;
$tabletags_without -> class = 'noshadow' ;
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2019-06-07 17:35:13 +02:00
$tabletags_without -> class = 'nobady' ;
$tabletags_without -> cellspacing = 0 ;
$tabletags_without -> cellpadding = 0 ;
}
$tabletags_without -> styleTable = 'border: 0px;' ;
$data = [];
$data [ 0 ] = html_print_select (
$tags_select_without ,
'select_without' ,
'' ,
'' ,
'' ,
0 ,
true ,
true ,
true ,
2022-05-31 17:09:15 +02:00
'select_tags' ,
2023-04-12 11:02:35 +02:00
false ,
false ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
25
2019-06-07 17:35:13 +02:00
);
$data [ 1 ] = html_print_image (
'images/darrowright.png' ,
true ,
[
'id' => 'button-add_without' ,
'style' => 'cursor: pointer;' ,
'title' => __ ( 'Add' ),
2021-03-11 15:40:23 +01:00
'class' => 'invert_filter' ,
2019-06-07 17:35:13 +02:00
]
);
$data [ 1 ] .= html_print_input_hidden (
'tag_without' ,
2022-06-01 17:27:44 +02:00
( $tag_without_base64 ? ? '' ),
2019-06-07 17:35:13 +02:00
true
);
$data [ 1 ] .= '<br><br>' . html_print_image (
'images/darrowleft.png' ,
true ,
[
'id' => 'button-remove_without' ,
'style' => 'cursor: pointer;' ,
'title' => __ ( 'Remove' ),
2021-03-11 15:40:23 +01:00
'class' => 'invert_filter' ,
2019-06-07 17:35:13 +02:00
]
);
$data [ 2 ] = html_print_select (
$tag_without_temp ,
'tag_without_temp' ,
[],
'' ,
'' ,
0 ,
true ,
true ,
true ,
2022-05-31 17:09:15 +02:00
'select_tags' ,
2023-04-12 11:02:35 +02:00
false ,
false ,
false ,
false ,
false ,
'' ,
false ,
false ,
false ,
25
2019-06-07 17:35:13 +02:00
);
$tabletags_without -> data [] = $data ;
$tabletags_without -> rowclass [] = '' ;
2019-06-06 17:50:47 +02:00
if ( io_safe_output ( $tag_with ) == '["0"]' ) {
$tag_with = '[]' ;
2012-12-14 09:26:50 +01:00
}
2019-06-06 17:50:47 +02:00
if ( io_safe_output ( $tag_without ) == '["0"]' ) {
$tag_without = '[]' ;
}
2015-03-18 17:57:04 +01:00
2019-06-07 21:22:07 +02:00
/*
* END OF TAGS .
*/
2019-06-06 17:50:47 +02:00
// View.
$pure = get_parameter ( 'pure' , 0 );
$url = ui_get_full_url ( 'index.php?sec=eventos&sec2=operation/events/events' );
2012-06-15 12:46:40 +02:00
2019-06-06 17:50:47 +02:00
// Concatenate parameters.
$url .= '' ;
2019-04-29 15:04:14 +02:00
2019-06-18 19:17:21 +02:00
if ( $pure ) {
2019-06-06 17:50:47 +02:00
// Fullscreen.
// Floating menu - Start.
2021-03-11 15:40:23 +01:00
echo '<div id="vc-controls" class="zindex999"">' ;
2019-04-29 15:04:14 +02:00
2023-03-28 12:39:02 +02:00
echo '<div id="menu_tab" class="menu_tab_pure">' ;
2019-06-06 17:50:47 +02:00
echo '<ul class="mn">' ;
2019-04-29 15:04:14 +02:00
2019-06-06 17:50:47 +02:00
// Quit fullscreen.
echo '<li class="nomn">' ;
echo '<a target="_top" href="' . $url . '&pure=0">' ;
echo html_print_image (
2023-02-09 16:13:30 +01:00
'images/exit_fullscreen@svg.svg' ,
2019-06-06 17:50:47 +02:00
true ,
2021-03-11 15:40:23 +01:00
[
'title' => __ ( 'Back to normal mode' ),
'class' => 'invert_filter' ,
]
2019-04-29 15:04:14 +02:00
);
2019-06-06 17:50:47 +02:00
echo '</a>' ;
echo '</li>' ;
2014-10-07 16:33:54 +02:00
2019-06-06 17:50:47 +02:00
// Countdown.
echo '<li class="nomn">' ;
2019-08-19 11:36:13 +02:00
echo '<div class="events-refr">' ;
echo '<div class="events-countdown"><span id="refrcounter"></span></div>' ;
echo '<div id="events-refr-form">' ;
2019-06-06 17:50:47 +02:00
echo __ ( 'Refresh' ) . ':' ;
echo html_print_select (
get_refresh_time_array (),
'refresh' ,
$refr ,
'' ,
'' ,
0 ,
true ,
false ,
false
2019-03-25 12:53:50 +01:00
);
2019-06-06 17:50:47 +02:00
echo '</div>' ;
echo '</div>' ;
echo '</li>' ;
2013-01-31 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/jquery-ui-1.10.0.custom.css,
include/styles/images/ui-*,
include/javascript/jquery.jquery-ui-1.10.0.custom.js,
include/javascript/jquery-1.9.0.js: added the last version of
jquery and jqueryUI.
* godmode/reporting/visual_console_builder.editor.js,
include/ajax/events.php, include/functions_events.php,
include/functions_reporting.php,
include/javascript/pandora_events.js,
include/javascript/jquery.scrollTo.js,
include/javascript/jquery.tablesorter.pager.js,
include/javascript/jquery.tablesorter.js, include/functions_ui.php,
extensions/update_manager/lib/functions.php,
extensions/update_manager/main.php, extensions/agents_alerts.php,
operation/events/events.php, general/login_page.php,
general/logoff.php, general/header.php,
general/login_help_dialog.php: fixes about the new jquery and
jqueryUI version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7554 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-31 17:49:08 +01:00
2019-06-06 17:50:47 +02:00
// Console name.
echo '<li class="nomn">' ;
echo '<div class="vc-title">' . __ ( 'Event viewer' ) . '</div>' ;
echo '</li>' ;
2015-05-22 13:10:05 +02:00
2019-06-06 17:50:47 +02:00
echo '</ul>' ;
echo '</div>' ;
2015-05-22 13:10:05 +02:00
2019-06-06 17:50:47 +02:00
echo '</div>' ;
// Floating menu - End.
ui_require_jquery_file ( 'countdown' );
} else {
// Header.
2019-01-30 16:18:44 +01:00
$pss = get_user_info ( $config [ 'id_user' ]);
$hashup = md5 ( $config [ 'id_user' ] . $pss [ 'password' ]);
2019-03-25 12:53:50 +01:00
// Fullscreen.
2019-01-30 16:18:44 +01:00
$fullscreen [ 'active' ] = false ;
2021-03-11 15:40:23 +01:00
$fullscreen [ 'text' ] = '<a class="events_link" href="' . $url . '&pure=1&">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/fullscreen@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Full screen' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2019-03-25 12:53:50 +01:00
// Event list.
2019-01-30 16:18:44 +01:00
$list [ 'active' ] = false ;
2021-03-11 15:40:23 +01:00
$list [ 'text' ] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&pure=' . $config [ 'pure' ] . '&">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/event.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Event list' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2019-03-25 12:53:50 +01:00
// History event list.
2019-01-30 16:18:44 +01:00
$history_list [ 'active' ] = false ;
2021-03-11 15:40:23 +01:00
$history_list [ 'text' ] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&pure=' . $config [ 'pure' ] . '&section=history&history=1&">' . html_print_image (
'images/books.png' ,
true ,
[
'title' => __ ( 'History event list' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2019-03-25 12:53:50 +01:00
// RSS.
2019-01-30 16:18:44 +01:00
$rss [ 'active' ] = false ;
2021-03-11 15:40:23 +01:00
$rss [ 'text' ] = '<a class="events_link" href="operation/events/events_rss.php?user=' . $config [ 'id_user' ] . '&hashup=' . $hashup . '&">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/rrs@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'RSS Events' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2019-03-25 12:53:50 +01:00
// CSV.
2019-01-30 16:18:44 +01:00
$csv [ 'active' ] = false ;
2022-12-02 09:42:24 +01:00
$csv [ 'text' ] = '<a class="events_link" onclick="blockResubmit($(this))" href="' . ui_get_full_url ( false , false , false , false ) . 'operation/events/export_csv.php?' . ( $filter_b64 ? ? '' ) . '">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/file-csv.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Export to CSV file' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2023-05-30 17:17:34 +02:00
// Acoustic console.
2019-01-30 16:18:44 +01:00
$sound_event [ 'active' ] = false ;
2023-07-24 12:25:06 +02:00
if ( is_metaconsole () === true ) {
$urlSound = '../../include/sounds/' ;
} else {
$urlSound = 'include/sounds/' ;
}
2023-01-27 12:37:25 +01:00
// Sound Events.
$data_sound = base64_encode (
json_encode (
[
'title' => __ ( 'Sound Console' ),
'start' => __ ( 'Start' ),
'stop' => __ ( 'Stop' ),
'noAlert' => __ ( 'No alert' ),
'silenceAlarm' => __ ( 'Silence alarm' ),
'url' => ui_get_full_url ( 'ajax.php' ),
'page' => 'include/ajax/events' ,
2023-07-24 12:25:06 +02:00
'urlSound' => $urlSound ,
2023-01-27 12:37:25 +01:00
]
)
);
$sound_event [ 'text' ] = '<a href="javascript: openSoundEventModal(`' . $data_sound . '`);">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/sound_console@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
2023-05-30 17:17:34 +02:00
'title' => __ ( 'Acoustic console' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
2023-07-27 10:47:51 +02:00
echo '<input type="hidden" id="open_sound_event_modal" value="0" /> ' ;
2019-03-25 12:53:50 +01:00
// If the user has administrator permission display manage tab.
2022-10-19 16:20:49 +02:00
if ( $event_w === true || $event_m === true ) {
2019-03-25 12:53:50 +01:00
// Manage events.
2019-01-30 16:18:44 +01:00
$manage_events [ 'active' ] = false ;
2021-03-11 15:40:23 +01:00
$manage_events [ 'text' ] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=filter&pure=' . $config [ 'pure' ] . '">' . html_print_image (
2023-02-09 16:13:30 +01:00
'images/configuration@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Manage events' ),
2023-02-09 16:13:30 +01:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ;
2019-01-30 16:18:44 +01:00
$manage_events [ 'godmode' ] = true ;
$onheader = [
'manage_events' => $manage_events ,
'fullscreen' => $fullscreen ,
'list' => $list ,
'history' => $history_list ,
'rss' => $rss ,
'csv' => $csv ,
'sound_event' => $sound_event ,
];
} else {
$onheader = [
'fullscreen' => $fullscreen ,
'list' => $list ,
'history' => $history_list ,
'rss' => $rss ,
'csv' => $csv ,
'sound_event' => $sound_event ,
];
}
2019-06-06 17:50:47 +02:00
// If the history event is not enabled, dont show the history tab.
2022-09-30 08:56:19 +02:00
if ( isset ( $config [ 'history_db_enabled' ]) === false
|| ( bool ) $config [ 'history_db_enabled' ] === false
) {
2019-01-30 16:18:44 +01:00
unset ( $onheader [ 'history' ]);
}
switch ( $section ) {
case 'sound_event' :
$onheader [ 'sound_event' ][ 'active' ] = true ;
2023-05-30 17:17:34 +02:00
$section_string = __ ( 'Acoustic console' );
2019-01-30 16:18:44 +01:00
break ;
case 'history' :
$onheader [ 'history' ][ 'active' ] = true ;
$section_string = __ ( 'History' );
break ;
default :
$onheader [ 'list' ][ 'active' ] = true ;
$section_string = __ ( 'List' );
break ;
}
2023-02-28 09:50:42 +01:00
if ( is_metaconsole () === true ) {
unset ( $onheader [ 'rss' ]);
unset ( $onheader [ 'sound_event' ]);
unset ( $onheader [ 'fullscreen' ]);
}
2019-01-30 16:18:44 +01:00
unset ( $onheader [ 'history' ]);
2022-06-03 12:26:15 +02:00
ui_print_standard_header (
__ ( 'Events list' ),
2023-02-09 16:13:30 +01:00
'images/event.svg' ,
2019-01-30 16:18:44 +01:00
false ,
'eventview' ,
false ,
2022-06-03 12:26:15 +02:00
( array ) $onheader ,
[
[
'link' => '' ,
'label' => __ ( 'Events' ),
],
2023-02-23 09:48:13 +01:00
],
$fav_menu
2019-01-30 16:18:44 +01:00
);
2008-07-25 20:37:32 +02:00
}
2007-02-05 18:45:14 +01:00
2021-05-28 14:32:41 +02:00
if ( enterprise_installed () === true ) {
if ( isset ( $config [ 'merge_process_events' ]) === true
&& empty ( $config [ 'merge_process_events' ]) === false
) {
ui_require_css_file ( 'command_center' , ENTERPRISE_DIR . '/include/styles/' );
ui_require_javascript_file (
'pandora_command_center' ,
ENTERPRISE_DIR . '/include/javascript/'
);
2021-07-07 16:11:20 +02:00
$commandCenter = 'CommandCenterController' ;
if ( class_exists ( $commandCenter ) === true ) {
$events_merge_state = $commandCenter :: displayEventsProgress ();
if ( empty ( $events_merge_state ) === false ) {
echo '<div class="view_events_merge_process_events">' ;
echo $events_merge_state ;
echo '</div>' ;
}
}
2021-05-28 14:32:41 +02:00
$tittle_error = __ ( 'Errors' );
echo '<div id="dialog-error-node-' . $config [ 'metaconsole_node_id' ] . '" title="' . $tittle_error . '"></div>' ;
}
2021-05-24 17:35:15 +02:00
}
2019-03-25 12:53:50 +01:00
// Error div for ajax messages.
2021-07-05 17:42:45 +02:00
html_print_div (
[
'id' => 'show_message_error' ,
'content' => '' ,
]
);
2012-06-15 12:46:40 +02:00
2021-08-13 15:57:01 +02:00
if ( enterprise_hook (
'enterprise_acl' ,
[
$config [ 'id_user' ],
'eventos' ,
'execute_event_responses' ,
]
2023-11-29 11:55:59 +01:00
) === false && enterprise_hook (
'enterprise_acl' ,
[
$config [ 'id_user' ],
'eventos' ,
'operation/events/events' ,
]
2021-08-13 15:57:01 +02:00
) === false
) {
$readonly = true ;
}
2019-06-07 17:35:13 +02:00
/*
* Load filter form .
*/
2023-08-28 13:54:35 +02:00
// User private filter process.
$inputs [] = html_print_input_hidden ( 'id_filter_event' , $load_filter_id , true );
2019-06-06 17:50:47 +02:00
// Group.
2022-07-15 11:38:46 +02:00
if ( $id_group === null ) {
$id_group = 0 ;
2020-10-29 10:24:37 +01:00
}
2020-09-11 14:34:41 +02:00
$data = html_print_input (
[
'name' => 'id_group_filter' ,
2020-09-11 15:30:18 +02:00
'returnAllGroup' => true ,
2020-09-11 14:34:41 +02:00
'privilege' => 'AR' ,
'type' => 'select_groups' ,
2022-07-15 11:38:46 +02:00
'selected' => $id_group ,
2020-09-11 15:30:18 +02:00
'nothing' => false ,
2020-09-11 14:34:41 +02:00
'return' => true ,
2023-02-24 10:04:23 +01:00
'size' => '100%' ,
2020-09-11 14:34:41 +02:00
]
2019-06-06 17:50:47 +02:00
);
$in = '<div class="filter_input"><label>' . __ ( 'Group' ) . '</label>' ;
2023-02-24 10:04:23 +01:00
$in .= $data ;
// Search recursive groups.
$data = html_print_checkbox_switch (
'search_recursive_groups' ,
$search_recursive_groups ,
$search_recursive_groups ,
true ,
false ,
'checked_slide_events(this);' ,
true
);
$in_group = '<div class="display-initial">' ;
$in_group .= $data ;
2023-09-04 10:03:53 +02:00
$in_group .= '<label class="vert-align-bottom pdd_r_15px">' ;
2023-02-24 10:04:23 +01:00
$in_group .= __ ( 'Group recursion' );
$in_group .= ui_print_help_tip (
__ ( 'WARNING: This could cause a performace impact.' ),
true
);
$in_group .= '</label>' ;
$in .= $in_group ;
// Search secondary groups.
$data = html_print_checkbox_switch (
'search_secondary_groups' ,
$search_secondary_groups ,
$search_secondary_groups ,
true ,
false ,
'checked_slide_events(this);' ,
true
);
$in_sec_group .= $data ;
$in_sec_group .= '<label class="vert-align-bottom">' ;
$in_sec_group .= __ ( 'Search in secondary groups' );
$in_sec_group .= ui_print_help_tip (
__ ( 'WARNING: This could cause a performace impact.' ),
true
);
$in_sec_group .= '</label>' ;
$in_sec_group .= '</div>' ;
$in .= $in_sec_group ;
$in .= '</div>' ;
2019-06-06 17:50:47 +02:00
$inputs [] = $in ;
// Event type.
$types = get_event_types ();
$types [ 'not_normal' ] = __ ( 'Not normal' );
$data = html_print_select (
$types ,
'event_type' ,
$event_type ,
'' ,
__ ( 'All' ),
'' ,
true
);
$in = '<div class="filter_input"><label>' . __ ( 'Event type' ) . '</label>' ;
$in .= $data . '</div>' ;
$inputs [] = $in ;
// Event status.
$data = html_print_select (
events_get_all_status (),
'status' ,
$status ,
'' ,
'' ,
'' ,
true
);
$in = '<div class="filter_input"><label>' . __ ( 'Event status' ) . '</label>' ;
$in .= $data . '</div>' ;
$inputs [] = $in ;
2012-10-09 18:05:32 +02:00
2019-06-06 17:50:47 +02:00
// Max hours old.
$data = html_print_input_text (
'event_view_hr' ,
$event_view_hr ,
'' ,
5 ,
255 ,
true
);
$in = '<div class="filter_input"><label>' . __ ( 'Max. hours old' ) . '</label>' ;
$in .= $data . '</div>' ;
$inputs [] = $in ;
// Duplicates group { events | agents }.
$data = html_print_select (
[
2022-09-27 15:08:09 +02:00
EVENT_GROUP_REP_ALL => __ ( 'All events' ),
EVENT_GROUP_REP_EVENTS => __ ( 'Group events' ),
EVENT_GROUP_REP_AGENTS => __ ( 'Group agents' ),
EVENT_GROUP_REP_EXTRAIDS => __ ( 'Group extra id' ),
2019-06-06 17:50:47 +02:00
],
'group_rep' ,
$group_rep ,
'' ,
'' ,
0 ,
true
);
$in = '<div class="filter_input"><label>' . __ ( 'Repeated' ) . '</label>' ;
$in .= $data . '</div>' ;
$inputs [] = $in ;
2019-06-18 17:40:31 +02:00
// Free search.
$data = html_print_input_text ( 'search' , $search , '' , '' , 255 , true );
2023-02-24 10:04:23 +01:00
2022-11-18 14:04:54 +01:00
// Search recursive groups.
2023-02-24 10:04:23 +01:00
$data .= '<div class="display-initial">' ;
2022-11-18 14:04:54 +01:00
$data .= html_print_checkbox_switch (
'not_search' ,
$not_search ,
$not_search ,
true ,
false ,
'checked_slide_events(this);' ,
true
);
2023-02-24 10:04:23 +01:00
$data .= ui_print_help_tip (
__ ( 'Search for elements NOT containing given text.' ),
true
);
$data .= '</div>' ;
2022-11-18 14:04:54 +01:00
$in = '<div class="filter_input filter_input_not_search"><label>' . __ ( 'Free search' ) . '</label>' ;
2022-12-13 09:30:56 +01:00
$in .= $data ;
$in .= '</div>' ;
2019-06-06 17:50:47 +02:00
$inputs [] = $in ;
2022-04-11 15:22:37 +02:00
if ( is_array ( $severity ) === false ) {
if ( empty ( $severity ) === true && $severity !== '0' ) {
$severity = - 1 ;
} else {
$severity = explode ( ',' , $severity );
}
2020-01-13 18:24:29 +01:00
}
// Criticity - severity.
$data = html_print_select (
get_priorities (),
'severity' ,
2022-04-11 15:22:37 +02:00
$severity ,
2020-01-13 18:24:29 +01:00
'' ,
__ ( 'All' ),
- 1 ,
true ,
true ,
true ,
'' ,
2022-05-27 12:17:26 +02:00
false ,
false ,
false ,
3
2020-01-13 18:24:29 +01:00
);
$in = '<div class="filter_input"><label>' . __ ( 'Severity' ) . '</label>' ;
$in .= $data . '</div>' ;
$inputs [] = $in ;
2023-09-28 10:11:55 +02:00
// REGEX search datatable.
2024-01-29 13:42:09 +01:00
$in = '<div class="filter_input"><label>' . __ ( 'Regex search' ) . ui_print_help_tip ( __ ( 'Filter the results of the current page with regular expressions. It works on Agent name, Event name, Extra ID, Source, Custom data and Comment fields.' ), true ) . '</label>' ;
2023-09-28 10:11:55 +02:00
$in .= html_print_input_text ( 'regex' , $regex , '' , '' , 255 , true );
$in .= '</div>' ;
$inputs [] = $in ;
2023-08-28 13:54:35 +02:00
// User private filter.
$inputs [] = html_print_input_hidden ( 'private_filter_event' , $private_filter_event , true );
2022-07-05 17:02:40 +02:00
// Trick view in table.
2023-02-24 10:04:23 +01:00
$inputs [] = '<div class="w100p pdd_t_15px"></div>' ;
2022-07-05 17:02:40 +02:00
2019-06-11 12:58:18 +02:00
$buttons = [];
$buttons [] = [
'id' => 'load-filter' ,
2022-11-07 14:04:07 +01:00
'class' => 'float-left margin-right-2' ,
2019-06-11 12:58:18 +02:00
'text' => __ ( 'Load filter' ),
'onclick' => '' ,
2023-02-27 10:12:42 +01:00
'icon' => 'load' ,
2019-06-11 12:58:18 +02:00
];
2022-10-19 16:20:49 +02:00
if ( $event_w === true || $event_m === true ) {
2019-06-20 19:23:13 +02:00
$buttons [] = [
'id' => 'save-filter' ,
2023-02-24 10:04:23 +01:00
'class' => 'margin-right-2' ,
2019-06-20 19:23:13 +02:00
'text' => __ ( 'Save filter' ),
'onclick' => '' ,
2023-02-27 10:12:42 +01:00
'icon' => 'save' ,
2019-06-20 19:23:13 +02:00
];
}
2019-06-06 17:50:47 +02:00
2019-06-07 17:35:13 +02:00
/*
* Advanced filter .
*/
$adv_inputs = [];
2019-06-18 17:40:31 +02:00
// Source.
$data = html_print_input_text ( 'source' , $source , '' , '' , 255 , true );
$in = '<div class="filter_input"><label>' . __ ( 'Source' ) . '</label>' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
// Extra ID.
$data = html_print_input_text ( 'id_extra' , $id_extra , '' , 11 , 255 , true );
$in = '<div class="filter_input"><label>' . __ ( 'Extra ID' ) . '</label>' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
// Comment.
$data = html_print_input_text (
'user_comment' ,
$user_comment ,
'' ,
'' ,
255 ,
true
);
$in = '<div class="filter_input"><label>' . __ ( 'Comment' ) . '</label>' ;
2019-06-07 17:35:13 +02:00
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
// Agent search.
$params = [];
$params [ 'show_helptip' ] = true ;
$params [ 'input_name' ] = 'text_agent' ;
$params [ 'value' ] = $text_agent ;
$params [ 'return' ] = true ;
2022-06-01 17:27:44 +02:00
if ( is_metaconsole () === true ) {
2019-06-07 17:35:13 +02:00
$params [ 'javascript_page' ] = 'enterprise/meta/include/ajax/events.ajax' ;
}
$params [ 'print_hidden_input_idagent' ] = true ;
$params [ 'hidden_input_idagent_name' ] = 'id_agent' ;
$params [ 'hidden_input_idagent_value' ] = $id_agent ;
$params [ 'size' ] = '' ;
2021-04-21 13:05:18 +02:00
if ( $id_agent !== null ) {
2022-06-01 17:27:44 +02:00
if ( is_metaconsole () === true ) {
2021-04-21 13:05:18 +02:00
$metaconsole_agent = db_get_row_sql (
sprintf (
' SELECT alias , server_name
FROM tmetaconsole_agent
WHERE id_tagente = " %d " ' ,
$id_agent
)
);
2022-06-01 17:27:44 +02:00
if ( $metaconsole_agent !== false ) {
$params [ 'value' ] = $metaconsole_agent [ 'alias' ] . ' (' . $metaconsole_agent [ 'server_name' ] . ')' ;
}
2021-04-21 13:05:18 +02:00
} else {
$params [ 'value' ] = agents_get_alias ( $id_agent );
}
}
2019-06-07 17:35:13 +02:00
$data = ui_print_agent_autocomplete_input ( $params );
2023-03-28 12:39:02 +02:00
$in = '<div class="filter_input agent-min-w100p"><label>' . __ ( 'Agent search' );
2023-02-24 10:04:23 +01:00
$in .= '</label>' . $data . '</div>' ;
2019-06-07 17:35:13 +02:00
$adv_inputs [] = $in ;
// Mixed. Metaconsole => server, Console => module.
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2019-06-07 17:35:13 +02:00
$title = __ ( 'Server' );
2022-09-29 09:17:37 +02:00
$data = html_print_select (
$servers ,
2019-06-07 17:35:13 +02:00
'server_id' ,
$server_id ,
2019-08-27 15:46:22 +02:00
'' ,
2022-09-29 09:17:37 +02:00
'' ,
0 ,
true ,
true ,
true ,
'' ,
false ,
'height: 60px;'
2019-06-07 17:35:13 +02:00
);
} else {
$title = __ ( 'Module search' );
$data = html_print_autocomplete_modules (
'module_search' ,
$text_module ,
false ,
true ,
'' ,
[],
true ,
$id_agent_module ,
''
);
}
$in = '<div class="filter_input"><label>' . $title . '</label>' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
// User ack.
$user_users = users_get_user_users (
$config [ 'id_user' ],
$access ,
2019-11-06 12:56:42 +01:00
true
2019-06-07 17:35:13 +02:00
);
$data = html_print_select (
$user_users ,
'id_user_ack' ,
$id_user_ack ,
'' ,
__ ( 'Any' ),
0 ,
2023-02-24 10:04:23 +01:00
true ,
false ,
true ,
'' ,
false ,
'width: 400px'
2019-06-07 17:35:13 +02:00
);
$in = '<div class="filter_input"><label>' . __ ( 'User ack.' ) . '</label>' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
2022-11-03 12:00:58 +01:00
$data = html_print_select (
$user_users ,
'owner_user' ,
$owner_user ,
'' ,
__ ( 'Any' ),
0 ,
2023-02-24 10:04:23 +01:00
true ,
false ,
true ,
'' ,
false ,
'width: 400px'
2022-11-03 12:00:58 +01:00
);
$in = '<div class="filter_input"><label>' . __ ( 'Owner' ) . '</label>' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
2019-06-07 17:35:13 +02:00
// Only alert events.
$data = html_print_select (
[
2019-09-05 10:37:12 +02:00
'0' => __ ( 'Filter alert events' ),
'1' => __ ( 'Only alert events' ),
2019-06-07 17:35:13 +02:00
],
'filter_only_alert' ,
$filter_only_alert ,
'' ,
2019-09-05 10:37:12 +02:00
__ ( 'All' ),
- 1 ,
2023-02-24 10:04:23 +01:00
true ,
false ,
true ,
'' ,
false ,
'width: 400px'
2019-06-07 17:35:13 +02:00
);
2021-07-05 17:42:45 +02:00
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
'<label>%s</label>%s' ,
__ ( 'Alert events' ),
$data
),
],
true
);
2021-04-21 13:05:18 +02:00
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2019-11-22 13:38:08 +01:00
$data = html_print_input_text (
'id_source_event' ,
$id_source_event ,
'' ,
5 ,
255 ,
true
);
2021-07-05 17:42:45 +02:00
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
'<label>%s</label>%s' ,
__ ( 'Id source event' ),
$data
),
],
true
);
2021-04-21 13:05:18 +02:00
}
2019-06-07 17:35:13 +02:00
// Date from.
2021-07-05 17:42:45 +02:00
$inputDateFrom = html_print_input_text (
2019-06-07 17:35:13 +02:00
'date_from' ,
2021-07-05 17:42:45 +02:00
( $date_from === '0000-00-00' ) ? '' : $date_from ,
2019-06-07 17:35:13 +02:00
'' ,
false ,
10 ,
true ,
// Disabled.
false ,
// Required.
false ,
// Function.
'' ,
// Class.
'' ,
// OnChange.
'' ,
// Autocomplete.
'off'
);
2021-07-05 17:42:45 +02:00
// Time from.
$inputTimeFrom = html_print_input_text (
'time_from' ,
$time_from ,
'' ,
false ,
10 ,
true ,
// Disabled.
false ,
// Required.
false ,
// Function.
'' ,
// Class.
'' ,
// OnChange.
'' ,
// Autocomplete.
'off'
);
2019-06-07 17:35:13 +02:00
2021-07-05 17:42:45 +02:00
// Date and Time From.
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
2023-02-24 10:04:23 +01:00
'<label>%s</label><div class="datetime-adv-opt">%s<span>:</span>%s</div>' ,
2021-07-05 17:42:45 +02:00
__ ( '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'
);
2021-04-21 13:05:18 +02:00
2019-06-07 17:35:13 +02:00
// Date to.
2021-07-05 17:42:45 +02:00
$inputDateTo = html_print_input_text (
2019-06-07 17:35:13 +02:00
'date_to' ,
2021-07-05 17:42:45 +02:00
( $date_to === '0000-00-00' ) ? '' : $date_to ,
2019-06-07 17:35:13 +02:00
'' ,
false ,
10 ,
true ,
// Disabled.
false ,
// Required.
false ,
// Function.
'' ,
// Class.
'' ,
// OnChange.
'' ,
// Autocomplete.
'off'
);
2021-07-05 17:42:45 +02:00
// Date and Time To.
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
2023-02-24 10:04:23 +01:00
'<label>%s</label><div class="datetime-adv-opt">%s<span>:</span>%s</div>' ,
2021-07-05 17:42:45 +02:00
__ ( 'To (date:time)' ),
$inputDateTo ,
$inputTimeTo
),
],
true
);
2019-06-07 17:35:13 +02:00
2022-03-29 18:09:19 +02:00
// Custom data filter type.
$custom_data_filter_type_input = html_print_select (
[
'0' => __ ( 'Filter custom data by field name' ),
'1' => __ ( 'Filter custom data by field value' ),
],
'custom_data_filter_type' ,
$custom_data_filter_type ,
'' ,
false ,
- 1 ,
2023-02-24 10:04:23 +01:00
true ,
false ,
true ,
'' ,
false ,
'width: 400px'
2022-03-29 18:09:19 +02:00
);
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
'<label>%s</label>%s' ,
__ ( 'Custom data filter' ),
$custom_data_filter_type_input
),
],
true
);
// Custom data.
$custom_data_input = html_print_input_text (
'custom_data' ,
$custom_data ,
'' ,
5 ,
255 ,
true
);
$adv_inputs [] = html_print_div (
[
'class' => 'filter_input' ,
'content' => sprintf (
'<label>%s</label>%s' ,
__ ( 'Custom data search' ),
$custom_data_input
),
],
true
);
2019-06-07 17:35:13 +02:00
// Tags.
2021-07-05 17:42:45 +02:00
if ( is_metaconsole () === true ) {
2021-03-11 15:40:23 +01:00
$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>' ;
2019-06-07 17:35:13 +02:00
} else {
$data = '<fieldset><legend>' . __ ( 'Events with following tags' ) . '</legend>' . html_print_table ( $tabletags_with , true ) . '</fieldset>' ;
$data .= '<fieldset><legend>' . __ ( 'Events without following tags' ) . '</legend>' . html_print_table ( $tabletags_without , true ) . '</fieldset>' ;
}
$in = '<div class="filter_input large">' ;
$in .= $data . '</div>' ;
$adv_inputs [] = $in ;
2019-06-06 17:50:47 +02:00
// Load view.
2019-06-07 17:35:13 +02:00
$adv_filter = join ( '' , $adv_inputs );
2019-06-06 17:50:47 +02:00
$filter = join ( '' , $inputs );
$filter .= ui_toggle (
$adv_filter ,
2023-02-09 16:13:30 +01:00
'<span class="subsection_header_title">' . __ ( 'Advanced options' ) . '</span>' ,
2019-06-06 17:50:47 +02:00
'' ,
'' ,
true ,
true ,
2023-02-24 10:04:23 +01:00
'white_box white_box_opened no_border' ,
'advanced-options-events no-border flex-row' ,
2023-02-22 13:08:15 +01:00
'box-flat white_table_graph w100p'
2019-06-06 17:50:47 +02:00
);
2019-01-30 16:18:44 +01:00
2019-06-06 17:50:47 +02:00
try {
2019-06-18 10:32:04 +02:00
$checkbox_all = html_print_checkbox (
'all_validate_box' ,
1 ,
false ,
true
);
2019-06-10 15:18:35 +02:00
$default_fields = [
2019-06-18 17:40:31 +02:00
[
'text' => 'evento' ,
'class' => 'mw120px' ,
],
2019-06-24 19:23:41 +02:00
[
'text' => 'mini_severity' ,
'class' => 'no-padding' ,
],
2019-06-07 17:35:13 +02:00
'id_evento' ,
'agent_name' ,
'timestamp' ,
'event_type' ,
2019-06-12 18:19:39 +02:00
[
'text' => 'options' ,
2022-11-30 10:14:42 +01:00
'class' => 'table_action_buttons w120px' ,
2021-11-23 14:29:23 +01:00
],
[
2019-06-13 19:41:21 +02:00
'text' => 'm' ,
2019-06-18 10:32:04 +02:00
'extra' => $checkbox_all ,
2019-06-18 17:40:31 +02:00
'class' => 'mw120px' ,
2019-06-12 18:19:39 +02:00
],
2019-06-07 17:35:13 +02:00
];
2019-06-10 15:18:35 +02:00
$fields = explode ( ',' , $config [ 'event_fields' ]);
// Always check something is shown.
if ( empty ( $fields )) {
$fields = $default_fields ;
}
2019-06-24 19:23:41 +02:00
if ( in_array ( 'mini_severity' , $fields ) > 0 ) {
$fields [ array_search ( 'mini_severity' , $fields )] = [
'text' => 'mini_severity' ,
'class' => 'no-padding-imp' ,
];
}
2019-06-18 17:40:31 +02:00
2019-09-17 19:54:34 +02:00
// Identifies column instructions to make it unsortable.
if ( in_array ( 'instructions' , $fields ) > 0 ) {
$fields [ array_search ( 'instructions' , $fields )] = [
'text' => 'instructions' ,
2023-07-28 10:39:46 +02:00
'class' => 'column-instructions mw60px' ,
2019-09-17 19:54:34 +02:00
];
}
2019-06-18 17:40:31 +02:00
$evento_id = array_search ( 'evento' , $fields );
if ( $evento_id !== false ) {
$fields [ $evento_id ] = [
'text' => 'evento' ,
2023-12-11 17:01:40 +01:00
'class' => 'mw180px' ,
2019-06-18 17:40:31 +02:00
];
}
2023-06-21 10:43:28 +02:00
$comment_id = array_search ( 'user_comment' , $fields );
if ( $comment_id !== false ) {
2023-07-07 12:53:14 +02:00
$fields [ $comment_id ] = [ 'text' => 'user_comment' ];
2023-06-21 10:43:28 +02:00
}
2023-12-11 17:01:40 +01:00
$estado = array_search ( 'estado' , $fields );
if ( $estado !== false ) {
$fields [ $estado ] = [
'text' => $fields [ $estado ],
'class' => 'column-estado' ,
];
2023-07-28 10:39:46 +02:00
}
2023-12-11 17:01:40 +01:00
2023-07-28 10:39:46 +02:00
2019-06-10 15:18:35 +02:00
// Always add options column.
2019-06-12 18:19:39 +02:00
$fields = array_merge (
$fields ,
2019-06-13 19:41:21 +02:00
[
[
'text' => 'options' ,
2023-12-13 19:53:14 +01:00
'class' => 'table_action_buttons mw100px' ,
2021-11-23 14:29:23 +01:00
],
[
2019-06-13 19:41:21 +02:00
'text' => 'm' ,
2019-06-18 10:32:04 +02:00
'extra' => $checkbox_all ,
2019-06-13 19:41:21 +02:00
'class' => 'w20px no-text-imp' ,
],
2019-06-12 18:19:39 +02:00
]
);
2019-06-10 15:18:35 +02:00
// Get column names.
2019-07-30 16:10:34 +02:00
$column_names = events_get_column_names ( $fields , true );
2019-06-10 15:18:35 +02:00
2019-08-05 16:23:37 +02:00
foreach ( $column_names as $key => $column ) {
if ( is_array ( $column ) && $column [ 'text' ] == 'S' ) {
$column_names [ $key ][ 'style' ] = 'padding-left: 1em !important;' ;
}
}
2019-08-02 10:04:10 +02:00
2023-07-28 10:39:46 +02:00
// mw60px
2019-06-10 15:18:35 +02:00
// Open current filter quick reference.
$active_filters_div = '<div class="filter_summary">' ;
2019-06-17 17:02:33 +02:00
2023-10-04 12:41:23 +02:00
$active_filters_div .= '<div>' ;
$active_filters_div .= '<div class="label box-shadow">' . __ ( 'Show graph' ) . '</div>' ;
$active_filters_div .= html_print_div (
[
'class' => 'content' ,
'style' => 'padding-top: 5px !important;' ,
'content' => html_print_checkbox_switch_extended (
'show_event_graph' ,
1 ,
false ,
false ,
'' ,
'' ,
true
),
],
true
);
$active_filters_div .= '</div>' ;
2019-06-17 17:02:33 +02:00
// Current filter.
$active_filters_div .= '<div>' ;
$active_filters_div .= '<div class="label box-shadow">' . __ ( 'Current filter' ) . '</div>' ;
$active_filters_div .= '<div id="current_filter" class="content">' ;
2021-04-21 13:05:18 +02:00
if ( $loaded_filter !== false ) {
2021-06-04 13:36:32 +02:00
$active_filters_div .= htmlentities ( io_safe_output ( $loaded_filter [ 'id_name' ]));
2019-06-17 17:02:33 +02:00
} else {
$active_filters_div .= __ ( 'Not set.' );
}
$active_filters_div .= '</div>' ;
$active_filters_div .= '</div>' ;
2019-06-10 15:18:35 +02:00
// Event status.
$active_filters_div .= '<div>' ;
$active_filters_div .= '<div class="label box-shadow">' . __ ( 'Event status' ) . '</div>' ;
$active_filters_div .= '<div id="summary_status" class="content">' ;
switch ( $status ) {
case EVENT_ALL :
default :
$active_filters_div .= __ ( 'Any status.' );
break ;
case EVENT_NEW :
$active_filters_div .= __ ( 'New events.' );
break ;
case EVENT_VALIDATE :
$active_filters_div .= __ ( 'Validated.' );
break ;
case EVENT_PROCESS :
$active_filters_div .= __ ( 'In proccess.' );
break ;
case EVENT_NO_VALIDATED :
$active_filters_div .= __ ( 'Not validated.' );
break ;
2023-09-25 11:29:38 +02:00
case EVENT_NO_PROCESS :
$active_filters_div .= __ ( 'Not in process.' );
break ;
2019-06-10 15:18:35 +02:00
}
$active_filters_div .= '</div>' ;
$active_filters_div .= '</div>' ;
// Max. hours old.
$active_filters_div .= '<div>' ;
$active_filters_div .= '<div class="label box-shadow">' . __ ( 'Max. hours old' ) . '</div>' ;
$active_filters_div .= '<div id="summary_hours" class="content">' ;
if ( $event_view_hr == 0 ) {
$active_filters_div .= __ ( 'Any time.' );
} else if ( $event_view_hr == 1 ) {
$active_filters_div .= __ ( 'Last hour.' );
2019-06-11 12:58:18 +02:00
} else if ( $event_view_hr > 1 ) {
2019-06-10 15:18:35 +02:00
$active_filters_div .= __ ( 'Last %d hours.' , $event_view_hr );
}
$active_filters_div .= '</div>' ;
$active_filters_div .= '</div>' ;
// Duplicates.
$active_filters_div .= '<div>' ;
$active_filters_div .= '<div class="label box-shadow">' . __ ( 'Duplicated' ) . '</div>' ;
$active_filters_div .= '<div id="summary_duplicates" class="content">' ;
2022-09-27 15:08:09 +02:00
if ( $group_rep == EVENT_GROUP_REP_ALL ) {
2019-06-10 15:18:35 +02:00
$active_filters_div .= __ ( 'All events.' );
2022-09-27 15:08:09 +02:00
} else if ( $group_rep == EVENT_GROUP_REP_EVENTS ) {
2019-06-10 15:18:35 +02:00
$active_filters_div .= __ ( 'Group events' );
2022-09-27 15:08:09 +02:00
} else if ( $group_rep == EVENT_GROUP_REP_AGENTS ) {
2019-06-10 15:18:35 +02:00
$active_filters_div .= __ ( 'Group agents.' );
2022-09-27 15:08:09 +02:00
} else if ( $group_rep == EVENT_GROUP_REP_EXTRAIDS ) {
$active_filters_div .= __ ( 'Group extra id.' );
2019-06-10 15:18:35 +02:00
}
$active_filters_div .= '</div>' ;
$active_filters_div .= '</div>' ;
// Close.
$active_filters_div .= '</div>' ;
2023-03-03 12:40:58 +01:00
// $active_filters_div .= '<div id="events_buffers_display"></div>';
2022-06-30 11:56:25 +02:00
$table_id = 'table_events' ;
2019-06-20 11:46:01 +02:00
$form_id = 'events_form' ;
2019-06-10 15:18:35 +02:00
2023-02-27 09:57:17 +01:00
$show_hide_filters = '' ;
if (( int ) $_GET [ 'pure' ] === 1 ) {
$show_hide_filters = 'invisible' ;
}
2023-10-04 12:41:23 +02:00
// Print graphs
$graph_background = '' ;
if ( $config [ 'style' ] === 'pandora' ) {
$graph_background = ' background-color: #fff;' ;
} else if ( $config [ 'style' ] === 'pandora_black' ) {
$graph_background = ' background-color: #222;' ;
}
$graph_div = html_print_div (
[
'id' => 'events-graph' ,
2023-10-04 16:28:40 +02:00
'class' => 'invisible' ,
'style' => 'margin-bottom: 10px; text-align: left;' . $graph_background ,
2023-10-04 12:41:23 +02:00
],
true
);
$graph_div .= html_print_div (
[
'id' => 'events-graph-loading' ,
'class' => 'center invisible' ,
'content' => html_print_image (
'images/spinner.gif' ,
true ,
[
'title' => __ ( 'Loading' ),
'class' => 'invert_filter' ,
]
),
],
true
);
2019-06-10 15:18:35 +02:00
// Print datatable.
2023-02-09 16:13:30 +01:00
html_print_div (
2019-06-06 17:50:47 +02:00
[
2023-02-09 16:13:30 +01:00
'class' => 'events_table_wrapper' ,
2023-02-27 09:57:17 +01:00
'style' => 'margin-top: 0px; margin-bottom: 0px;' ,
2023-02-09 16:13:30 +01:00
'content' => ui_print_datatable (
2019-06-06 17:50:47 +02:00
[
2023-02-09 16:13:30 +01:00
'id' => $table_id ,
'class' => 'info_table events' ,
2023-05-08 14:25:57 +02:00
'style' => 'width: 100%;' ,
2023-02-09 16:13:30 +01:00
'ajax_url' => 'operation/events/events' ,
'ajax_data' => [
'get_events' => 1 ,
'history' => ( int ) $history ,
'table_id' => $table_id ,
],
'form' => [
'id' => $form_id ,
'class' => 'flex-row' ,
'html' => $filter ,
'inputs' => [],
'extra_buttons' => $buttons ,
],
2023-10-04 12:41:23 +02:00
'extra_html' => $active_filters_div . $graph_div ,
2023-02-09 16:13:30 +01:00
'pagination_options' => [
[
2023-12-18 14:46:44 +01:00
( int ) $config [ 'block_size' ],
2023-02-09 16:13:30 +01:00
10 ,
25 ,
100 ,
200 ,
500 ,
],
[
2023-12-18 14:46:44 +01:00
( int ) $config [ 'block_size' ],
2023-02-09 16:13:30 +01:00
10 ,
25 ,
100 ,
200 ,
500 ,
],
],
2023-12-18 14:46:44 +01:00
'pagination_options_order' => 'true' ,
2023-02-09 16:13:30 +01:00
'order' => [
'field' => 'timestamp' ,
'direction' => 'desc' ,
],
'column_names' => $column_names ,
'columns' => $fields ,
'no_sortable_columns' => [
- 1 ,
- 2 ,
'column-instructions' ,
2023-08-24 14:43:05 +02:00
'user_comment' ,
2023-02-09 16:13:30 +01:00
],
'ajax_return_operation' => 'buffers' ,
'ajax_return_operation_function' => 'process_buffers' ,
'drawCallback' => 'process_datatables_callback(this, settings)' ,
'print' => false ,
'csv' => 0 ,
2023-03-28 12:39:02 +02:00
'filter_main_class' => 'events-pure box-flat white_table_graph fixed_filter_bar ' . $show_hide_filters ,
2019-06-06 17:50:47 +02:00
],
2023-02-09 16:13:30 +01:00
),
2019-06-06 17:50:47 +02:00
]
2019-01-30 16:18:44 +01:00
);
2019-06-06 17:50:47 +02:00
} catch ( Exception $e ) {
ui_print_error_message ( $e -> getMessage ());
2013-10-14 17:36:50 +02:00
}
2023-03-03 12:40:58 +01:00
// Close.
echo '<div id="events_buffers_display"></div>' ;
2019-06-13 19:41:21 +02:00
// Event responses.
2021-03-11 16:11:06 +01:00
if ( is_user_admin ( $config [ 'id_user' ])) {
$sql_event_resp = " SELECT id, name FROM tevent_response WHERE type LIKE 'command' " ;
$event_responses = db_get_all_rows_sql ( $sql_event_resp );
} else {
$id_groups = array_keys ( users_get_groups ( false , 'EW' ));
$event_responses = db_get_all_rows_filter (
'tevent_response' ,
[
'id_group' => $id_groups ,
'type' => 'command' ,
]
);
}
2022-10-19 16:20:49 +02:00
$array_events_actions = [];
if ( $event_w === true && $readonly === false ) {
$array_events_actions [ 'in_progress_selected' ] = __ ( 'In progress selected' );
$array_events_actions [ 'validate_selected' ] = __ ( 'Validate selected' );
}
if ( $event_m === true && $readonly === false ) {
$array_events_actions [ 'delete_selected' ] = __ ( 'Delete selected' );
}
2019-06-13 19:41:21 +02:00
foreach ( $event_responses as $val ) {
$array_events_actions [ $val [ 'id' ]] = $val [ 'name' ];
}
2021-03-11 15:40:23 +01:00
if ( check_acl (
$config [ 'id_user' ],
0 ,
'EW'
)
) {
2020-06-26 15:36:51 +02:00
echo '<div class="multi-response-buttons">' ;
echo '<form method="post" id="form_event_response">' ;
echo '<input type="hidden" id="max_execution_event_response" value="' . $config [ 'max_execution_event_response' ] . '" />' ;
2022-10-26 17:00:54 +02:00
$elements = html_print_button (
__ ( 'Execute event response' ),
'submit_event_response' ,
false ,
'execute_event_response(true);' ,
2023-07-06 13:15:45 +02:00
[ 'icon' => 'cog' ],
2022-10-26 17:00:54 +02:00
true
);
$elements .= html_print_select (
2021-03-11 15:40:23 +01:00
$array_events_actions ,
'response_id' ,
'' ,
'' ,
'' ,
0 ,
2022-10-26 17:00:54 +02:00
true ,
2021-03-11 15:40:23 +01:00
false ,
false
);
2023-07-24 12:25:06 +02:00
if ( is_metaconsole () === true ) {
$urlSound = '../../include/sounds/' ;
} else {
$urlSound = 'include/sounds/' ;
}
2022-10-26 17:00:54 +02:00
2023-07-06 13:15:45 +02:00
// Acoustic console.
$data_sound = base64_encode (
json_encode (
[
'title' => __ ( 'Acoustic console' ),
'start' => __ ( 'Start' ),
'stop' => __ ( 'Stop' ),
'noAlert' => __ ( 'No alert' ),
'silenceAlarm' => __ ( 'Silence alarm' ),
'url' => ui_get_full_url ( 'ajax.php' ),
'page' => 'include/ajax/events' ,
2023-07-24 12:25:06 +02:00
'urlSound' => $urlSound ,
2023-07-06 13:15:45 +02:00
]
)
);
$elements .= html_print_button (
__ ( 'Sound Events' ),
'sound_events_button' ,
false ,
'openSoundEventsDialog("' . $data_sound . '")' ,
[
2024-01-22 15:07:25 +01:00
'class' => 'responsive_button_sound_events' ,
2023-07-21 13:32:12 +02:00
'icon' => 'sound' ,
'minimize-arrow' => true ,
2023-07-24 12:25:06 +02:00
'span_style' => 'width: 100%' ,
2023-07-06 13:15:45 +02:00
],
true
);
$elements .= html_print_button (
'hidden' ,
'sound_events_button_hidden' ,
false ,
'openSoundEventModal("' . $data_sound . '")' ,
[ 'style' => 'display:none' ],
true
);
2022-10-26 17:00:54 +02:00
2022-11-21 14:49:07 +01:00
html_print_action_buttons (
$elements ,
[ 'type' => 'data_table' ]
2021-03-11 15:40:23 +01:00
);
2022-10-26 17:00:54 +02:00
2021-03-11 15:40:23 +01:00
echo " <span id='response_loading_dialog' class='invisible'> " . html_print_image (
'images/spinner.gif' ,
true
) . '</span>' ;
2020-06-26 15:36:51 +02:00
echo '</form>' ;
2021-03-18 18:05:50 +01:00
echo '<span id="max_custom_event_resp_msg" style="display: none; color: #e63c52; line-height: 200%;">' ;
2020-06-26 15:36:51 +02:00
echo __ (
'A maximum of %s event custom responses can be selected' ,
$config [ 'max_execution_event_response' ]
) . '</span>' ;
2021-03-18 18:05:50 +01:00
echo '<span id="max_custom_selected" style="display: none; color: #e63c52; line-height: 200%;">' ;
2020-06-26 15:36:51 +02:00
echo __ (
'Please, select an event'
) . '</span>' ;
echo '</div>' ;
}
2019-06-13 19:41:21 +02:00
2019-06-07 17:35:13 +02:00
// Datepicker requirements.
ui_require_css_file ( 'datepicker' );
ui_include_time_picker ();
ui_require_jquery_file (
'ui.datepicker-' . get_user_language (),
'include/javascript/i18n/'
);
2019-06-07 21:22:07 +02:00
// End. Load required JS.
2019-06-10 15:18:35 +02:00
html_print_input_hidden ( 'meta' , ( int ) is_metaconsole ());
html_print_input_hidden ( 'history' , ( int ) $history );
html_print_input_hidden (
'ajax_file' ,
ui_get_full_url ( 'ajax.php' , false , false , false )
);
// AJAX call options responses.
echo " <div id='event_details_window'></div> " ;
echo " <div id='event_response_window'></div> " ;
echo " <div id='event_response_command_window' title=' " . __ ( 'Parameters' ) . " '></div> " ;
2019-06-11 12:58:18 +02:00
// Load filter div for dialog.
2021-03-29 09:23:03 +02:00
echo '<div id="load-modal-filter" style="display:none"></div>' ;
echo '<div id="save-modal-filter" style="display:none"></div>' ;
2019-07-15 17:41:20 +02:00
2022-06-01 17:27:44 +02:00
$autorefresh_draw = false ;
if ( $_GET [ 'refr' ] || ( bool ) ( $do_refresh ? ? false ) === true ) {
2019-07-15 17:41:20 +02:00
$autorefresh_draw = true ;
}
2019-06-07 17:35:13 +02:00
?>
< script type = " text/javascript " >
2019-06-11 12:58:18 +02:00
var loading = 0 ;
2019-06-07 21:22:07 +02:00
var select_with_tag_empty = < ? php echo ( int ) $remove_with_tag_disabled ; ?> ;
var select_without_tag_empty = < ? php echo ( int ) $remove_without_tag_disabled ; ?> ;
var origin_select_with_tag_empty = < ? php echo ( int ) $add_with_tag_disabled ; ?> ;
var origin_select_without_tag_empty = < ? php echo ( int ) $add_without_tag_disabled ; ?> ;
var val_none = 0 ;
var text_none = " <?php echo __('None'); ?> " ;
var group_agents_id = false ;
2019-06-12 18:19:39 +02:00
var test ;
2019-06-11 12:58:18 +02:00
/* Datatables auxiliary functions starts */
2019-06-12 18:19:39 +02:00
function process_datatables_callback ( table , settings ) {
var api = table . api ();
var rows = api . rows ( { page : 'current' } ) . nodes ();
var last = null ;
var last_count = 0 ;
var events_per_group = [];
var j = 0 ;
// Only while grouping by agents.
if ( $ ( '#group_rep' ) . val () == '2' ) {
test = api ;
target = - 1 ;
for ( var i = 0 ; i < api . columns ()[ '0' ] . length ; i ++ ) {
var label = $ ( api . table () . column ( i ) . header ()) . text ();
if ( label == '<?php echo __(' Agent ID '); ?>' ) {
// Agent id.
target = i ;
}
2019-10-30 13:01:59 +01:00
if ( label == '<?php echo addslashes(__(' Agent name ')); ?>' ) {
2019-06-12 18:19:39 +02:00
// Agent id.
target = i ;
break ;
}
}
// Cannot group without agent_id or agent_name.
if ( target < 0 ) {
return ;
}
api . column ( target , { page : 'current' } )
. data ()
. each ( function ( group , i ) {
$ ( rows ) . eq ( i ) . show ();
2023-12-26 18:33:31 +01:00
// Compare only "a" tag because in metaconsole the node has "form".
let last_to_compare = $ ( last ) . filter ( 'a' ) . html ();
let group_to_compare = $ ( group ) . filter ( 'a' ) . html ();
if ( last_to_compare !== group_to_compare ) {
2019-06-12 18:19:39 +02:00
$ ( rows ) . eq ( i ) . before (
'<tr class="group"><td colspan="100%">'
+ '<?php echo __(' Agent ').' '; ?>'
2019-06-13 12:30:09 +02:00
+ group + ' <?php echo __(' has at least ').' '; ?>'
2019-06-12 18:19:39 +02:00
+ '<span style="cursor: pointer" id="s' + j + '">' + '</span>'
+ '<?php echo ' '.__(' events '); ?>'
+ '</td></tr>'
);
2019-06-13 12:30:09 +02:00
events_per_group . push ( i - last_count );
2019-06-12 18:19:39 +02:00
last_count = i ;
last = group ;
j += 1 ;
}
});
events_per_group . push ( rows . length - last_count );
for ( j = 0 ; j < events_per_group . length ; j ++ ) {
$ ( '#s' + j ) . text ( events_per_group [ j + 1 ]);
}
/* Grouped by agent toggle view. */
$ ( " tr.group td span " ) . on ( 'click' , function ( e ){
var id = this . id . substring ( 1 ) * 1 ;
var from = events_per_group [ id ];
var to = events_per_group [ id + 1 ] + from ;
for ( var i = from ; i < to ; i ++ ) {
$ ( rows ) . eq ( i ) . toggle ();
}
})
}
2019-07-15 17:41:20 +02:00
var autorefresh_draw = '<?php echo $autorefresh_draw; ?>' ;
if ( autorefresh_draw == true ){
$ ( " #refrcounter " ) . countdown ( 'change' , {
until : countdown_repeat ()
});
function countdown_repeat () {
var until_time = new Date ();
2023-02-22 12:35:34 +01:00
until_time . setTime ( until_time . getTime () + parseInt ( < ? php echo ( $config [ 'refr' ] * 1000 ); ?> ));
2019-07-15 17:41:20 +02:00
return until_time ;
}
}
2020-01-14 08:37:04 +01:00
// Uncheck checkbox to select all.
if ( $ ( '#checkbox-all_validate_box' ) . length ) {
$ ( '#checkbox-all_validate_box' ) . uncheck ();
}
2019-06-12 18:19:39 +02:00
}
2019-06-11 12:58:18 +02:00
/* Datatables auxiliary functions ends */
/* Tag management starts */
2019-06-07 21:22:07 +02:00
function click_button_remove_tag ( what_button ) {
if ( what_button == " with " ) {
id_select_origin = " #select_with " ;
id_select_destiny = " #tag_with_temp " ;
id_button_remove = " #button-remove_with " ;
id_button_add = " #button-add_with " ;
select_origin_empty = origin_select_with_tag_empty ;
}
else { //without
id_select_origin = " #select_without " ;
id_select_destiny = " #tag_without_temp " ;
id_button_remove = " #button-remove_without " ;
id_button_add = " #button-add_without " ;
select_origin_empty = origin_select_without_tag_empty ;
}
if ( $ ( id_select_destiny + " option:selected " ) . length == 0 ) {
return ; //Do nothing
}
if ( select_origin_empty ) {
$ ( id_select_origin + " option " ) . remove ();
if ( what_button == " with " ) {
origin_select_with_tag_empty = false ;
}
else { //without
origin_select_without_tag_empty = false ;
}
$ ( id_button_add ) . removeAttr ( 'disabled' );
}
//Foreach because maybe the user select several items in
//the select.
jQuery . each ( $ ( id_select_destiny + " option:selected " ), function ( key , element ) {
val = $ ( element ) . val ();
text = $ ( element ) . text ();
$ ( id_select_origin ) . append ( $ ( " <option value=' " + val + " '> " + text + " </option> " ));
});
$ ( id_select_destiny + " option:selected " ) . remove ();
if ( $ ( id_select_destiny + " option " ) . length == 0 ) {
$ ( id_select_destiny ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
$ ( id_button_remove ) . attr ( 'disabled' , 'true' );
if ( what_button == 'with' ) {
select_with_tag_empty = true ;
}
else { //without
select_without_tag_empty = true ;
}
}
replace_hidden_tags ( what_button );
}
function click_button_add_tag ( what_button ) {
if ( what_button == 'with' ) {
id_select_origin = " #select_with " ;
id_select_destiny = " #tag_with_temp " ;
id_button_remove = " #button-remove_with " ;
id_button_add = " #button-add_with " ;
}
else { //without
id_select_origin = " #select_without " ;
id_select_destiny = " #tag_without_temp " ;
id_button_remove = " #button-remove_without " ;
id_button_add = " #button-add_without " ;
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( id_select_origin + " option:selected " ) . each ( function () {
if ( what_button == 'with' ) {
select_destiny_empty = select_with_tag_empty ;
}
else { //without
select_destiny_empty = select_without_tag_empty ;
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
without_val = $ ( this ) . val ();
if ( without_val == null ) {
next ;
}
without_text = $ ( this ) . text ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( select_destiny_empty ) {
$ ( id_select_destiny ) . empty ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( what_button == 'with' ) {
select_with_tag_empty = false ;
}
else { //without
select_without_tag_empty = false ;
}
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( id_select_destiny ) . append ( $ ( " <option value=' " + without_val + " '> " + without_text + " </option> " ));
$ ( id_select_origin + " option:selected " ) . remove ();
$ ( id_button_remove ) . removeAttr ( 'disabled' );
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( $ ( id_select_origin + " option " ) . length == 0 ) {
$ ( id_select_origin ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
$ ( id_button_add ) . attr ( 'disabled' , 'true' );
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( what_button == 'with' ) {
origin_select_with_tag_empty = true ;
}
else { //without
origin_select_without_tag_empty = true ;
}
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
replace_hidden_tags ( what_button );
});
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
}
function replace_hidden_tags ( what_button ) {
if ( what_button == 'with' ) {
id_select_destiny = " #tag_with_temp " ;
id_hidden = " #hidden-tag_with " ;
}
else { //without
id_select_destiny = " #tag_without_temp " ;
id_hidden = " #hidden-tag_without " ;
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
value_store = [];
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
jQuery . each ( $ ( id_select_destiny + " option " ), function ( key , element ) {
val = $ ( element ) . val ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
value_store . push ( val );
});
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( id_hidden ) . val ( Base64 . encode ( JSON . stringify ( value_store )));
}
function clear_tags_inputs () {
$ ( " #hidden-tag_with " ) . val ( Base64 . encode ( JSON . stringify ([])));
$ ( " #hidden-tag_without " ) . val ( Base64 . encode ( JSON . stringify ([])));
reorder_tags_inputs ();
}
function reorder_tags_inputs () {
$ ( '#select_with option[value="' + val_none + '"]' ) . remove ();
jQuery . each ( $ ( " #tag_with_temp option " ), function ( key , element ) {
val = $ ( element ) . val ();
text = $ ( element ) . text ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( val == val_none )
return ;
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( " #select_with " ) . append ( $ ( " <option value=' " + val + " '> " + text + " </option> " ));
});
$ ( " #tag_with_temp option " ) . remove ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( '#select_without option[value="' + val_none + '"]' ) . remove ();
jQuery . each ( $ ( " #tag_without_temp option " ), function ( key , element ) {
val = $ ( element ) . val ();
text = $ ( element ) . text ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
if ( val == val_none )
return ;
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
$ ( " #select_without " ) . append ( $ ( " <option value=' " + val + " '> " + text + " </option> " ));
});
$ ( " #tag_without_temp option " ) . remove ();
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
tags_base64 = $ ( " #hidden-tag_with " ) . val ();
2019-06-11 12:58:18 +02:00
if ( tags_base64 . length > 0 ) {
tags = jQuery . parseJSON ( Base64 . decode ( tags_base64 ));
} else {
tags = [];
}
2019-06-07 21:22:07 +02:00
jQuery . each ( tags , function ( key , element ) {
if ( $ ( " #select_with option[value=' " + element + " '] " ) . length == 1 ) {
text = $ ( " #select_with option[value=' " + element + " '] " ) . text ();
val = $ ( " #select_with option[value=' " + element + " '] " ) . val ();
$ ( " #tag_with_temp " ) . append ( $ ( " <option value=' " + val + " '> " + text + " </option> " ));
$ ( " #select_with option[value=' " + element + " '] " ) . remove ();
}
});
if ( $ ( " #select_with option " ) . length == 0 ) {
origin_select_with_tag_empty = true ;
$ ( " #button-add_with " ) . attr ( 'disabled' , 'true' );
$ ( " #select_with " ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
}
else {
origin_select_with_tag_empty = false ;
$ ( " #button-add_with " ) . removeAttr ( 'disabled' );
}
if ( $ ( " #tag_with_temp option " ) . length == 0 ) {
select_with_tag_empty = true ;
$ ( " #button-remove_with " ) . attr ( 'disabled' , 'true' );
$ ( " #tag_with_temp " ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
}
else {
select_with_tag_empty = false ;
$ ( " #button-remove_with " ) . removeAttr ( 'disabled' );
}
2021-12-16 16:35:31 +01:00
2019-06-07 21:22:07 +02:00
tags_base64 = $ ( " #hidden-tag_without " ) . val ();
2019-06-11 12:58:18 +02:00
if ( tags_base64 . length > 0 ) {
tags = jQuery . parseJSON ( Base64 . decode ( tags_base64 ));
} else {
tags = [];
}
2019-06-07 21:22:07 +02:00
jQuery . each ( tags , function ( key , element ) {
if ( $ ( " #select_without option[value=' " + element + " '] " ) . length == 1 ) {
text = $ ( " #select_without option[value=' " + element + " '] " ) . text ();
val = $ ( " #select_without option[value=' " + element + " '] " ) . val ();
$ ( " #tag_without_temp " ) . append ( $ ( " <option value=' " + val + " '> " + text + " </option> " ));
$ ( " #select_without option[value=' " + element + " '] " ) . remove ();
}
});
if ( $ ( " #select_without option " ) . length == 0 ) {
origin_select_without_tag_empty = true ;
$ ( " #button-add_without " ) . attr ( 'disabled' , 'true' );
$ ( " #select_without " ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
}
else {
origin_select_without_tag_empty = false ;
$ ( " #button-add_without " ) . removeAttr ( 'disabled' );
}
if ( $ ( " #tag_without_temp option " ) . length == 0 ) {
select_without_tag_empty = true ;
$ ( " #button-remove_without " ) . attr ( 'disabled' , 'true' );
$ ( " #tag_without_temp " ) . append ( $ ( " <option value=' " + val_none + " '> " + text_none + " </option> " ));
}
else {
select_without_tag_empty = false ;
$ ( " #button-remove_without " ) . removeAttr ( 'disabled' );
}
}
2019-06-12 13:17:18 +02:00
/* Tag management ends */
2019-06-11 12:58:18 +02:00
$ ( document ) . ready ( function () {
2023-10-04 12:41:23 +02:00
let hidden_graph = true ;
$ ( '#checkbox-show_event_graph' ) . on ( 'change' , function (){
if ( hidden_graph == true ) {
hidden_graph = false ;
$ ( '#events-graph' ) . removeClass ( 'invisible' );
show_events_graph ();
} else {
hidden_graph = true ;
$ ( '#events-graph' ) . html ();
$ ( '#events-graph' ) . addClass ( 'invisible' );
}
});
2019-08-19 11:32:40 +02:00
let refresco = < ? php echo get_parameter ( 'refr' , 0 ); ?> ;
$ ( '#refresh option[value=' + refresco + ']' ) . attr ( 'selected' , 'selected' );
2019-06-19 17:30:32 +02:00
/* Filter to a href */
$ ( '.events_link' ) . on ( 'click' , function ( e ) {
e . preventDefault ();
2019-06-20 11:46:01 +02:00
inputs = $ ( " #<?php echo $form_id ; ?> :input " );
values = {};
inputs . each ( function () {
2022-11-22 11:35:38 +01:00
if ( this . name === 'server_id' ) {
values [ this . name ] = $ ( this ) . val () . join ();
} else {
values [ this . name ] = $ ( this ) . val ();
}
2019-06-20 11:46:01 +02:00
})
2019-06-19 17:30:32 +02:00
2019-06-20 11:46:01 +02:00
values [ 'history' ] = " <?php echo (int) $history ; ?> " ;
2019-06-19 17:30:32 +02:00
2019-06-20 11:46:01 +02:00
var url = e . currentTarget . href ;
url += 'fb64=' + btoa ( JSON . stringify ( values ));
2019-08-19 11:32:40 +02:00
url += '&refr=' + '<?php echo $config[' refr ']; ?>' ;
2019-06-20 11:46:01 +02:00
document . location = url ;
2019-06-19 17:30:32 +02:00
});
2023-04-11 13:50:11 +02:00
var show_event_dialog = " <?php echo get_parameter('show_event_dialog', ''); ?> " ;
if ( show_event_dialog !== '' ){
show_event_dialo ( show_event_dialog );
}
2019-06-13 19:41:21 +02:00
/* Multi select handler */
$ ( '#checkbox-all_validate_box' ) . on ( 'change' , function () {
if ( $ ( '#checkbox-all_validate_box' ) . is ( " :checked " )) {
$ ( '.chk_val' ) . check ();
} else {
$ ( '.chk_val' ) . uncheck ();
}
});
2019-06-11 12:58:18 +02:00
/* Update summary */
$ ( " #status " ) . on ( " change " , function (){
$ ( '#summary_status' ) . html ( $ ( " #status option:selected " ) . text ());
});
$ ( " #text-event_view_hr " ) . on ( " keyup " , function (){
hours = $ ( '#text-event_view_hr' ) . val ();
if ( hours == '' || hours == 0 ) {
2022-11-22 15:54:19 +01:00
$ ( '#summary_hours' ) . text ( '<?php echo __(' Any '); ?>' );
2019-06-11 12:58:18 +02:00
} else if ( hours == 1 ) {
2022-11-22 15:54:19 +01:00
$ ( '#summary_hours' ) . text ( '<?php echo __(' Last hour . '); ?>' );
2019-06-11 12:58:18 +02:00
} else {
2022-11-22 15:54:19 +01:00
$ ( '#summary_hours' ) . text ( hours + '<?php echo ' '.__(' hours . '); ?>' );
2019-06-11 12:58:18 +02:00
}
});
$ ( '#group_rep' ) . on ( " change " , function (){
$ ( '#summary_duplicates' ) . html ( $ ( " #group_rep option:selected " ) . text ());
});
/* Summary updates end. */
/* Filter management */
2022-11-07 14:04:07 +01:00
$ ( '#button-load-filter' ) . click ( function (){
2019-06-11 12:58:18 +02:00
if ( $ ( '#load-filter-select' ) . length ) {
$ ( '#load-filter-select' ) . dialog ();
} else {
if ( loading == 0 ) {
loading = 1
$ . ajax ({
method : 'POST' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
data : {
page : 'include/ajax/events' ,
2023-07-27 10:47:51 +02:00
load_filter_modal : 1 ,
settings : '<?php echo $settings_modal; ?>' ,
parameters : '<?php echo $parameters_modal; ?>' ,
2022-09-29 09:17:37 +02:00
},
2019-06-11 12:58:18 +02:00
success : function ( data ){
$ ( '#load-modal-filter' )
. empty ()
. html ( data );
loading = 0 ;
}
});
}
}
});
2022-11-07 14:04:07 +01:00
$ ( '#button-save-filter' ) . click ( function (){
2019-06-11 12:58:18 +02:00
if ( $ ( '#save-filter-select' ) . length ) {
$ ( '#save-filter-select' ) . dialog ();
} else {
if ( loading == 0 ) {
loading = 1
$ . ajax ({
method : 'POST' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
data : {
page : 'include/ajax/events' ,
save_filter_modal : 1 ,
2023-08-28 13:54:35 +02:00
current_filter : $ ( '#hidden-id_filter_event' ) . val (),
private_filter_event : $ ( '#hidden-private_filter_event' ) . val ()
2019-06-11 12:58:18 +02:00
},
success : function ( data ){
$ ( '#save-modal-filter' )
. empty ()
. html ( data );
loading = 0 ;
}
});
}
}
});
/* Filter management ends */
/* Tag management */
id_select_destiny = " #tag_with_temp " ;
id_hidden = " #hidden-tag_with " ;
value_store = [];
jQuery . each ( $ ( id_select_destiny + " option " ), function ( key , element ) {
val = $ ( element ) . val ();
value_store . push ( val );
});
$ ( id_hidden ) . val ( Base64 . encode ( JSON . stringify ( value_store )));
id_select_destiny2 = " #tag_without_temp " ;
id_hidden2 = " #hidden-tag_without " ;
value_store2 = [];
jQuery . each ( $ ( id_select_destiny2 + " option " ), function ( key , element ) {
val = $ ( element ) . val ();
value_store2 . push ( val );
});
$ ( id_hidden2 ) . val ( Base64 . encode ( JSON . stringify ( value_store2 )));
$ ( " #text-date_from, #text-date_to " ) . datepicker (
{ dateFormat : " <?php echo DATE_FORMAT_JS; ?> " });
$ ( " #button-add_with " ) . click ( function () {
click_button_add_tag ( " with " );
});
$ ( " #button-add_without " ) . click ( function () {
click_button_add_tag ( " without " );
});
$ ( " #button-remove_with " ) . click ( function () {
click_button_remove_tag ( " with " );
});
$ ( " #button-remove_without " ) . click ( function () {
click_button_remove_tag ( " without " );
});
2023-10-04 16:28:40 +02:00
2023-09-28 10:11:55 +02:00
$ ( '#myInputTextField' ) . keyup ( function (){
$ ( " #table_events " ) . search ( $ ( this ) . val ()) . draw () ;
2023-11-28 09:50:48 +01:00
});
2023-10-04 16:28:40 +02:00
$ ( " #button-events_form_search_bt " ) . click ( function (){
show_events_graph ();
});
2019-06-11 12:58:18 +02:00
2019-08-19 11:32:40 +02:00
//Autorefresh in fullscreen
var pure = '<?php echo $pure; ?>' ;
2023-03-28 12:39:02 +02:00
var pure = '<?php echo $pure; ?>' ;
2019-08-19 11:32:40 +02:00
if ( pure == 1 ){
2023-02-22 12:35:34 +01:00
var refresh_interval = parseInt ( '<?php echo($config[' refr '] * 1000); ?>' );
2019-08-19 11:32:40 +02:00
var until_time = '' ;
// If autorefresh is disabled, don't show the countdown
var refresh_time = '<?php echo $_GET[' refr ']; ?>' ;
if ( refresh_time == '' || refresh_time == 0 ){
$ ( '#refrcounter' ) . toggle ();
}
function events_refresh () {
until_time = new Date ();
2023-02-22 12:35:34 +01:00
until_time . setTime ( until_time . getTime () + parseInt ( < ? php echo ( $config [ 'refr' ] * 1000 ); ?> ));
2019-08-19 11:32:40 +02:00
$ ( " #refrcounter " ) . countdown ({
until : until_time ,
layout : '(%M%nn%M:%S%nn%S <?php echo __(' Until next '); ?>)' ,
labels : [ '' , '' , '' , '' , '' , '' , '' ],
onExpiry : function () {
2023-03-28 12:39:02 +02:00
$ ( " #table_events " )
. DataTable ()
. draw ( false );
2019-08-19 11:32:40 +02:00
}
});
}
// Start the countdown when page is loaded (first time).
events_refresh ();
// Repeat countdown according to refresh_interval.
setInterval ( events_refresh , refresh_interval );
2023-03-28 12:39:02 +02:00
$ ( " select#refresh " ) . on ( 'select2:select' , function () {
2019-08-19 11:32:40 +02:00
var href = window . location . href ;
inputs = $ ( " #events_form :input " );
values = {};
inputs . each ( function () {
2022-11-22 11:35:38 +01:00
if ( this . name === 'server_id' ) {
values [ this . name ] = $ ( this ) . val () . join ();
} else {
values [ this . name ] = $ ( this ) . val ();
}
2019-08-19 11:32:40 +02:00
})
var newValue = btoa ( JSON . stringify ( values ));
var fb64 = '<?php echo $fb64; ?>' ;
// Check if the filters have changed.
if ( fb64 !== newValue ){
href = href . replace ( fb64 , newValue );
}
href = href . replace ( 'refr=' + refresh_time , 'refr=' + this . value );
$ ( document ) . attr ( " location " , href );
});
2023-03-28 12:39:02 +02:00
$ ( " div.events-pure " ) . removeClass ( " fixed_filter_bar invisible " );
$ ( " div#principal_action_buttons " ) . addClass ( " w100p " );
$ ( " table#table_events " ) . addClass ( " margn-b-50px " );
$ ( '#refresh' ) . val ( '<?php echo $config[' refr ']; ?>' ) . trigger ( 'change' );
2019-08-19 11:32:40 +02:00
}
2023-12-05 16:48:12 +01:00
const urlSearch = window . location . search ;
const urlParams = new URLSearchParams ( urlSearch );
if ( urlParams . has ( " settings " )) {
let modal_parameters = " " ;
if ( urlParams . has ( " parameters " )) {
modal_parameters = urlParams . get ( " parameters " );
}
let settings = urlParams . get ( " settings " );
openSoundEventsDialog ( settings , modal_parameters );
}
2019-06-11 12:58:18 +02:00
});
2022-11-18 14:04:54 +01:00
function checked_slide_events ( element ) {
2022-07-05 17:02:40 +02:00
var value = $ ( " #checkbox- " + element . name ) . val ();
if ( value == 0 ) {
$ ( " #checkbox- " + element . name ) . val ( 1 );
} else {
$ ( " #checkbox- " + element . name ) . val ( 0 );
}
}
2019-06-07 21:22:07 +02:00
2019-06-07 17:35:13 +02:00
function datetime_picker_callback () {
$ ( " #text-time_from, #text-time_to " ) . timepicker ({
showSecond : true ,
timeFormat : '<?php echo TIME_FORMAT_JS; ?>' ,
timeOnlyTitle : '<?php echo __(' Choose time '); ?>' ,
timeText : '<?php echo __(' Time '); ?>' ,
hourText : '<?php echo __(' Hour '); ?>' ,
minuteText : '<?php echo __(' Minute '); ?>' ,
secondText : '<?php echo __(' Second '); ?>' ,
currentText : '<?php echo __(' Now '); ?>' ,
closeText : '<?php echo __(' Close '); ?>' });
$ ( " #text-date_from, #text-date_to " ) . datepicker ({ dateFormat : " <?php echo DATE_FORMAT_JS; ?> " });
$ . datepicker . setDefaults ( $ . datepicker . regional [ " <?php echo get_user_language(); ?> " ]);
};
datetime_picker_callback ();
2019-09-24 15:14:17 +02:00
function show_instructions ( id ){
title = " <?php echo __('Instructions'); ?> " ;
$ ( '#hidden_event_instructions_' + id ) . dialog ({
title : title ,
width : 600
});
}
2019-06-07 17:35:13 +02:00
2023-02-24 10:04:23 +01:00
$ ( document ) . ready ( function () {
let moduleLabel = $ ( '#text-module_search' ) . prev ();
let moduleTip = $ ( '#text-module_search' ) . next () . next ();
moduleLabel . append ( moduleTip );
2023-02-27 09:57:17 +01:00
$ ( '.white_table_graph_header' ) . first () . append ( $ ( '.filter_summary' ));
2023-02-24 10:04:23 +01:00
});
2023-04-11 13:50:11 +02:00
// Show the modal window of an event
function show_event_dialo ( event , dialog_page ) {
var ajax_file = getUrlAjax ();
var view = `` ;
if ( $ ( " #event_details_window " ) . length ) {
view = " #event_details_window " ;
} else if ( $ ( " #sound_event_details_window " ) . length ) {
view = " #sound_event_details_window " ;
}
if ( dialog_page == undefined ) {
dialog_page = " general " ;
}
try {
event = event . replaceAll ( "   " , " + " );
event = JSON . parse ( atob ( event ), true );
} catch ( e ) {
console . error ( e );
return ;
}
var inputs = $ ( " #events_form :input " );
var values = {};
inputs . each ( function () {
values [ this . name ] = $ ( this ) . val ();
});
// Metaconsole mode flag
var meta = $ ( " #hidden-meta " ) . val ();
// History mode flag
var history = $ ( " #hidden-history " ) . val ();
2023-10-10 15:15:43 +02:00
console . log ( event );
2023-04-11 13:50:11 +02:00
jQuery . post (
ajax_file ,
{
page : " include/ajax/events " ,
get_extended_event : 1 ,
dialog_page : dialog_page ,
event : event ,
meta : meta ,
history : history ,
filter : values
},
function ( data ) {
$ ( view )
. hide ()
. empty ()
. append ( data )
. dialog ({
2023-10-10 15:15:43 +02:00
title : event . event_title ,
2023-04-11 13:50:11 +02:00
resizable : true ,
draggable : true ,
modal : true ,
minWidth : 875 ,
minHeight : 600 ,
close : function () {
$ ( " #refrcounter " ) . countdown ( " resume " );
$ ( " div.vc-countdown " ) . countdown ( " resume " );
},
overlay : {
opacity : 0.5 ,
background : " black "
},
width : 710 ,
height : 650 ,
autoOpen : true ,
open : function () {
if (
$ . ui &&
$ . ui . dialog &&
$ . ui . dialog . prototype . _allowInteraction
) {
var ui_dialog_interaction =
$ . ui . dialog . prototype . _allowInteraction ;
$ . ui . dialog . prototype . _allowInteraction = function ( e ) {
if ( $ ( e . target ) . closest ( " .select2-dropdown " ) . length )
return true ;
return ui_dialog_interaction . apply ( this , arguments );
};
}
},
_allowInteraction : function ( event ) {
return !! $ ( event . target ) . is ( " .select2-input " ) || this . _super ( event );
}
})
. show ();
$ ( " #refrcounter " ) . countdown ( " pause " );
$ ( " div.vc-countdown " ) . countdown ( " pause " );
forced_title_callback ();
},
" html "
);
return false ;
}
2023-10-04 12:41:23 +02:00
function show_events_graph (){
var inputs = $ ( " #events_form :input " );
var values = {};
inputs . each ( function () {
values [ this . name ] = $ ( this ) . val ();
});
$ . ajax ({
method : 'POST' ,
url : '<?php echo ui_get_full_url(' ajax . php '); ?>' ,
data : {
page : 'include/ajax/events' ,
drawEventsGraph : true ,
filter : values
},
success : function ( data ){
$ ( '#events-graph' )
. empty ()
. html ( data );
}
});
}
2019-06-07 17:35:13 +02:00
</ script >