From 8c6c4d99a092a480c6fcaf857751f5bd9906e1a6 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 13 Oct 2020 09:32:28 +0200 Subject: [PATCH] fixed sql graph pie --- pandora_console/include/functions_graph.php | 98 +++++++++++---------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 55ef41ef31..4ac74e9637 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3737,14 +3737,18 @@ function graph_custom_sql_graph( global $config; $SQL_GRAPH_MAX_LABEL_SIZE = 20; - - if (is_metaconsole() && $content['server_name'] !== '0') { - $server = metaconsole_get_connection_names(); - $connection = metaconsole_get_connection($server); + if (is_metaconsole() === true + && empty($content['server_name']) === false + ) { + $connection = metaconsole_get_connection($content['server_name']); metaconsole_connect($connection); } - $report_content = db_get_row('treport_content', 'id_rc', $content['id_rc']); + $report_content = db_get_row( + 'treport_content', + 'id_rc', + $content['id_rc'] + ); if ($report_content == false || $report_content == '') { $report_content = db_get_row( @@ -3755,7 +3759,9 @@ function graph_custom_sql_graph( } if ($report_content == false || $report_content == '') { - if (is_metaconsole() && $content['server_name'] !== '0') { + if (is_metaconsole() === true + && empty($content['server_name']) === false + ) { enterprise_hook('metaconsole_restore_db'); } @@ -3772,9 +3778,10 @@ function graph_custom_sql_graph( ); } - if ((is_metaconsole() & $content['server_name']) !== '0') { - $server = metaconsole_get_connection_names(); - $connection = metaconsole_get_connection($server); + if (is_metaconsole() === true + && empty($content['server_name']) === false + ) { + $connection = metaconsole_get_connection($content['server_name']); metaconsole_connect($connection); } } @@ -3800,7 +3807,7 @@ function graph_custom_sql_graph( $data_result = db_get_all_rows_sql($sql, $historical_db); - if ((is_metaconsole() & $content['server_name']) !== '0') { + if (is_metaconsole() === true && empty($content['server_name']) === false) { enterprise_hook('metaconsole_restore_db'); } @@ -3908,6 +3915,7 @@ function graph_custom_sql_graph( ]; } + $output = ''; switch ($type) { case 'sql_graph_vbar': default: @@ -3936,48 +3944,48 @@ function graph_custom_sql_graph( $output .= vbar_graph($data, $options, $ttl); $output .= ''; } - return $output; + break; - break; case 'sql_graph_hbar': // Horizontal bar. - return hbar_graph( - $data, - $width, - $height, - [], - [], - '', - '', - '', - '', - $water_mark, - $config['fontpath'], - $config['font_size'], - false, - $ttl, - $homeurl, - 'white', - '#c1c1c1' - ); + $output .= hbar_graph( + $data, + $width, + $height, + [], + [], + '', + '', + '', + '', + $water_mark, + $config['fontpath'], + $config['font_size'], + false, + $ttl, + $homeurl, + 'white', + '#c1c1c1' + ); + break; - break; case 'sql_graph_pie': // Pie. - return pie_graph( - $data, - $width, - $height, - __('other'), - $homeurl, - $water_mark, - $config['fontpath'], - $config['font_size'], - $ttl - ); - - break; + $output .= pie_graph( + $data, + $width, + $height, + __('other'), + $homeurl, + $water_mark, + $config['fontpath'], + $config['font_size'], + $ttl + ); + break; } + + return $output; }