From 526168e0eb6b77cd4ae444fdcaa4dbd1b2745050 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 26 May 2023 11:57:51 +0200 Subject: [PATCH] #11361 SLA Grpah correction PDF Metaconsole --- pandora_console/include/chart_generator.php | 5 ++++ pandora_console/include/functions.php | 23 +++++++++++++++++++ .../include/graphs/functions_flot.php | 5 ++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 62701365e5..2695b89c22 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -46,6 +46,8 @@ if (json_last_error() === JSON_ERROR_NONE) { $session_id = $data_decoded['session_id']; $type_graph_pdf = $data_decoded['type_graph_pdf']; $id_user = $data_decoded['id_user']; + $slicebar = $data_decoded['slicebar']; + $slicebar_value = $data_decoded['slicebar_value']; $data_combined = []; if (isset($data_decoded['data_combined']) === true) { @@ -64,6 +66,9 @@ global $config; // Care whit this!!! check_login not working if you remove this. $config['id_user'] = $id_user; $_SESSION['id_usuario'] = $id_user; +if (!isset($config[$slicebar])) { + $config[$slicebar] = $slicebar_value; +} // Try to initialize session using existing php session id. $user = new PandoraFMS\User(['phpsessionid' => $session_id]); diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 81799a549d..7f59f6e598 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3548,6 +3548,25 @@ function update_config_token($cfgtoken, $cfgvalue) } +function update_check_config_token($cfgtoken, $cfgvalue) +{ + global $config; + db_process_sql('START TRANSACTION'); + if (isset($config[$cfgtoken])) { + delete_config_token($cfgtoken); + } + + $insert = db_process_sql(sprintf("INSERT INTO tconfig (token, value) VALUES ('%s', '%s')", $cfgtoken, $cfgvalue)); + db_process_sql('COMMIT'); + if ($insert) { + $config[$cfgtoken] = $cfgvalue; + return true; + } else { + return false; + } +} + + function delete_config_token($cfgtoken) { $delete = db_process_sql(sprintf('DELETE FROM tconfig WHERE token = "%s"', $cfgtoken)); @@ -4284,6 +4303,8 @@ function generator_chart_to_pdf( 'data_module_list' => $module_list, 'data_combined' => $params_combined, 'id_user' => $config['id_user'], + 'slicebar' => $_SESSION['slicebar'], + 'slicebar_value' => $config[$_SESSION['slicebar']], ]; } else { $data = [ @@ -4291,6 +4312,8 @@ function generator_chart_to_pdf( 'session_id' => $session_id, 'type_graph_pdf' => $type_graph_pdf, 'id_user' => $config['id_user'], + 'slicebar' => $_SESSION['slicebar'], + 'slicebar_value' => $config[$_SESSION['slicebar']], ]; } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 1ee377f290..d1856b7b4c 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -756,8 +756,9 @@ function flot_slicesbar_graph( 'server_id' => $server_id, ]; // TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET. - update_config_token($tokem_config, json_encode($graph_data)); - + update_check_config_token($tokem_config, json_encode($graph_data)); + $_SESSION['slicebar'] = $tokem_config; + $_SESSION['slicebar_value'] = json_encode($graph_data); $graph = '';