Merge branch '3631_Unidades_no_se_muestran_en_informes_de_graficas_combinadas' into 'develop'

Added module units in module graphs

See merge request artica/pandorafms!2237
This commit is contained in:
Daniel Rodriguez 2019-05-08 16:36:43 +02:00
commit ac101af72f
3 changed files with 15 additions and 12 deletions

View File

@ -3541,25 +3541,21 @@ function series_type_graph_array($data, $show_elements_graph)
break;
}
if (isset($show_elements_graph['labels'])
if (isset($show_elements_graph['labels'][$value['agent_module_id']])
&& is_array($show_elements_graph['labels'])
&& (count($show_elements_graph['labels']) > 0)
) {
if ($show_elements_graph['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
}
$name_legend = $data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].' ';
} else {
if (strpos($key, 'baseline') !== false) {
if ($show_elements_graph['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].'Baseline ';
if ($value['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].'Baseline ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].'Baseline ';
}
} else {
if ($show_elements_graph['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': ';
if ($value['unit']) {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].': ';
} else {
$name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': ';
}

View File

@ -256,6 +256,7 @@ function grafico_modulo_sparse_data(
$array_data['sum'.$series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data['sum'.$series_suffix]['module_name'] = $data_module_graph['module_name'];
$array_data['sum'.$series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
$array_data['sum'.$series_suffix]['unit'] = $data_module_graph['unit'];
// This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
if ($params['force_interval'] != '') {
@ -759,6 +760,7 @@ function grafico_modulo_sparse($params)
$data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph['unit'] = $module_data['unit'];
} else {
$data_module_graph = false;
}
@ -1225,11 +1227,11 @@ function graphic_combined_module(
foreach ($sources as $source) {
array_push($modules, $source['id_agent_module']);
array_push($weights, $source['weight']);
if ($source['label'] != '') {
if ($source['label'] != '' || $params_combined['labels']) {
$item['type'] = 'custom_graph';
$item['id_agent'] = agents_get_module_id($source['id_agent_module']);
$item['id_agent_module'] = $source['id_agent_module'];
$labels[$source['id_agent_module']] = reporting_label_macro($item, $source['label']);
$labels[$source['id_agent_module']] = ($source['label'] != '') ? reporting_label_macro($item, $source['label']) : reporting_label_macro($item, $params_combined['labels']);
}
}
}
@ -1357,6 +1359,7 @@ function graphic_combined_module(
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph['module_id'] = $agent_module_id;
$data_module_graph['unit'] = $module_data['unit'];
// stract data
$array_data_module = grafico_modulo_sparse_data(

View File

@ -4439,6 +4439,9 @@ function reporting_value($report, $content, $type, $pdf=false)
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['agents'] = [$content['id_agent']];
$return['id_agent'] = $content['id_agent'];
$return['id_agent_module'] = $content['id_agent_module'];
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
@ -7267,6 +7270,7 @@ function reporting_custom_graph(
'modules_series' => $graphs[0]['modules_series'],
'id_graph' => $id_graph,
'type_report' => $type_report,
'labels' => $content['style']['label'],
];
$return['chart'] = graphic_combined_module(