mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge branch 'ent-6453-Bug-visual-en-item-SQL-PIE-Graph-Metaconsola' into 'develop'
fixed sql graph pie See merge request artica/pandorafms!3520
This commit is contained in:
commit
3c932e1e71
@ -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 array $content ID of report content
|
||||||
* @param integer height graph height
|
* used to get SQL code to get information for graph.
|
||||||
* @param integer width graph width
|
* @param integer $width Graph width.
|
||||||
* @param integer Graph type 1 vbar, 2 hbar, 3 pie
|
* @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(
|
function graph_custom_sql_graph(
|
||||||
$content,
|
$content,
|
||||||
@ -3740,7 +3747,11 @@ function graph_custom_sql_graph(
|
|||||||
$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('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 == '') {
|
if ($report_content == false || $report_content == '') {
|
||||||
@ -3748,9 +3759,17 @@ function graph_custom_sql_graph(
|
|||||||
enterprise_hook('metaconsole_restore_db');
|
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 == '') {
|
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') {
|
if ((is_metaconsole() & $content['server_name']) !== '0') {
|
||||||
@ -3761,7 +3780,9 @@ function graph_custom_sql_graph(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($id != null) {
|
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 {
|
} else {
|
||||||
$historical_db = $content['historical_db'];
|
$historical_db = $content['historical_db'];
|
||||||
}
|
}
|
||||||
@ -3769,7 +3790,11 @@ function graph_custom_sql_graph(
|
|||||||
if ($report_content['external_source'] != '') {
|
if ($report_content['external_source'] != '') {
|
||||||
$sql = io_safe_output($report_content['external_source']);
|
$sql = io_safe_output($report_content['external_source']);
|
||||||
} else {
|
} 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']);
|
$sql = io_safe_output($sql['sql']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3790,24 +3815,32 @@ function graph_custom_sql_graph(
|
|||||||
foreach ($data_result as $data_item) {
|
foreach ($data_result as $data_item) {
|
||||||
$count++;
|
$count++;
|
||||||
$value = 0;
|
$value = 0;
|
||||||
if (!empty($data_item['value'])) {
|
if (empty($data_item['value']) === false) {
|
||||||
$value = $data_item['value'];
|
$value = $data_item['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($count <= $max_num_elements) {
|
if ($count <= $max_num_elements) {
|
||||||
$label = __('Data');
|
$label = __('Data');
|
||||||
if (!empty($data_item['label'])) {
|
if (empty($data_item['label']) === false) {
|
||||||
$label = io_safe_output($data_item['label']);
|
$label = io_safe_output($data_item['label']);
|
||||||
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
|
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
|
||||||
$first_label = $label;
|
$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 .= '...';
|
||||||
$label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2));
|
$label .= substr(
|
||||||
|
$first_label,
|
||||||
|
floor(-$SQL_GRAPH_MAX_LABEL_SIZE / 2)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'sql_graph_vbar':
|
case 'sql_graph_vbar':
|
||||||
|
default:
|
||||||
// Vertical bar.
|
// Vertical bar.
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'tick' => $label.'_'.$count,
|
'tick' => $label.'_'.$count,
|
||||||
@ -3816,18 +3849,19 @@ function graph_custom_sql_graph(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sql_graph_hbar':
|
case 'sql_graph_hbar':
|
||||||
// horizontal bar
|
// Horizontal bar.
|
||||||
$data[$label.'_'.$count]['g'] = $value;
|
$data[$label.'_'.$count]['g'] = $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sql_graph_pie':
|
case 'sql_graph_pie':
|
||||||
// Pie
|
// Pie.
|
||||||
$data[$label.'_'.$count] = $value;
|
$data[$label.'_'.$count] = $value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'sql_graph_vbar':
|
case 'sql_graph_vbar':
|
||||||
|
default:
|
||||||
// Vertical bar.
|
// Vertical bar.
|
||||||
if ($flagOther === false) {
|
if ($flagOther === false) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
@ -3842,8 +3876,8 @@ function graph_custom_sql_graph(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sql_graph_hbar':
|
case 'sql_graph_hbar':
|
||||||
// horizontal bar
|
// Horizontal bar.
|
||||||
if (!isset($data[__('Other')]['g'])) {
|
if (isset($data[__('Other')]['g']) === false) {
|
||||||
$data[__('Other')]['g'] = 0;
|
$data[__('Other')]['g'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3851,8 +3885,8 @@ function graph_custom_sql_graph(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sql_graph_pie':
|
case 'sql_graph_pie':
|
||||||
// Pie
|
// Pie.
|
||||||
if (!isset($data[__('Other')])) {
|
if (isset($data[__('Other')]) === false) {
|
||||||
$data[__('Other')] = 0;
|
$data[__('Other')] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3865,12 +3899,18 @@ function graph_custom_sql_graph(
|
|||||||
if ($config['fixed_graph'] == false) {
|
if ($config['fixed_graph'] == false) {
|
||||||
$water_mark = [
|
$water_mark = [
|
||||||
'file' => $config['homedir'].'/images/logo_vertical_water.png',
|
'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) {
|
switch ($type) {
|
||||||
case 'sql_graph_vbar':
|
case 'sql_graph_vbar':
|
||||||
|
default:
|
||||||
// Vertical bar.
|
// Vertical bar.
|
||||||
$color = color_graph_array();
|
$color = color_graph_array();
|
||||||
|
|
||||||
@ -3900,7 +3940,7 @@ function graph_custom_sql_graph(
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'sql_graph_hbar':
|
case 'sql_graph_hbar':
|
||||||
// horizontal bar
|
// Horizontal bar.
|
||||||
return hbar_graph(
|
return hbar_graph(
|
||||||
$data,
|
$data,
|
||||||
$width,
|
$width,
|
||||||
@ -3923,7 +3963,7 @@ function graph_custom_sql_graph(
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'sql_graph_pie':
|
case 'sql_graph_pie':
|
||||||
// Pie
|
// Pie.
|
||||||
return pie_graph(
|
return pie_graph(
|
||||||
$data,
|
$data,
|
||||||
$width,
|
$width,
|
||||||
|
@ -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(
|
function reporting_sql_graph(
|
||||||
$report,
|
$report,
|
||||||
$content,
|
$content,
|
||||||
@ -4380,6 +4392,7 @@ function reporting_sql_graph(
|
|||||||
|
|
||||||
switch ($type_sql_graph) {
|
switch ($type_sql_graph) {
|
||||||
case 'sql_graph_hbar':
|
case 'sql_graph_hbar':
|
||||||
|
default:
|
||||||
$return['type'] = 'sql_graph_hbar';
|
$return['type'] = 'sql_graph_hbar';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4392,9 +4405,10 @@ function reporting_sql_graph(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($content['name'])) {
|
if (empty($content['name']) === true) {
|
||||||
switch ($type_sql_graph) {
|
switch ($type_sql_graph) {
|
||||||
case 'sql_graph_vbar':
|
case 'sql_graph_vbar':
|
||||||
|
default:
|
||||||
$content['name'] = __('SQL Graph Vertical Bars');
|
$content['name'] = __('SQL Graph Vertical Bars');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4409,13 +4423,20 @@ function reporting_sql_graph(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get chart.
|
// 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;
|
$width = $force_width_chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($force_height_chart)) {
|
if (empty($force_height_chart) === false) {
|
||||||
$height = $force_height_chart;
|
$height = $force_height_chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4431,7 +4452,7 @@ function reporting_sql_graph(
|
|||||||
WHERE id_graph = '.$content['id_gs']
|
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 = [];
|
$modules = [];
|
||||||
foreach ($module_source as $key => $value) {
|
foreach ($module_source as $key => $value) {
|
||||||
$modules[$key] = $value['id_agent_module'];
|
$modules[$key] = $value['id_agent_module'];
|
||||||
@ -4441,6 +4462,7 @@ function reporting_sql_graph(
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'dinamic':
|
case 'dinamic':
|
||||||
case 'static':
|
case 'static':
|
||||||
|
default:
|
||||||
$return['chart'] = graph_custom_sql_graph(
|
$return['chart'] = graph_custom_sql_graph(
|
||||||
$content,
|
$content,
|
||||||
$width,
|
$width,
|
||||||
@ -8575,6 +8597,7 @@ function reporting_set_conf_charts(
|
|||||||
) {
|
) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'dinamic':
|
case 'dinamic':
|
||||||
|
default:
|
||||||
$only_image = false;
|
$only_image = false;
|
||||||
$width = 900;
|
$width = 900;
|
||||||
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230;
|
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230;
|
||||||
@ -8584,25 +8607,17 @@ function reporting_set_conf_charts(
|
|||||||
case 'static':
|
case 'static':
|
||||||
$ttl = 2;
|
$ttl = 2;
|
||||||
$only_image = true;
|
$only_image = true;
|
||||||
$height = 360;
|
$height = isset($content['style']['dyn_height']) ? $content['style']['dyn_height'] : 230;
|
||||||
$width = 780;
|
$width = 780;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'data':
|
case 'data':
|
||||||
|
// Nothing.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// MAYBE MOVE THE NEXT FUNCTIONS TO A FILE NAMED AS FUNCTION_REPORTING.UTILS.PHP //
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a detailed report of summarized events per agent
|
* Get a detailed report of summarized events per agent
|
||||||
*
|
*
|
||||||
|
@ -376,10 +376,22 @@ function menu_graph(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
/**
|
||||||
//
|
* Pie chart.
|
||||||
//
|
*
|
||||||
// Prints a FLOT 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(
|
function flot_pie_chart(
|
||||||
$values,
|
$values,
|
||||||
$labels,
|
$labels,
|
||||||
@ -392,9 +404,9 @@ function flot_pie_chart(
|
|||||||
$colors='',
|
$colors='',
|
||||||
$hide_labels=false
|
$hide_labels=false
|
||||||
) {
|
) {
|
||||||
// include_javascript_dependencies_flot_graph();
|
$series = count($values);
|
||||||
$series = sizeof($values);
|
|
||||||
if (($series != sizeof($labels)) || ($series == 0)) {
|
if (($series !== count($labels)) || ($series === 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,11 +419,11 @@ function flot_pie_chart(
|
|||||||
|
|
||||||
case 'right':
|
case 'right':
|
||||||
default:
|
default:
|
||||||
// TODO FOR TOP OR LEFT OR RIGHT
|
// TODO FOR TOP OR LEFT OR RIGHT.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = "<div id='$graph_id' class='graph' style='width: ".$width.'px; height: '.$height."px;'></div>";
|
$return = "<div id='".$graph_id."' class='graph' style='width: ".$width.'px; height: '.$height."px;'></div>";
|
||||||
|
|
||||||
if ($water_mark != '') {
|
if ($water_mark != '') {
|
||||||
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
||||||
@ -424,15 +436,24 @@ function flot_pie_chart(
|
|||||||
|
|
||||||
$labels = implode($separator, $labels);
|
$labels = implode($separator, $labels);
|
||||||
$values = implode($separator, $values);
|
$values = implode($separator, $values);
|
||||||
if (!empty($colors)) {
|
if (empty($colors) === false) {
|
||||||
$colors = implode($separator, $colors);
|
$colors = implode($separator, $colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// include_javascript_dependencies_flot_graph();
|
|
||||||
$return .= "<script type='text/javascript'>";
|
$return .= "<script type='text/javascript'>";
|
||||||
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
$return .= "pandoraFlotPie(
|
||||||
'$series', '$width', $font_size, $water_mark, '$separator',
|
'$graph_id',
|
||||||
'$legend_position', '$height', '$colors', ".json_encode($hide_labels).')';
|
'$values',
|
||||||
|
'$labels',
|
||||||
|
'$series',
|
||||||
|
'$width',
|
||||||
|
$font_size,
|
||||||
|
$water_mark,
|
||||||
|
'$separator',
|
||||||
|
'$legend_position',
|
||||||
|
'$height',
|
||||||
|
'$colors',
|
||||||
|
".json_encode($hide_labels).')';
|
||||||
$return .= '</script>';
|
$return .= '</script>';
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -6019,3 +6019,12 @@ form#form-filter-interfaces ul li.select-interfaces {
|
|||||||
li .select2 {
|
li .select2 {
|
||||||
max-width: 400px !important;
|
max-width: 400px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.graph td.legendLabel {
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.graph div.legend div,
|
||||||
|
div.graph div.legend table {
|
||||||
|
top: 25px !important;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user