Merge branch 'ent-11361-metaconsola-reporte-exportado-a-pdf-no-trae-grafica-horizontal-de-sla' into 'develop'

Ent 11361 metaconsola reporte exportado a pdf no trae grafica horizontal de sla

See merge request artica/pandorafms!5968
This commit is contained in:
Rafael Ameijeiras 2023-05-30 09:39:01 +00:00
commit d1a0c9697d
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']; $session_id = $data_decoded['session_id'];
$type_graph_pdf = $data_decoded['type_graph_pdf']; $type_graph_pdf = $data_decoded['type_graph_pdf'];
$id_user = $data_decoded['id_user']; $id_user = $data_decoded['id_user'];
$slicebar = $data_decoded['slicebar'];
$slicebar_value = $data_decoded['slicebar_value'];
$data_combined = []; $data_combined = [];
if (isset($data_decoded['data_combined']) === true) { if (isset($data_decoded['data_combined']) === true) {
@ -64,6 +66,9 @@ global $config;
// Care whit this!!! check_login not working if you remove this. // Care whit this!!! check_login not working if you remove this.
$config['id_user'] = $id_user; $config['id_user'] = $id_user;
$_SESSION['id_usuario'] = $id_user; $_SESSION['id_usuario'] = $id_user;
if (!isset($config[$slicebar])) {
$config[$slicebar] = $slicebar_value;
}
// Try to initialize session using existing php session id. // Try to initialize session using existing php session id.
$user = new PandoraFMS\User(['phpsessionid' => $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) function delete_config_token($cfgtoken)
{ {
$delete = db_process_sql(sprintf('DELETE FROM tconfig WHERE token = "%s"', $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_module_list' => $module_list,
'data_combined' => $params_combined, 'data_combined' => $params_combined,
'id_user' => $config['id_user'], 'id_user' => $config['id_user'],
'slicebar' => $_SESSION['slicebar'],
'slicebar_value' => $config[$_SESSION['slicebar']],
]; ];
} else { } else {
$data = [ $data = [
@ -4291,6 +4312,8 @@ function generator_chart_to_pdf(
'session_id' => $session_id, 'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf, 'type_graph_pdf' => $type_graph_pdf,
'id_user' => $config['id_user'], '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, 'server_id' => $server_id,
]; ];
// TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET. // 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 = '<img src="data:image/png;base64,';
$graph .= generator_chart_to_pdf('slicebar', $params); $graph .= generator_chart_to_pdf('slicebar', $params);
$graph .= '" />'; $graph .= '" />';