Added the new item to item editor builder and to html view

This commit is contained in:
Arturo Gonzalez 2017-04-12 15:00:09 +02:00
parent b3e1125526
commit b912834ce7
4 changed files with 149 additions and 1 deletions

View File

@ -144,6 +144,7 @@ switch ($action) {
case 'network_interfaces_report':
case 'availability':
case 'event_report_log':
case 'increment':
case 'availability_graph':
case 'agent_module':
$get_data_editor = true;
@ -272,6 +273,13 @@ switch ($action) {
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
break;
case 'increment':
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$period = $item['period'];
break;
case 'SLA_services':
$description = $item['description'];
$period = $item['period'];
@ -578,6 +586,7 @@ switch ($action) {
case 'MTTR':
case 'simple_baseline_graph':
case 'event_report_log':
case 'increment':
$label = (isset($style['label'])) ? $style['label'] : '';
break;
default:
@ -2646,6 +2655,13 @@ function chooseType() {
$("#agents_row").show();
$("#row_source").show();
break;
case 'increment':
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
break;
case 'simple_graph':
$("#row_time_compare_overlapped").show();

View File

@ -171,6 +171,12 @@ function reporting_make_reporting_data($report = null, $id_report,
$report,
$content);
break;
case 'increment':
$report['contents'][] =
reporting_increment(
$report,
$content);
break;
case 'general':
$report['contents'][] =
reporting_general(
@ -5464,6 +5470,65 @@ function reporting_availability_graph($report, $content, $pdf=false) {
return reporting_check_structure_content($return);
}
/**
* reporting_increment
*
* Generates a structure the report.
*
*/
function reporting_increment ($report, $content) {
global $config;
$return = array();
$return['type'] = 'increment';
if (empty($content['name'])) {
$content['name'] = __('Increment');
}
$return['title'] = $content['name'];
$return["description"] = $content["description"];
$return["id_agent_module"] = $content["id_agent_module"];
$return["id_agent"] = $content["id_agent"];
$id_agent_module = $content['id_agent_module'];
$period = (int)$content['period'];
$return["from"] = time() - $period;
$return["to"] = time();
$return["data"] = array();
$old_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . '
AND utimestamp <= ' . (time() - $period) . ' ORDER BY utimestamp DESC');
$last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = ' . $id_agent_module . ' ORDER BY utimestamp DESC');
if (is_numeric($old_data) && is_numeric($last_data)) {
$return["data"]['old'] = $old_data;
$return["data"]['now'] = $last_data;
$increment = $old_data - $last_data;
if ($increment < 0) {
$return["data"]['inc'] = 'positive';
$return["data"]["inc_data"] = $last_data - $old_data;
}
else if ($increment == 0) {
$return["data"]['inc'] = 'neutral';
$return["data"]["inc_data"] = 0;
}
else {
$return["data"]['inc'] = 'negative';
$return["data"]["inc_data"] = $old_data - $last_data;
}
}
else {
$return["data"]['message'] = __('The monitor type is not numeric');
$return["data"]['error'] = true;
}
return reporting_check_structure_content($return);
}
/**
* reporting_general
*

View File

@ -208,6 +208,9 @@ function reporting_html_print_report($report, $mini = false, $report_info = 1) {
case 'avg_value':
reporting_html_avg_value($table, $item, $mini);
break;
case 'increment':
reporting_html_increment($table, $item);
break;
case 'min_value':
reporting_html_min_value($table, $item, $mini);
break;
@ -2213,6 +2216,69 @@ function reporting_html_value(&$table, $item, $mini, $only_value = false, $check
$table->data['data']['cell'] .= '</p>';
}
function reporting_html_increment(&$table, $item) {
global $config;
if (isset($item["data"]['error'])) {
$table->colspan['error']['cell'] = 3;
$table->data['error']['cell'] = $item["data"]['message'];
}
else {
$table1 = new stdClass();
$table1->width = '99%';
$table1->data = array ();
$table1->head = array ();
$table1->head[0] = __('Agent');
$table1->head[1] = __('Module');
$table1->head[2] = __('From');
$table1->head[3] = __('To');
$table1->head[4] = __('From data');
$table1->head[5] = __('To data');
$table1->head[6] = __('Increment');
$table1->headstyle = array();
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->headstyle[3] = 'text-align: left';
$table1->headstyle[4] = 'text-align: right';
$table1->headstyle[5] = 'text-align: right';
$table1->headstyle[6] = 'text-align: right';
$table1->style[0] = 'text-align: left';
$table1->style[1] = 'text-align: left';
$table1->style[2] = 'text-align: left';
$table1->style[3] = 'text-align: left';
$table1->style[4] = 'text-align: right';
$table1->style[5] = 'text-align: right';
$table1->style[6] = 'text-align: right';
$table1_row = array();
$table1_row[0] = agents_get_alias($item['id_agent']);
$table1_row[1] = modules_get_agentmodule_name($item['id_agent_module']);
$table1_row[2] = date("F j, Y, g:i a", $item['from']);
$table1_row[3] = date("F j, Y, g:i a", $item['to']);
$table1_row[4] = $item["data"]['old'];
$table1_row[5] = $item["data"]['now'];
if ($item["data"]['inc'] == 'negative') {
$table1_row[6] = __('Negative increase: ') . $item["data"]["inc_data"];
}
else if ($item["data"]['inc'] == 'positive') {
$table1_row[6] = __('Positive increase: ') . $item["data"]["inc_data"];
}
else {
$table1_row[6] = __('Neutral increase: ') . $item["data"]["inc_data"];
}
$table1->data[] = $table1_row;
$data = array();
$data[0] = html_print_table($table1, true);
array_push ($table->data, $data);
}
}
function reporting_html_url(&$table, $item, $key) {
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: left;';

View File

@ -574,7 +574,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
'name' => __('Summatory'));
$types['historical_data'] = array('optgroup' => __('Modules'),
'name' => __('Historical Data'));
$types['increment'] = array('optgroup' => __('Modules'),
'name' => __('Increment'));
$types['general'] = array('optgroup' => __('Grouped'),