diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0bfe96e864..674da95b09 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4979,6 +4979,16 @@ function reporting_agent_configuration($report, $content) } +/** + * Report Min, Max and Avg. + * + * @param array $report Info report. + * @param array $content Content report. + * @param string $type Type report. + * @param boolean $pdf Is pdf. + * + * @return array Data draw report. + */ function reporting_value($report, $content, $type, $pdf=false) { global $config; @@ -4993,16 +5003,17 @@ function reporting_value($report, $content, $type, $pdf=false) $return['type'] = 'min_value'; break; - case 'avg': - $return['type'] = 'avg_value'; - break; - case 'sum': $return['type'] = 'sumatory'; break; + + case 'avg': + default: + $return['type'] = 'avg_value'; + break; } - if (empty($content['name'])) { + if (empty($content['name']) === true) { switch ($type) { case 'max': $content['name'] = __('Max. Value'); @@ -5012,17 +5023,18 @@ function reporting_value($report, $content, $type, $pdf=false) $content['name'] = __('Min. Value'); break; - case 'avg': - $content['name'] = __('AVG. Value'); - break; - case 'sum': $content['name'] = __('Summatory'); break; + + case 'avg': + default: + $content['name'] = __('AVG. Value'); + break; } } - if ($config['metaconsole']) { + if (is_metaconsole() === true) { $id_meta = metaconsole_get_id_server($content['server_name']); $server = metaconsole_get_connection_by_id($id_meta); @@ -5060,14 +5072,15 @@ function reporting_value($report, $content, $type, $pdf=false) $return['agent_name'] = $agent_name; $return['module_name'] = $module_name; + $only_image = false; if ($pdf) { - $only_image = 1; + $only_image = true; } $params = [ 'agent_module_id' => $content['id_agent_module'], 'period' => $content['period'], - 'width' => '600px', + 'width' => '90%', 'pure' => false, 'date' => $report['datetime'], 'only_image' => $only_image, @@ -5086,6 +5099,7 @@ function reporting_value($report, $content, $type, $pdf=false) case 'max': case 'min': case 'avg': + default: $divisor = get_data_multiplier($unit); if ($content['lapse_calc'] == 0) { @@ -5107,6 +5121,7 @@ function reporting_value($report, $content, $type, $pdf=false) break; case 'avg': + default: $value = reporting_get_agentmodule_data_average( $content['id_agent_module'], $content['period'], @@ -5118,7 +5133,14 @@ function reporting_value($report, $content, $type, $pdf=false) if (!$config['simple_module_value']) { $formated_value = $value; } else { - $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit); + $formated_value = format_for_graph( + $value, + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); } } else { $return['visual_format'] = $content['visual_format']; @@ -5126,17 +5148,51 @@ function reporting_value($report, $content, $type, $pdf=false) switch ($type) { case 'max': $params['force_interval'] = 'max_only'; - $value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + $value = format_for_graph( + reporting_get_agentmodule_data_max( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; case 'min': $params['force_interval'] = 'min_only'; - $value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + $value = format_for_graph( + reporting_get_agentmodule_data_min( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; case 'avg': + default: $params['force_interval'] = 'avg_only'; - $value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit); + $value = format_for_graph( + reporting_get_agentmodule_data_average( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; } @@ -5166,15 +5222,49 @@ function reporting_value($report, $content, $type, $pdf=false) if ($i > $time_begin['utimestamp']) { switch ($type) { case 'max': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + $row[__('Maximun')] = format_for_graph( + reporting_get_agentmodule_data_max( + $content['id_agent_module'], + $content['lapse'], + ($i + $content['lapse']) + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; case 'min': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + $row[__('Maximun')] = format_for_graph( + reporting_get_agentmodule_data_min( + $content['id_agent_module'], + $content['lapse'], + ($i + $content['lapse']) + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; case 'avg': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit); + default: + $row[__('Maximun')] = format_for_graph( + reporting_get_agentmodule_data_average( + $content['id_agent_module'], + $content['lapse'], + ($i + $content['lapse']) + ), + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); break; } } else { @@ -5185,7 +5275,7 @@ function reporting_value($report, $content, $type, $pdf=false) } } - if ($config['metaconsole']) { + if (is_metaconsole() === true) { metaconsole_restore_db(); } @@ -5205,7 +5295,14 @@ function reporting_value($report, $content, $type, $pdf=false) } else { $divisor = get_data_multiplier($unit); - $formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit); + $formated_value = format_for_graph( + $value, + $config['graph_precision'], + '.', + ',', + $divisor, + $unit + ); } break; } @@ -5215,7 +5312,7 @@ function reporting_value($report, $content, $type, $pdf=false) 'formated_value' => $formated_value, ]; - if ($config['metaconsole']) { + if (is_metaconsole() === true) { metaconsole_restore_db(); } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 0de6b542bd..a9f7acadb9 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2965,8 +2965,26 @@ function reporting_html_min_value(&$table, $item, $mini) } -function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_empty=false) -{ +/** + * Htlm report AVg, min, Max, Only. + * + * @param array $table Table. + * @param array $item Data. + * @param boolean $mini Is mini. + * @param boolean $only_value Only value. + * @param boolean $check_empty Empty. + * @param integer $pdf PDF Mode. + * + * @return string Html output. + */ +function reporting_html_value( + $table, + $item, + $mini, + $only_value=false, + $check_empty=false, + $pdf=0 +) { global $config; if ($mini) { @@ -2975,8 +2993,12 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e $font_size = $config['font_size_item_report'].'em'; } - if (isset($item['visual_format']) && $item['visual_format'] != 0 - && ($item['type'] == 'max_value' || $item['type'] == 'min_value' || $item['type'] == 'avg_value') + $return_pdf = ''; + + if (isset($item['visual_format']) === true && $item['visual_format'] != 0 + && ($item['type'] == 'max_value' + || $item['type'] == 'min_value' + || $item['type'] == 'avg_value') ) { $table2 = new stdClass(); $table2->width = '100%'; @@ -2998,6 +3020,7 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e break; case 'avg_value': + default: $table2->head = [ __('Agent'), __('Module'), @@ -3025,15 +3048,28 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e $table->colspan[2][0] = 3; $table->colspan[3][0] = 3; - array_push($table->data, html_print_table($table2, true)); + if ($pdf === 0) { + array_push($table->data, html_print_table($table2, true)); + } else { + $return_pdf .= html_print_table($table2, true); + } + unset($item['data'][0]); if ($item['visual_format'] != 1) { $value = $item['data'][1]['value']; - array_push($table->data, $value); - unset($item['data'][1]); + if ($pdf === 0) { + array_push($table->data, $value); + } else { + $style_div_pdf = 'text-align:center;margin-bottom:20px;'; + $return_pdf .= '