#11361 SLA Grpah correction PDF Metaconsole

This commit is contained in:
Jonathan 2023-05-26 11:57:51 +02:00
parent a32d9351df
commit 526168e0eb
3 changed files with 31 additions and 2 deletions

View File

@ -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]);

View File

@ -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']],
];
}

View File

@ -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 = '<img src="data:image/png;base64,';
$graph .= generator_chart_to_pdf('slicebar', $params);
$graph .= '" />';