Merge branch 'feature/ticket#1980-dynamic_reports' into develop

This commit is contained in:
mdtrooper 2015-06-29 13:26:14 +02:00
commit 2fd82b6ee5
4 changed files with 98 additions and 51 deletions

View File

@ -95,36 +95,43 @@ function reporting_get_name($id_report) {
return db_get_value('name', 'treport', 'id_report', $id_report); return db_get_value('name', 'treport', 'id_report', $id_report);
} }
function reporting_make_reporting_data($id_report, $date, $time, function reporting_make_reporting_data($report = null, $id_report,
$period = null, $type = 'dinamic', $force_width_chart = null, $date, $time, $period = null, $type = 'dinamic',
$force_height_chart = null) { $force_width_chart = null, $force_height_chart = null) {
global $config; global $config;
$return = array(); $return = array();
$report = db_get_row ('treport', 'id_report', $id_report); if (!empty($report)) {
$contents = $report['contents'];
}
else {
$report = db_get_row ('treport', 'id_report', $id_report);
switch ($config["dbtype"]) {
case "mysql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, "`order`");
break;
case "postgresql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
case "oracle":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
}
}
$datetime = strtotime($date . ' ' . $time);
$report["datetime"] = $datetime;
$report["group"] = $report['id_group']; $report["group"] = $report['id_group'];
$report["group_name"] = groups_get_name ($report['id_group']); $report["group_name"] = groups_get_name ($report['id_group']);
$report['contents'] = array(); $report['contents'] = array();
$datetime = strtotime($date . ' ' . $time);
$report["datetime"] = $datetime;
switch ($config["dbtype"]) { if (empty($contents)) {
case "mysql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, "`order`");
break;
case "postgresql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
case "oracle":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
}
if ($contents === false) {
return reporting_check_structure_report($report); return reporting_check_structure_report($report);
} }
@ -477,9 +484,14 @@ function reporting_SLA($report, $content, $type = 'dinamic',
$edge_interval = 10; $edge_interval = 10;
$slas = db_get_all_rows_field_filter ( if (empty($content['subitems'])) {
'treport_content_sla_combined', $slas = db_get_all_rows_field_filter (
'id_report_content', $content['id_rc']); 'treport_content_sla_combined',
'id_report_content', $content['id_rc']);
}
else {
$slas = $content['subitems'];
}
if (empty($slas)) { if (empty($slas)) {
$return['failed'] = __('There are no SLAs defined'); $return['failed'] = __('There are no SLAs defined');
@ -929,12 +941,19 @@ function reporting_event_top_n($report, $content, $type = 'dinamic',
$top_n_value = $content['top_n_value']; $top_n_value = $content['top_n_value'];
$show_graph = $content['show_graph']; $show_graph = $content['show_graph'];
//Get all the related data
$sql = sprintf("SELECT id_agent_module, server_name
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$tops = db_process_sql ($sql);
if (empty($content['subitems'])) {
//Get all the related data
$sql = sprintf("SELECT id_agent_module, server_name
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$tops = db_process_sql ($sql);
}
else {
$tops = $content['subitems'];
}
// Get chart // Get chart
reporting_set_conf_charts($width, $height, $only_image, $type, reporting_set_conf_charts($width, $height, $only_image, $type,
@ -1727,13 +1746,22 @@ function reporting_exception($report, $content, $type = 'dinamic',
//Get all the related data
$sql = sprintf("
SELECT id_agent_module, server_name, operation
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$exceptions = db_process_sql ($sql);
if (empty($content['subitems'])) {
//Get all the related data
$sql = sprintf("
SELECT id_agent_module, server_name, operation
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$exceptions = db_process_sql ($sql);
}
else {
$exceptions = $content['subitems'];
}
if ($exceptions === false) { if ($exceptions === false) {
$return['failed'] = __('There are no Agent/Modules defined'); $return['failed'] = __('There are no Agent/Modules defined');
} }
@ -3729,14 +3757,21 @@ function reporting_availability($report, $content) {
} }
$sql = sprintf(" if (empty($content['subitems'])) {
SELECT id_agent_module, $sql = sprintf("
server_name, operation SELECT id_agent_module,
FROM treport_content_item server_name, operation
WHERE id_report_content = %d", FROM treport_content_item
$content['id_rc']); WHERE id_report_content = %d",
$content['id_rc']);
$items = db_process_sql ($sql);
}
else {
$items = $content['subitems'];
}
$items = db_process_sql ($sql);
$data = array(); $data = array();
@ -3964,9 +3999,16 @@ function reporting_general($report, $content) {
$return["max"]["agent"] = null; $return["max"]["agent"] = null;
$return["max"]["module"] = null; $return["max"]["module"] = null;
$generals = db_get_all_rows_filter( if (empty($content['subitems'])) {
'treport_content_item', $generals = db_get_all_rows_filter(
array('id_report_content' => $content['id_rc'])); 'treport_content_item',
array('id_report_content' => $content['id_rc']));
}
else {
$generals = $content['subitems'];
}
if (empty($generals)) { if (empty($generals)) {
$generals = array(); $generals = array();
} }

View File

@ -500,7 +500,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
$types['simple_baseline_graph'] = array('optgroup' => __('Graphs'), $types['simple_baseline_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple baseline graph')); 'name' => __('Simple baseline graph'));
if ($not_editor == false) if ($not_editor == false)
$types['automatic_custom_graph'] = array('optgroup' => __('Graphs'), $types['automatic_custom_graph'] = array(
'optgroup' => __('Graphs'),
'name' => __('Custom graph')); 'name' => __('Custom graph'));
$types['custom_graph'] = array('optgroup' => __('Graphs'), $types['custom_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Custom graph')); 'name' => __('Custom graph'));
@ -513,7 +514,7 @@ function reports_get_report_types ($template = false, $not_editor = false) {
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'), $types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL horizonal bar graph')); 'name' => __('SQL horizonal bar graph'));
} }
if ($template) { if ($template && !defined('METACONSOLE')) {
$types['automatic_graph'] = array('optgroup' => __('Graphs'), $types['automatic_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Automatic combined Graph')); 'name' => __('Automatic combined Graph'));
} }

View File

@ -176,7 +176,8 @@ $table->size[0] = '60px';
$table->colspan[0][1] = 2; $table->colspan[0][1] = 2;
$table->style[0] = 'text-align:center;'; $table->style[0] = 'text-align:center;';
$table->data = array (); $table->data = array ();
$table->data[0][0] = html_print_image("images/reporting32.png", true, array("width" => "32", "height" => "32")); $table->data[0][0] = html_print_image("images/reporting32.png", true,
array("width" => "32", "height" => "32"));
if (defined("METACONSOLE")) { if (defined("METACONSOLE")) {
if ($report['description'] != '') { if ($report['description'] != '') {
$table->data[0][1] = '<div style="">' . __("Description: ") . $report['description'] . '</div>'; $table->data[0][1] = '<div style="">' . __("Description: ") . $report['description'] . '</div>';
@ -215,7 +216,8 @@ else {
} }
$table->data[0][1] .= '<div style="text-align:right; width:100%; margin-right:50px">'.__('Set initial date') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true); $table->data[0][1] .= '<div style="text-align:right; width:100%; margin-right:50px">'.__('Set initial date') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true);
$html_enterprise = enterprise_hook('reporting_print_button_PDF', array($id_report)); $html_enterprise = enterprise_hook('reporting_print_button_PDF',
array($id_report));
if ($html_enterprise !== ENTERPRISE_NOT_HOOK) { if ($html_enterprise !== ENTERPRISE_NOT_HOOK) {
$table->data[0][1] .= $html_enterprise; $table->data[0][1] .= $html_enterprise;
} }
@ -245,7 +247,9 @@ if ($enable_init_date) {
} }
} }
$report = reporting_make_reporting_data($id_report, $date, $time, $period, 'dinamic'); $report = reporting_make_reporting_data(null, $id_report, $date, $time,
$period, 'dinamic');
reporting_html_print_report($report); reporting_html_print_report($report);
echo "<br>"; echo "<br>";

View File

@ -120,7 +120,7 @@ switch ($date_mode) {
} }
$report = reporting_make_reporting_data($id_report, $date, $time, $report = reporting_make_reporting_data(null, $id_report, $date, $time,
$period, 'static'); $period, 'static');
//------- Removed the unused fields ------------------------------------ //------- Removed the unused fields ------------------------------------