diff --git a/.project b/.project
new file mode 100644
index 0000000000..2abdc05dbb
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ pandora
+
+
+
+
+
+
+
+
diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index f592353d80..a32d0ffe38 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-30 Miguel de Dios
+
+ * include/functions_graph.php, include/graphs/*, include/graphs/fgraph.php:
+ added first version of common graph libraries with Integria and Babel.
+
2011-03-30 Javier Lanz
* include/functions_reporting.php: Fixed get_agentmodule_sla_array and
diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php
new file mode 100755
index 0000000000..df127dd545
--- /dev/null
+++ b/pandora_console/include/functions_graph.php
@@ -0,0 +1,264 @@
+ $agent_module_id,
+ "utimestamp > $datelimit",
+ "utimestamp < $date",
+ 'order' => 'utimestamp ASC'),
+ array ('evento', 'utimestamp', 'event_type'));
+ if ($events === false) {
+ $events = array ();
+ }
+ }
+
+ // Get module data
+ $data = get_db_all_rows_filter ('tagente_datos',
+ array ('id_agente_modulo' => $agent_module_id,
+ "utimestamp > $datelimit",
+ "utimestamp < $date",
+ 'order' => 'utimestamp ASC'),
+ array ('datos', 'utimestamp'), 'AND', true);
+ if ($data === false) {
+ $data = array ();
+ }
+
+ // Uncompressed module data
+ if ($uncompressed_module) {
+ $min_necessary = 1;
+
+ // Compressed module data
+ } else {
+ // Get previous data
+ $previous_data = get_previous_data ($agent_module_id, $datelimit);
+ if ($previous_data !== false) {
+ $previous_data['utimestamp'] = $datelimit;
+ array_unshift ($data, $previous_data);
+ }
+
+ // Get next data
+ $nextData = get_next_data ($agent_module_id, $date);
+ if ($nextData !== false) {
+ array_push ($data, $nextData);
+ } else if (count ($data) > 0) {
+ // Propagate the last known data to the end of the interval
+ $nextData = array_pop ($data);
+ array_push ($data, $nextData);
+ $nextData['utimestamp'] = $date;
+ array_push ($data, $nextData);
+ }
+
+ $min_necessary = 2;
+ }
+
+ // Check available data
+ if (count ($data) < $min_necessary) {
+ if (!$graphic_type) {
+ return fs_error_image ();
+ }
+ graphic_error ();
+ }
+
+ // Data iterator
+ $j = 0;
+
+ // Event iterator
+ $k = 0;
+
+ // Set initial conditions
+ $chart = array();
+ if ($data[0]['utimestamp'] == $datelimit) {
+ $previous_data = $data[0]['datos'];
+ $j++;
+ } else {
+ $previous_data = 0;
+ }
+
+ // Get baseline data
+ $baseline_data = array ();
+ if ($baseline == 1) {
+ $baseline_data = enterprise_hook ('enterprise_get_baseline', array ($agent_module_id, $period, $width, $height , $title, $unit_name, $date));
+ if ($baseline_data === ENTERPRISE_NOT_HOOK) {
+ $baseline_data = array ();
+ }
+ }
+
+ // Calculate chart data
+ for ($i = 0; $i < $resolution; $i++) {
+ $timestamp = $datelimit + ($interval * $i);
+
+ $total = 0;
+ $count = 0;
+
+ // Read data that falls in the current interval
+ $interval_min = false;
+ $interval_max = false;
+ while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) {
+ if ($interval_min === false) {
+ $interval_min = $data[$j]['datos'];
+ }
+ if ($interval_max === false) {
+ $interval_max = $data[$j]['datos'];
+ }
+
+ if ($data[$j]['datos'] > $interval_max) {
+ $interval_max = $data[$j]['datos'];
+ } else if ($data[$j]['datos'] < $interval_max) {
+ $interval_min = $data[$j]['datos'];
+ }
+ $total += $data[$j]['datos'];
+ $count++;
+ $j++;
+ }
+
+ // Data in the interval
+ if ($count > 0) {
+ $total /= $count;
+ }
+
+ // Read events and alerts that fall in the current interval
+ $event_value = 0;
+ $alert_value = 0;
+ while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) {
+ if ($show_events == 1) {
+ $event_value++;
+ }
+ if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
+ $alert_value++;
+ }
+ $k++;
+ }
+
+ // Data
+ if ($count > 0) {
+ $chart[$timestamp]['sum'] = $total;
+ $chart[$timestamp]['min'] = $interval_min;
+ $chart[$timestamp]['max'] = $interval_max;
+ $previous_data = $total;
+ // Compressed data
+ } else {
+ if ($uncompressed_module || ($timestamp > time ())) {
+ $chart[$timestamp]['sum'] = 0;
+ $chart[$timestamp]['min'] = 0;
+ $chart[$timestamp]['max'] = 0;
+ } else {
+ $chart[$timestamp]['sum'] = $previous_data;
+ $chart[$timestamp]['min'] = $previous_data;
+ $chart[$timestamp]['max'] = $previous_data;
+ }
+ }
+
+ $chart[$timestamp]['count'] = 0;
+ /////////
+ //$chart[$timestamp]['timestamp_bottom'] = $timestamp;
+ //$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
+ /////////
+ $chart[$timestamp]['event'] = $event_value;
+ $chart[$timestamp]['alert'] = $alert_value;
+ $chart[$timestamp]['baseline'] = array_shift ($baseline_data);
+ if ($chart[$timestamp]['baseline'] == NULL) {
+ $chart[$timestamp]['baseline'] = 0;
+ }
+ }
+
+ // Return chart data and don't draw
+ if ($return_data == 1) {
+ return $chart;
+ }
+
+ // Get min, max and avg (less efficient but centralized for all modules and reports)
+ $min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
+ $max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
+ $avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
+
+ // Fix event and alert scale
+ $event_max = $max_value * 1.25;
+ foreach ($chart as $timestamp => $chart_data) {
+ if ($chart_data['event'] > 0) {
+ $chart[$timestamp]['event'] = $event_max;
+ }
+ if ($chart_data['alert'] > 0) {
+ $chart[$timestamp]['alert'] = $event_max;
+ }
+ }
+
+ // Set the title and time format
+ if ($period <= 3600) {
+ $title_period = __('Last hour');
+ $time_format = 'G:i:s';
+ }
+ elseif ($period <= 86400) {
+ $title_period = __('Last day');
+ $time_format = 'G:i';
+ }
+ elseif ($period <= 604800) {
+ $title_period = __('Last week');
+ $time_format = 'M j';
+ }
+ elseif ($period <= 2419200) {
+ $title_period = __('Last month');
+ $time_format = 'M j';
+ }
+ else {
+ $title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
+ $time_format = 'M j';
+ }
+
+ // Only show caption if graph is not small
+ if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
+ // Flash chart
+ $caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
+ else
+ $caption = array();
+
+ ///////
+ $color = array();
+ $color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 100);
+ $color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
+ $color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
+ $color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 100);
+ $color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 100);
+ $color['min'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
+
+ area_graph(0, $chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline, $color);
+}
+?>
\ No newline at end of file
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Area2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Area2D.swf
new file mode 100755
index 0000000000..224fb17ebf
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Area2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Bar2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Bar2D.swf
new file mode 100755
index 0000000000..7b1b09e77e
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Bar2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Candlestick.swf b/pandora_console/include/graphs/FusionCharts/FCF_Candlestick.swf
new file mode 100755
index 0000000000..01ba770d7d
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Candlestick.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Column2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Column2D.swf
new file mode 100755
index 0000000000..e6913b5fa6
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Column2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Column3D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Column3D.swf
new file mode 100755
index 0000000000..a023642920
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Column3D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Doughnut2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Doughnut2D.swf
new file mode 100755
index 0000000000..58d826056d
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Doughnut2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Funnel.swf b/pandora_console/include/graphs/FusionCharts/FCF_Funnel.swf
new file mode 100755
index 0000000000..87d1c663d8
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Funnel.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Gantt.swf b/pandora_console/include/graphs/FusionCharts/FCF_Gantt.swf
new file mode 100755
index 0000000000..de6de3ec64
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Gantt.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Line.swf b/pandora_console/include/graphs/FusionCharts/FCF_Line.swf
new file mode 100755
index 0000000000..547e54f8ce
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Line.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSArea2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSArea2D.swf
new file mode 100755
index 0000000000..bff3774ae9
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSArea2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSBar2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSBar2D.swf
new file mode 100755
index 0000000000..476d7b9060
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSBar2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2D.swf
new file mode 100755
index 0000000000..0e0cbebc6c
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2DLineDY.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2DLineDY.swf
new file mode 100755
index 0000000000..b79490140b
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn2DLineDY.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3D.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3D.swf
new file mode 100755
index 0000000000..5076f580e2
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3DLineDY.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3DLineDY.swf
new file mode 100755
index 0000000000..501291a94f
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSColumn3DLineDY.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_MSLine.swf b/pandora_console/include/graphs/FusionCharts/FCF_MSLine.swf
new file mode 100755
index 0000000000..26329e644d
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_MSLine.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Pie2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Pie2D.swf
new file mode 100755
index 0000000000..d0eea35889
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Pie2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_Pie3D.swf b/pandora_console/include/graphs/FusionCharts/FCF_Pie3D.swf
new file mode 100755
index 0000000000..1d78f79b03
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_Pie3D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_StackedArea2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_StackedArea2D.swf
new file mode 100755
index 0000000000..5f8d3e7a11
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_StackedArea2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_StackedBar2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_StackedBar2D.swf
new file mode 100755
index 0000000000..b9dfb0baf8
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_StackedBar2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn2D.swf b/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn2D.swf
new file mode 100755
index 0000000000..7559014b84
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn2D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn3D.swf b/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn3D.swf
new file mode 100755
index 0000000000..be1ca1c4b7
Binary files /dev/null and b/pandora_console/include/graphs/FusionCharts/FCF_StackedColumn3D.swf differ
diff --git a/pandora_console/include/graphs/FusionCharts/FusionCharts.js b/pandora_console/include/graphs/FusionCharts/FusionCharts.js
new file mode 100755
index 0000000000..4d6cafddba
--- /dev/null
+++ b/pandora_console/include/graphs/FusionCharts/FusionCharts.js
@@ -0,0 +1,311 @@
+/**
+ * FusionCharts: Flash Player detection and Chart embedding.
+ * Version: vFree.1.2 (1st November, 2007) - Added Player detection, New conditional fixes for IE, supports FORM in IE
+ *
+ * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+
+if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
+if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
+infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
+ if (!document.getElementById) { return; }
+
+ //Flag to see whether data has been set initially
+ this.initialDataSet = false;
+
+ //Create container objects
+ this.params = new Object();
+ this.variables = new Object();
+ this.attributes = new Array();
+
+ //Set attributes for the SWF
+ if(swf) { this.setAttribute('swf', swf); }
+ if(id) { this.setAttribute('id', id); }
+ if(w) { this.setAttribute('width', w); }
+ if(h) { this.setAttribute('height', h); }
+
+ //Set background color
+ if(c) { this.addParam('bgcolor', c); }
+
+ //Set Quality
+ this.addParam('quality', 'high');
+
+ //Add scripting access parameter
+ this.addParam('allowScriptAccess', 'always');
+
+ //Pass width and height to be appended as chartWidth and chartHeight
+ this.addVariable('chartWidth', w);
+ this.addVariable('chartHeight', h);
+
+ //Whether in debug mode
+ debugMode = debugMode ? debugMode : 0;
+ this.addVariable('debugMode', debugMode);
+ //Pass DOM ID to Chart
+ this.addVariable('DOMId', id);
+ //Whether to registed with JavaScript
+ registerWithJS = registerWithJS ? registerWithJS : 0;
+ this.addVariable('registerWithJS', registerWithJS);
+
+ //Scale Mode of chart
+ scaleMode = scaleMode ? scaleMode : 'noScale';
+ this.addVariable('scaleMode', scaleMode);
+ //Application Message Language
+ lang = lang ? lang : 'EN';
+ this.addVariable('lang', lang);
+
+ //Whether to auto detect and re-direct to Flash Player installation
+ this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
+ this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
+
+ //Ger Flash Player version
+ this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();
+
+ if (!window.opera && document.all && this.installedVer.major > 7) {
+ // Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
+ infosoftglobal.FusionCharts.doPrepUnload = true;
+ }
+}
+
+infosoftglobal.FusionCharts.prototype = {
+ setAttribute: function(name, value){
+ this.attributes[name] = value;
+ },
+ getAttribute: function(name){
+ return this.attributes[name];
+ },
+ addParam: function(name, value){
+ this.params[name] = value;
+ },
+ getParams: function(){
+ return this.params;
+ },
+ addVariable: function(name, value){
+ this.variables[name] = value;
+ },
+ getVariable: function(name){
+ return this.variables[name];
+ },
+ getVariables: function(){
+ return this.variables;
+ },
+ getVariablePairs: function(){
+ var variablePairs = new Array();
+ var key;
+ var variables = this.getVariables();
+ for(key in variables){
+ variablePairs.push(key +"="+ variables[key]);
+ }
+ return variablePairs;
+ },
+ getSWFHTML: function() {
+ var swfNode = "";
+ if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
+ // netscape plugin architecture
+ swfNode = '