Merge branch 'ent-6467-No-funciona-el-select-de-nodos-en-los-items-de-graficas-sql' into 'develop'

fixed sql graph pie

See merge request artica/pandorafms!3523
This commit is contained in:
Daniel Rodriguez 2020-10-14 10:29:53 +02:00
commit 5b1d29e4cb
1 changed files with 53 additions and 45 deletions

View File

@ -3737,14 +3737,18 @@ function graph_custom_sql_graph(
global $config; global $config;
$SQL_GRAPH_MAX_LABEL_SIZE = 20; $SQL_GRAPH_MAX_LABEL_SIZE = 20;
if (is_metaconsole() === true
if (is_metaconsole() && $content['server_name'] !== '0') { && empty($content['server_name']) === false
$server = metaconsole_get_connection_names(); ) {
$connection = metaconsole_get_connection($server); $connection = metaconsole_get_connection($content['server_name']);
metaconsole_connect($connection); 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 == '') { if ($report_content == false || $report_content == '') {
$report_content = db_get_row( $report_content = db_get_row(
@ -3755,7 +3759,9 @@ function graph_custom_sql_graph(
} }
if ($report_content == false || $report_content == '') { 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'); enterprise_hook('metaconsole_restore_db');
} }
@ -3772,9 +3778,10 @@ function graph_custom_sql_graph(
); );
} }
if ((is_metaconsole() & $content['server_name']) !== '0') { if (is_metaconsole() === true
$server = metaconsole_get_connection_names(); && empty($content['server_name']) === false
$connection = metaconsole_get_connection($server); ) {
$connection = metaconsole_get_connection($content['server_name']);
metaconsole_connect($connection); metaconsole_connect($connection);
} }
} }
@ -3800,7 +3807,7 @@ function graph_custom_sql_graph(
$data_result = db_get_all_rows_sql($sql, $historical_db); $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'); enterprise_hook('metaconsole_restore_db');
} }
@ -3908,6 +3915,7 @@ function graph_custom_sql_graph(
]; ];
} }
$output = '';
switch ($type) { switch ($type) {
case 'sql_graph_vbar': case 'sql_graph_vbar':
default: default:
@ -3936,48 +3944,48 @@ function graph_custom_sql_graph(
$output .= vbar_graph($data, $options, $ttl); $output .= vbar_graph($data, $options, $ttl);
$output .= '</div>'; $output .= '</div>';
} }
return $output; break;
break;
case 'sql_graph_hbar': case 'sql_graph_hbar':
// Horizontal bar. // Horizontal bar.
return hbar_graph( $output .= hbar_graph(
$data, $data,
$width, $width,
$height, $height,
[], [],
[], [],
'', '',
'', '',
'', '',
'', '',
$water_mark, $water_mark,
$config['fontpath'], $config['fontpath'],
$config['font_size'], $config['font_size'],
false, false,
$ttl, $ttl,
$homeurl, $homeurl,
'white', 'white',
'#c1c1c1' '#c1c1c1'
); );
break;
break;
case 'sql_graph_pie': case 'sql_graph_pie':
// Pie. // Pie.
return pie_graph( $output .= pie_graph(
$data, $data,
$width, $width,
$height, $height,
__('other'), __('other'),
$homeurl, $homeurl,
$water_mark, $water_mark,
$config['fontpath'], $config['fontpath'],
$config['font_size'], $config['font_size'],
$ttl $ttl
); );
break;
break;
} }
return $output;
} }