From 00f779817d709cb3a10a6cffaf2c4200c1957c02 Mon Sep 17 00:00:00 2001
From: daniel <daniel.barbero@artica.es>
Date: Mon, 25 Sep 2017 13:26:04 +0200
Subject: [PATCH] fixed errors in report interfaces

---
 .../reporting_builder.item_editor.php         |  5 +++-
 .../godmode/reporting/reporting_builder.php   |  6 ++++
 pandora_console/include/functions_graph.php   | 30 +++++++++++++++----
 .../include/functions_reporting.php           | 20 +++++++++++--
 .../agentes/interface_traffic_graph_win.php   |  2 +-
 5 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
index 094199349f..534bf07a0b 100755
--- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php
+++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
@@ -482,6 +482,7 @@ switch ($action) {
 					$description = $item['description'];
 					$group = $item['id_group'];
 					$period = $item['period'];
+					$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
 					break;
 				case 'top_n':
 					$description = $item['description'];
@@ -1356,7 +1357,8 @@ You can of course remove the warnings, that's why we include the source and do n
 			<td><?php html_print_checkbox('only_avg', 1, $only_avg);?></td>
 		</tr>
 		<tr id="row_fullscale" style="" class="datos">
-			<td style="font-weight:bold;"><?php echo __('Full resolution graph (TIP)');?></td>
+			<td style="font-weight:bold;"><?php echo __('Full resolution graph (TIP)').
+					ui_print_help_tip(__('This option may cause performance issues.'), true);?></td>
 			<td><?php html_print_checkbox('fullscale', 1, $fullscale);?></td>
 		</tr>
 		<tr id="row_percentil" style="" class="datos">
@@ -3130,6 +3132,7 @@ function chooseType() {
 			$("#row_description").show();
 			$("#row_period").show();
 			$("#row_historical_db_check").hide();
+			$("#row_fullscale").show();
 			break;
 		
 		case 'top_n':
diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php
index ead62db0c9..4dd13e9af0 100755
--- a/pandora_console/godmode/reporting/reporting_builder.php
+++ b/pandora_console/godmode/reporting/reporting_builder.php
@@ -1180,6 +1180,9 @@ switch ($action) {
 								else
 									$style['label'] = '';
 								break;
+							case 'network_interfaces_report':
+								$style['fullscale'] = (int) get_parameter('fullscale');
+								break;
 							case 'module_histogram_graph':
 							case 'agent_configuration':
 							case 'alert_report_agent':
@@ -1525,6 +1528,9 @@ switch ($action) {
 								else
 									$style['label'] = '';
 								break;
+							case 'network_interfaces_report':
+								$style['fullscale'] = (int) get_parameter('fullscale');
+								break;
 							case 'module_histogram_graph':
 							case 'agent_configuration':
 							case 'alert_report_agent':
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
index 322816c127..7e3fe9fbdb 100644
--- a/pandora_console/include/functions_graph.php
+++ b/pandora_console/include/functions_graph.php
@@ -1834,13 +1834,28 @@ function graphic_combined_module ($module_list, $weight_list, $period,
 		}
 	}
 	else{
-		$temp = fullscale_data_combined($module_list, $period, $date);
+		$flash_charts = true;
+		if($ttl>1 || !$config['flash_charts']){
+			$flash_charts = false;
+		}
+
+		$temp = fullscale_data_combined($module_list, $period, $date, $flash_charts);
 
 		$resolution = count($temp); //Number of points of the graph
 		$interval = (int) ($period / $resolution);
 		$module_name_list = array();
-		$flash_charts = true;
 		
+		if($ttl>1 || !$config['flash_charts']){
+			$temp2 = array();
+			foreach ($temp as $key => $value) {
+				$real_date = date("Y/M/d", $key);
+				$real_date .= "\n";
+				$real_date .= date("   H:i:s", $key);
+				$temp2[$real_date] = $value;
+			}
+			$temp = $temp2;
+		}
+
 		foreach ($module_list as $key => $value) {
 			$agent_name  = io_safe_output( modules_get_agentmodule_agent_name ($value) );
 			$alias       = db_get_value ("alias","tagente","nombre",$agent_name);
@@ -1856,7 +1871,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
 	}
 	
 	$graph_values = $temp;
-	
+
 	if($config["fixed_graph"] == false){
 		$water_mark = array(
 			'file' => $config['homedir'] .  "/images/logo_vertical_water.png",
@@ -2104,7 +2119,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
 	}
 }
 
-function fullscale_data_combined($module_list, $period, $date){
+function fullscale_data_combined($module_list, $period, $date, $flash_charts){
 
 	// Set variables
 	if ($date == 0){
@@ -2117,7 +2132,12 @@ function fullscale_data_combined($module_list, $period, $date){
 		$data_uncompress = db_uncompress_module_data($value_module, $datelimit, $date);
 		foreach ($data_uncompress as $key_data => $value_data) {
 			foreach ($value_data['data'] as $k => $v) {
-				$real_date = date("Y M d H:i:s", $v['utimestamp']);
+				if($flash_charts) {
+					$real_date = date("Y M d H:i:s", $v['utimestamp']);
+				}
+				else{
+					$real_date = $v['utimestamp'];
+				}
 				$data_all[$real_date][$key_module] = $v['datos'];
 			}
 		}
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index e68bb9b76f..8a47d2c7d2 100644
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -2674,6 +2674,10 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
 	if (empty($content['name'])) {
 		$content['name'] = __('Network interfaces report');
 	}
+
+	if (isset($content['style']['fullscale'])) {
+		$fullscale = (bool) $content['style']['fullscale'];
+	}
 	
 	$group_name = groups_get_name($content['id_group']);
 	
@@ -2745,7 +2749,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
 								true,
 								true,
 								true,
-								1);
+								1,
+								false,
+								false,
+								null,
+								false,
+								false,
+								$fullscale);
 							}
 						break;
 					case 'data':
@@ -2768,7 +2778,13 @@ function reporting_network_interfaces_report($report, $content, $type = 'dinamic
 								true,
 								true,
 								true,
-								2);
+								2,
+								false,
+								false,
+								null,
+								false,
+								false,
+								$fullscale);
 							}
 						break;
 				}
diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php
index 1a0a1343f9..0e1c6ae241 100644
--- a/pandora_console/operation/agentes/interface_traffic_graph_win.php
+++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php
@@ -263,7 +263,7 @@ $interface_traffic_modules = array(
 		$table->rowclass[] ='';
 
 		$data = array();
-		$data[0] = __('Full scale');
+		$data[0] = __('Show full scale graph (TIP)');
 		$data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true);
 		$table->data[] = $data;
 		$table->rowclass[] ='';