diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 0a243ccc66..55ef41ef31 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3710,12 +3710,19 @@ function grafico_eventos_usuario($width, $height) /** - * Print a custom SQL-defined graph + * Undocumented function * - * @param integer ID of report content, used to get SQL code to get information for graph - * @param integer height graph height - * @param integer width graph width - * @param integer Graph type 1 vbar, 2 hbar, 3 pie + * @param array $content ID of report content + * used to get SQL code to get information for graph. + * @param integer $width Graph width. + * @param integer $height Graph height. + * @param string $type Graph type 1 vbar, 2 hbar, 3 pie. + * @param boolean $only_image Only image. + * @param string $homeurl Url. + * @param integer $ttl Ttl. + * @param integer $max_num_elements Max elements. + * + * @return string Graph. */ function graph_custom_sql_graph( $content, @@ -3740,7 +3747,11 @@ function graph_custom_sql_graph( $report_content = db_get_row('treport_content', 'id_rc', $content['id_rc']); if ($report_content == false || $report_content == '') { - $report_content = db_get_row('treport_content_template', 'id_rc', $content['id_rc']); + $report_content = db_get_row( + 'treport_content_template', + 'id_rc', + $content['id_rc'] + ); } if ($report_content == false || $report_content == '') { @@ -3748,9 +3759,17 @@ function graph_custom_sql_graph( enterprise_hook('metaconsole_restore_db'); } - $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('treport_content_template', 'id_rc', $content['id_rc']); + $report_content = db_get_row( + 'treport_content_template', + 'id_rc', + $content['id_rc'] + ); } if ((is_metaconsole() & $content['server_name']) !== '0') { @@ -3761,7 +3780,9 @@ function graph_custom_sql_graph( } if ($id != null) { - $historical_db = db_get_value_sql('SELECT historical_db from treport_content where id_rc ='.$content['id_rc']); + $historical_db = db_get_value_sql( + 'SELECT historical_db from treport_content where id_rc ='.$content['id_rc'] + ); } else { $historical_db = $content['historical_db']; } @@ -3769,7 +3790,11 @@ function graph_custom_sql_graph( if ($report_content['external_source'] != '') { $sql = io_safe_output($report_content['external_source']); } else { - $sql = db_get_row('treport_custom_sql', 'id', $report_content['treport_custom_sql_id']); + $sql = db_get_row( + 'treport_custom_sql', + 'id', + $report_content['treport_custom_sql_id'] + ); $sql = io_safe_output($sql['sql']); } @@ -3790,24 +3815,32 @@ function graph_custom_sql_graph( foreach ($data_result as $data_item) { $count++; $value = 0; - if (!empty($data_item['value'])) { + if (empty($data_item['value']) === false) { $value = $data_item['value']; } if ($count <= $max_num_elements) { $label = __('Data'); - if (!empty($data_item['label'])) { + if (empty($data_item['label']) === false) { $label = io_safe_output($data_item['label']); if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) { $first_label = $label; - $label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE / 2)); + $label = substr( + $first_label, + 0, + floor($SQL_GRAPH_MAX_LABEL_SIZE / 2) + ); $label .= '...'; - $label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2)); + $label .= substr( + $first_label, + floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2) + ); } } switch ($type) { case 'sql_graph_vbar': + default: // Vertical bar. $data[] = [ 'tick' => $label.'_'.$count, @@ -3816,18 +3849,19 @@ function graph_custom_sql_graph( break; case 'sql_graph_hbar': - // horizontal bar + // Horizontal bar. $data[$label.'_'.$count]['g'] = $value; break; case 'sql_graph_pie': - // Pie + // Pie. $data[$label.'_'.$count] = $value; break; } } else { switch ($type) { case 'sql_graph_vbar': + default: // Vertical bar. if ($flagOther === false) { $data[] = [ @@ -3842,8 +3876,8 @@ function graph_custom_sql_graph( break; case 'sql_graph_hbar': - // horizontal bar - if (!isset($data[__('Other')]['g'])) { + // Horizontal bar. + if (isset($data[__('Other')]['g']) === false) { $data[__('Other')]['g'] = 0; } @@ -3851,8 +3885,8 @@ function graph_custom_sql_graph( break; case 'sql_graph_pie': - // Pie - if (!isset($data[__('Other')])) { + // Pie. + if (isset($data[__('Other')]) === false) { $data[__('Other')] = 0; } @@ -3865,12 +3899,18 @@ function graph_custom_sql_graph( if ($config['fixed_graph'] == false) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', - 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + 'url' => ui_get_full_url( + 'images/logo_vertical_water.png', + false, + false, + false + ), ]; } switch ($type) { case 'sql_graph_vbar': + default: // Vertical bar. $color = color_graph_array(); @@ -3900,7 +3940,7 @@ function graph_custom_sql_graph( break; case 'sql_graph_hbar': - // horizontal bar + // Horizontal bar. return hbar_graph( $data, $width, @@ -3923,7 +3963,7 @@ function graph_custom_sql_graph( break; case 'sql_graph_pie': - // Pie + // Pie. return pie_graph( $data, $width, diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3c530f3115..10a1992e18 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4368,6 +4368,18 @@ function reporting_alert_report_module($report, $content) } +/** + * Sql graph. + * + * @param array $report Info report. + * @param array $content Content. + * @param string $type Type. + * @param integer $force_width_chart Width. + * @param integer $force_height_chart Height. + * @param string $type_sql_graph Type. + * + * @return array Return array. + */ function reporting_sql_graph( $report, $content, @@ -4380,6 +4392,7 @@ function reporting_sql_graph( switch ($type_sql_graph) { case 'sql_graph_hbar': + default: $return['type'] = 'sql_graph_hbar'; break; @@ -4392,9 +4405,10 @@ function reporting_sql_graph( break; } - if (empty($content['name'])) { + if (empty($content['name']) === true) { switch ($type_sql_graph) { case 'sql_graph_vbar': + default: $content['name'] = __('SQL Graph Vertical Bars'); break; @@ -4409,13 +4423,20 @@ function reporting_sql_graph( } // Get chart. - reporting_set_conf_charts($width, $height, $only_image, $type, $content, $ttl); + reporting_set_conf_charts( + $width, + $height, + $only_image, + $type, + $content, + $ttl + ); - if (!empty($force_width_chart)) { + if (empty($force_width_chart) === false) { $width = $force_width_chart; } - if (!empty($force_height_chart)) { + if (empty($force_height_chart) === false) { $height = $force_height_chart; } @@ -4431,7 +4452,7 @@ function reporting_sql_graph( WHERE id_graph = '.$content['id_gs'] ); - if (isset($module_source) && is_array($module_source)) { + if (isset($module_source) === true && is_array($module_source) === true) { $modules = []; foreach ($module_source as $key => $value) { $modules[$key] = $value['id_agent_module']; @@ -4441,6 +4462,7 @@ function reporting_sql_graph( switch ($type) { case 'dinamic': case 'static': + default: $return['chart'] = graph_custom_sql_graph( $content, $width, @@ -8575,6 +8597,7 @@ function reporting_set_conf_charts( ) { switch ($type) { case 'dinamic': + default: $only_image = false; $width = 900; $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; @@ -8584,25 +8607,17 @@ function reporting_set_conf_charts( case 'static': $ttl = 2; $only_image = true; - $height = 360; + $height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230; $width = 780; break; case 'data': + // Nothing. break; } } -// -// -// -// MAYBE MOVE THE NEXT FUNCTIONS TO A FILE NAMED AS FUNCTION_REPORTING.UTILS.PHP // -// -// -// - - /** * Get a detailed report of summarized events per agent * diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 4b0bde1408..dc4e556292 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -376,10 +376,22 @@ function menu_graph( } -// -// -// -// Prints a FLOT pie chart +/** + * Pie chart. + * + * @param array $values Values. + * @param array $labels Labels. + * @param integer $width Width. + * @param integer $height Height. + * @param boolean $water_mark Water mark. + * @param string $font Font. + * @param integer $font_size Font Size. + * @param string $legend_position Psition Legend. + * @param string $colors Array Colors. + * @param boolean $hide_labels Hide labels. + * + * @return void + */ function flot_pie_chart( $values, $labels, @@ -392,9 +404,9 @@ function flot_pie_chart( $colors='', $hide_labels=false ) { - // include_javascript_dependencies_flot_graph(); - $series = sizeof($values); - if (($series != sizeof($labels)) || ($series == 0)) { + $series = count($values); + + if (($series !== count($labels)) || ($series === 0)) { return; } @@ -407,11 +419,11 @@ function flot_pie_chart( case 'right': default: - // TODO FOR TOP OR LEFT OR RIGHT + // TODO FOR TOP OR LEFT OR RIGHT. break; } - $return = "
"; + $return = ""; if ($water_mark != '') { $return .= " "; @@ -424,15 +436,24 @@ function flot_pie_chart( $labels = implode($separator, $labels); $values = implode($separator, $values); - if (!empty($colors)) { + if (empty($colors) === false) { $colors = implode($separator, $colors); } - // include_javascript_dependencies_flot_graph(); $return .= "'; return $return; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 0a5d7afb21..6b48ab13ae 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6019,3 +6019,12 @@ form#form-filter-interfaces ul li.select-interfaces { li .select2 { max-width: 400px !important; } + +div.graph td.legendLabel { + text-align: justify; +} + +div.graph div.legend div, +div.graph div.legend table { + top: 25px !important; +}