mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
Working in the refactoring code of reporting.
This commit is contained in:
parent
a5eaeb3ec9
commit
ceca482158
@ -86,6 +86,14 @@ function reporting_get_type($content) {
|
||||
return $content["type"];
|
||||
}
|
||||
|
||||
function reporting_get_description($id_report) {
|
||||
return db_get_value('description', 'treport', 'id_report', $id_report);
|
||||
}
|
||||
|
||||
function reporting_get_name($id_report) {
|
||||
return db_get_value('name', 'treport', 'id_report', $id_report);
|
||||
}
|
||||
|
||||
function reporting_make_reporting_data($id_report, $date, $time,
|
||||
$period = null, $type = 'dinamic', $force_width_chart = null,
|
||||
$force_height_chart = null) {
|
||||
@ -161,6 +169,7 @@ function reporting_sql($report, $content) {
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'sql';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('SQL');
|
||||
@ -168,9 +177,7 @@ function reporting_sql($report, $content) {
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text(
|
||||
$report,
|
||||
$content);
|
||||
$return["date"] = reporting_get_date_text();
|
||||
|
||||
if ($content['treport_custom_sql_id'] != 0) {
|
||||
switch ($config["dbtype"]) {
|
||||
@ -238,6 +245,7 @@ function reporting_general($report, $content) {
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'general';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('General');
|
||||
@ -482,6 +490,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'simple_graph';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Simple graph');
|
||||
@ -598,29 +607,32 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_get_date_text($report, $content) {
|
||||
function reporting_get_date_text($report = null, $content = null) {
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['date'] = "";
|
||||
$return['period'] = "";
|
||||
$return['from'] = "";
|
||||
$return['to'] = "";
|
||||
$return['date'] = null;
|
||||
$return['period'] = null;
|
||||
$return['from'] = null;
|
||||
$return['to'] = null;
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$es = json_decode($content['external_source'], true);
|
||||
if ($es['date'] == 0) {
|
||||
$return['date'] = __('Last data');
|
||||
if (!empty($report) && !empty($content)) {
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$es = json_decode($content['external_source'], true);
|
||||
if ($es['date'] == 0) {
|
||||
$return['period'] = 0;
|
||||
}
|
||||
else {
|
||||
$return['date'] = $es['date'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return['date'] = date($config["date_format"], $es['date']);
|
||||
$return['period'] = $content['period'];
|
||||
$return['from'] = $report["datetime"] - $content['period'];
|
||||
$return['to'] = $report["datetime"];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return['period'] = human_time_description_raw ($content['period']);
|
||||
$return['from'] = date($config["date_format"], $report["datetime"] - $content['period']);
|
||||
$return['from'] = date($config["date_format"], $report["datetime"]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -37,6 +37,115 @@ include_once($config['homedir'] . "/include/functions_forecast.php");
|
||||
include_once($config['homedir'] . "/include/functions_ui.php");
|
||||
include_once($config['homedir'] . "/include/functions_netflow.php");
|
||||
|
||||
function reporting_html_header(&$table, $mini, $title, $subtitle,
|
||||
$period, $date, $from, $to) {
|
||||
|
||||
global $config;
|
||||
|
||||
|
||||
if ($mini) {
|
||||
$sizh = '';
|
||||
$sizhfin = '';
|
||||
}
|
||||
else {
|
||||
$sizh = '<h4>';
|
||||
$sizhfin = '</h4>';
|
||||
}
|
||||
|
||||
|
||||
$date_text = "";
|
||||
if (!empty($date)) {
|
||||
$date_text = date($config["date_format"], $date);
|
||||
}
|
||||
else if (!empty($from) && !empty($to)) {
|
||||
$date_text =
|
||||
"(" . human_time_description_raw ($period) . ") " .
|
||||
__("From:") . " " . date($config["date_format"], $from) . "<br />" .
|
||||
__("To:") . " " . date($config["date_format"], $to);
|
||||
}
|
||||
else if ($period > 0) {
|
||||
$date_text = human_time_description_raw($period);
|
||||
}
|
||||
else if ($period === 0) {
|
||||
$date_text = __('Last data');
|
||||
}
|
||||
|
||||
|
||||
$data = array();
|
||||
if (empty($subtitle) && (empty($date_text))) {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$table->colspan[0][0] = 3;
|
||||
}
|
||||
else if (empty($subtitle)) {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$data[] = "<div style='text-align: right;'>" . $sizh . $date_text . $sizhfin . "</div>";
|
||||
$table->colspan[0][1] = 2;
|
||||
}
|
||||
else if (empty($date_text)) {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$data[] = $sizh . $subtitle . $sizhfin;
|
||||
$table->colspan[0][1] = 2;
|
||||
}
|
||||
else {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$data[] = $sizh . $subtitle . $sizhfin;
|
||||
$data[] = "<div style='text-align: right;'>" . $sizh . $date_text . $sizhfin . "</div>";
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
function reporting_html_print_report($report, $mini = false) {
|
||||
|
||||
foreach ($report['contents'] as $item) {
|
||||
$table->size = array ();
|
||||
$table->style = array ();
|
||||
$table->width = '98%';
|
||||
$table->class = 'databox';
|
||||
$table->rowclass = array ();
|
||||
$table->rowclass[0] = 'datos3';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->style = array ();
|
||||
$table->colspan = array ();
|
||||
$table->rowstyle = array ();
|
||||
|
||||
|
||||
reporting_html_header($table,
|
||||
$mini, $item['title'],
|
||||
$item['subtitle'],
|
||||
$item['date']['period'],
|
||||
$item['date']['date'],
|
||||
$item['date']['from'],
|
||||
$item['date']['to']);
|
||||
|
||||
if ($item["description"] != "") {
|
||||
$table->data['description_row']['description'] = $item["description"];
|
||||
$table->colspan['description_row']['description'] = 3;
|
||||
}
|
||||
|
||||
switch ($item['type']) {
|
||||
case 'general':
|
||||
break;
|
||||
case 'sql':
|
||||
break;
|
||||
case 'simple_graph':
|
||||
$table->colspan['chart']['cell'] = 3;
|
||||
$table->cellstyle['chart']['cell'] = 'text-align: center;';
|
||||
$table->data['chart']['cell'] = $item['chart'];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['type'] == 'agent_module')
|
||||
echo '<div style="width: 99%; overflow: auto;">';
|
||||
|
||||
html_print_table ($table);
|
||||
|
||||
if ($item['type'] == 'agent_module')
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the average value of an agent module in a period of time.
|
||||
*
|
||||
@ -2804,7 +2913,9 @@ function sla_value_asc_cmp($a, $b) {
|
||||
/**
|
||||
* Make the header for each content.
|
||||
*/
|
||||
function reporting_header_content($mini, $content, $report, &$table, $title = false, $name = false, $period = false) {
|
||||
function reporting_header_content($mini, $content, $report, &$table,
|
||||
$title = false, $name = false, $period = false) {
|
||||
|
||||
global $config;
|
||||
|
||||
if ($mini) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user