diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 4abf5152c1..3494eed389 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4785,12 +4785,10 @@ function reporting_value($report, $content, $type, $pdf=false) 'period' => $content['period'], 'width' => '600px', 'pure' => false, - // true 'date' => $report['datetime'], 'only_image' => $only_image, 'homeurl' => ui_get_full_url(false, false, false, false), 'ttl' => 1, - // 2 'type_graph' => $config['type_module_charts'], 'time_interval' => $content['lapse'], 'server_id' => $id_meta, @@ -4800,323 +4798,104 @@ function reporting_value($report, $content, $type, $pdf=false) switch ($type) { case 'max': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Maximum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'max_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Maximum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_max( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' -
'; - - $formated_value = $value; - } - break; - case 'min': - if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); - - if (!$config['simple_module_value']) { - $formated_value = $value; - } else { - $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; - } - } else { - $value = ' - - - - - - - - - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Minimum').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; - } - - $value .= ' -
- '; - - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'min_only'; - $value .= grafico_modulo_sparse($params); - } - - $value .= ' -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } - - $value .= '
- '.__('Lapse').' - - '.__('Minimum').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; - - if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_min( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; - } - - $value .= ' - -
'; - - $formated_value = $value; - } - break; - case 'avg': if ($content['lapse_calc'] == 0) { - $value = reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['period'], - $report['datetime'] - ); + switch ($type) { + case 'max': + $value = reporting_get_agentmodule_data_max( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'min': + $value = reporting_get_agentmodule_data_min( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + + case 'avg': + $value = reporting_get_agentmodule_data_average( + $content['id_agent_module'], + $content['period'], + $report['datetime'] + ); + break; + } + if (!$config['simple_module_value']) { $formated_value = $value; } else { $formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit; } } else { - $value = ' - - - - - - - - - -
'; + $return['visual_format'] = $content['visual_format']; - if ($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3) { - $value .= ' - - - - - - - - - - -
- '.__('Agent').' - - '.__('Module').' - - '.__('Average').' -
- '.$agent_name.' - - '.$module_name.' - - '.format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit.' -
'; + 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']).' '.$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']).' '.$unit; + break; + + case 'avg': + $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']).' '.$unit; + break; } - $value .= ' -
- '; - if ($content['visual_format'] == 2 || $content['visual_format'] == 3) { - $params['force_interval'] = 'avg_only'; - $value .= grafico_modulo_sparse($params); + $return['data'][] = [ + __('Agent') => $agent_name, + __('Module') => $module_name, + __('Maximun') => $value, + ]; + + if ($content['visual_format'] != 1) { + $graph = grafico_modulo_sparse($params); + $return['data'][] = ['value' => $graph]; } - $value .= ' - -
'; - - if ($content['visual_format'] == 1 || $content['visual_format'] == 3) { - $value .= ' - - - - - - '; - $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']); - $date_reference = getdate(); - - for ($i = $date_reference[0]; $i > ($date_reference[0] - $content['period']); $i -= $content['lapse']) { - $value .= ''; - } else { - $value .= 'N/A'; - } - } + switch ($type) { + case 'max': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; - $value .= '
- '.__('Lapse').' - - '.__('Average').' -
'.date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i).''; + if ($content['visual_format'] != 2) { + $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); + for ($i = $report['datetime']; $i > ($report['datetime'] - $content['period']); $i -= $content['lapse']) { + $row = []; + $row[__('Lapse')] = date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i); if ($i > $time_begin['utimestamp']) { - $value .= format_for_graph( - reporting_get_agentmodule_data_average( - $content['id_agent_module'], - $content['lapse'], - $i - ), - $config['graph_precision'] - ).' '.$unit.'
'; + case 'min': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; + + case 'avg': + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + break; + } + } else { + $row[__('Maximun')] = 'N/A'; + } + + $return['data'][] = $row; + } } - $value .= ' - -
'; + if ($config['metaconsole']) { + metaconsole_restore_db(); + } - $formated_value = $value; + return reporting_check_structure_content($return); } break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 6a7d60c620..c2ace5699e 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2784,20 +2784,130 @@ function reporting_html_value(&$table, $item, $mini, $only_value=false, $check_e $font_size = '3'; } - $table->colspan['data']['cell'] = 3; - $table->cellstyle['data']['cell'] = 'text-align: left;'; + if (isset($item['visual_format']) && $item['visual_format'] != 0 + && ($item['type'] == 'max_value' || $item['type'] == 'min_value' || $item['type'] == 'avg_value') + ) { + $table2 = new stdClass(); + $table2->width = '100%'; + switch ($item['type']) { + case 'max_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Maximun'), + ]; + break; - $table->data['data']['cell'] = '

'; + case 'min_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Minimun'), + ]; + break; - if ($check_empty && empty($item['data']['value'])) { - $table->data['data']['cell'] .= __('Unknown'); - } else if ($only_value) { - $table->data['data']['cell'] .= $item['data']['value']; + case 'avg_value': + $table2->head = [ + __('Agent'), + __('Module'), + __('Average'), + ]; + break; + } + + $table2->data = []; + + $data = $item['data'][0]; + + $row = [ + $data[__('Agent')], + $data[__('Module')], + $data[__('Maximun')], + ]; + + $table2->data[] = $row; + + $table2->title = $item['title']; + $table2->titleclass = 'title_table_pdf'; + $table2->titlestyle = 'text-align:left;'; + $table->colspan[1][0] = 3; + $table->colspan[2][0] = 3; + $table->colspan[3][0] = 3; + + array_push($table->data, 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 ($item['visual_format'] != 2) { + $table1 = new stdClass(); + $table1->width = '100%'; + switch ($item['type']) { + case 'max_value': + $table1->head = [ + __('Lapse'), + __('Maximun'), + ]; + break; + + case 'min_value': + $table1->head = [ + __('Lapse'), + __('Minimun'), + ]; + break; + + case 'avg_value': + $table1->head = [ + __('Lapse'), + __('Average'), + ]; + break; + } + + $table1->data = []; + foreach ($item['data'] as $data) { + if (!is_numeric($data[__('Maximun')])) { + $row = [ + $data[__('Lapse')], + $data[__('Maximun')], + ]; + } else { + $row = [ + $data[__('Lapse')], + remove_right_zeros(number_format($data[__('Maximun')], $config['graph_precision'])), + ]; + } + + $table1->data[] = $row; + } + + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + + array_push($table->data, html_print_table($table1, true)); + } } else { - $table->data['data']['cell'] .= $item['data']['formated_value']; - } + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; - $table->data['data']['cell'] .= '

'; + $table->data['data']['cell'] = '

'; + + if ($check_empty && empty($item['data']['value'])) { + $table->data['data']['cell'] .= __('Unknown'); + } else if ($only_value) { + $table->data['data']['cell'] .= $item['data']['value']; + } else { + $table->data['data']['cell'] .= $item['data']['formated_value']; + } + + $table->data['data']['cell'] .= '

'; + } }