Merge branch 'ent-3878-Report-type-summation-not-working-properly' into 'develop'

Ent 3878 report type summation not working properly

See merge request artica/pandorafms!2599
This commit is contained in:
Daniel Rodriguez 2019-09-18 14:41:35 +02:00
commit c81cb1d222
6 changed files with 55 additions and 24 deletions

View File

@ -4,4 +4,8 @@ UPDATE `tlayout_data` SET `height` = 70 , `width` = 70 WHERE `height` = 0 && `wi
(`type` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') || (`type` = 10 && `image` IS NOT NULL && `image` != '' && `image` != 'none') ||
(`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0)); (`type` = 11 && `image` IS NOT NULL && `image` != '' && `image` != 'none' && `show_statistics` = 0));
ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0';
COMMIT; COMMIT;

View File

@ -153,6 +153,7 @@ $checks_in_ok_status = true;
$unknown_checks = true; $unknown_checks = true;
$agent_max_value = true; $agent_max_value = true;
$agent_min_value = true; $agent_min_value = true;
$uncompressed_module = true;
switch ($action) { switch ($action) {
case 'new': case 'new':
@ -427,6 +428,7 @@ switch ($action) {
); );
$idAgentModule = $item['id_agent_module']; $idAgentModule = $item['id_agent_module'];
$period = $item['period']; $period = $item['period'];
$uncompressed_module = $item['uncompressed_module'];
break; break;
case 'historical_data': case 'historical_data':
@ -810,7 +812,6 @@ switch ($action) {
break; break;
} }
$urlForm = $config['homeurl'].'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action='.$actionParameter.'&id_report='.$idReport; $urlForm = $config['homeurl'].'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action='.$actionParameter.'&id_report='.$idReport;
echo '<form action="'.$urlForm.'" method="post">'; echo '<form action="'.$urlForm.'" method="post">';
@ -2792,6 +2793,23 @@ $class = 'databox filters';
?> ?>
</td> </td>
</tr> </tr>
<tr id="row_uncompressed_module" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Uncompress module').ui_print_help_tip(
__('Use uncompressed module data.'),
true
);
?>
</td>
<td style="">
<?php
html_print_checkbox('uncompressed_module', 1, $item['uncompressed_module'], false, false, '', false);
?>
</td>
</tr>
</tbody> </tbody>
</table> </table>
@ -4524,6 +4542,7 @@ function chooseType() {
$('#row_select_fields').hide(); $('#row_select_fields').hide();
$("#row_select_fields2").hide(); $("#row_select_fields2").hide();
$("#row_select_fields3").hide(); $("#row_select_fields3").hide();
$("#row_uncompressed_module").hide();
// SLA list default state. // SLA list default state.
$("#sla_list").hide(); $("#sla_list").hide();
@ -4732,6 +4751,7 @@ function chooseType() {
$("#row_module").show(); $("#row_module").show();
$("#row_period").show(); $("#row_period").show();
$("#row_historical_db_check").hide(); $("#row_historical_db_check").hide();
$("#row_uncompressed_module").show();
break; break;
case 'historical_data': case 'historical_data':

View File

@ -1908,6 +1908,11 @@ switch ($action) {
$values['id_agent'] = get_parameter('group'); $values['id_agent'] = get_parameter('group');
} }
if ($values['type'] = 'sumatory') {
$values['uncompressed_module'] = get_parameter('uncompressed_module', 0);
}
$values['header_definition'] = get_parameter('header'); $values['header_definition'] = get_parameter('header');
$values['column_separator'] = get_parameter('field'); $values['column_separator'] = get_parameter('field');
$values['line_separator'] = get_parameter('line'); $values['line_separator'] = get_parameter('line');
@ -2464,6 +2469,10 @@ switch ($action) {
$values['id_agent'] = get_parameter('group'); $values['id_agent'] = get_parameter('group');
} }
if ($values['type'] = 'sumatory') {
$values['uncompressed_module'] = get_parameter('uncompressed_module', 0);
}
$values['header_definition'] = get_parameter('header'); $values['header_definition'] = get_parameter('header');
$values['column_separator'] = get_parameter('field'); $values['column_separator'] = get_parameter('field');
$values['line_separator'] = get_parameter('line'); $values['line_separator'] = get_parameter('line');

View File

@ -4903,7 +4903,8 @@ function reporting_value($report, $content, $type, $pdf=false)
$value = reporting_get_agentmodule_data_sum( $value = reporting_get_agentmodule_data_sum(
$content['id_agent_module'], $content['id_agent_module'],
$content['period'], $content['period'],
$report['datetime'] $report['datetime'],
$content['uncompressed_module']
); );
if (!$config['simple_module_value']) { if (!$config['simple_module_value']) {
$formated_value = $value; $formated_value = $value;
@ -10725,17 +10726,19 @@ function reporting_get_agentmodule_data_min($id_agent_module, $period=0, $date=0
* @param int Agent module id to get the sumatory. * @param int Agent module id to get the sumatory.
* @param int Period of time to check (in seconds) * @param int Period of time to check (in seconds)
* @param int Top date to check the values. Default current time. * @param int Top date to check the values. Default current time.
* @param boolean Show uncompressed data from module
* *
* @return float The sumatory of the module values in the interval. * @return float The sumatory of the module values in the interval.
*/ */
function reporting_get_agentmodule_data_sum( function reporting_get_agentmodule_data_sum(
$id_agent_module, $id_agent_module,
$period=0, $period=0,
$date=0 $date=0,
$uncompressed_module=true
) { ) {
global $config; global $config;
// Initialize variables // Initialize variables.
if (empty($date)) { if (empty($date)) {
$date = get_system_time(); $date = get_system_time();
} }
@ -10757,18 +10760,21 @@ function reporting_get_agentmodule_data_sum(
$id_module_type $id_module_type
); );
$module_interval = modules_get_interval($id_agent_module); $module_interval = modules_get_interval($id_agent_module);
// Check if module must be compressed.
if (!$uncompressed_module) {
$uncompressed_module = is_module_uncompressed($module_name); $uncompressed_module = is_module_uncompressed($module_name);
}
// Wrong module type // Wrong module type
if (is_module_data_string($module_name)) { if (is_module_data_string($module_name)) {
return 0; return 0;
} }
// Incremental modules are treated differently // Incremental modules are treated differently.
$module_inc = is_module_inc($module_name); $module_inc = is_module_inc($module_name);
if ($uncompressed_module) { if (!$uncompressed_module) {
// Get module data // Get module data.
$interval_data = db_get_all_rows_sql( $interval_data = db_get_all_rows_sql(
' '
SELECT * FROM tagente_datos SELECT * FROM tagente_datos
@ -10792,7 +10798,7 @@ function reporting_get_agentmodule_data_sum(
return false; return false;
} }
// Set initial conditions // Set initial conditions.
$total = 0; $total = 0;
$partial_total = 0; $partial_total = 0;
$count_sum = 0; $count_sum = 0;
@ -10801,18 +10807,9 @@ function reporting_get_agentmodule_data_sum(
$partial_total = 0; $partial_total = 0;
$count_sum = 0; $count_sum = 0;
switch ($config['dbtype']) { if (!$uncompressed_module) {
case 'mysql': $total += $data['datos'];
case 'postgresql': } else if (!$module_inc) {
// Do none
break;
case 'oracle':
$data['datos'] = oracle_format_float_to_php($data['datos']);
break;
}
if (!$module_inc) {
foreach ($data['data'] as $val) { foreach ($data['data'] as $val) {
if (is_numeric($val['datos'])) { if (is_numeric($val['datos'])) {
$partial_total += $val['datos']; $partial_total += $val['datos'];
@ -10824,7 +10821,7 @@ function reporting_get_agentmodule_data_sum(
continue; continue;
} }
$total += ($partial_total / $count_sum); $total += $partial_total;
} else { } else {
$last = end($data['data']); $last = end($data['data']);
$total += $last['datos']; $total += $last['datos'];

View File

@ -17,7 +17,6 @@ global $config;
check_login(); check_login();
enterprise_hook('open_meta_frame'); enterprise_hook('open_meta_frame');
$id_report = (int) get_parameter('id'); $id_report = (int) get_parameter('id');
if (! $id_report) { if (! $id_report) {

View File

@ -1455,6 +1455,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`current_month` TINYINT(1) DEFAULT '1', `current_month` TINYINT(1) DEFAULT '1',
`failover_mode` tinyint(1) DEFAULT '1', `failover_mode` tinyint(1) DEFAULT '1',
`failover_type` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1',
`uncompressed_module` TINYINT DEFAULT '0',
PRIMARY KEY(`id_rc`), PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
@ -2998,6 +2999,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`current_month` TINYINT(1) DEFAULT '1', `current_month` TINYINT(1) DEFAULT '1',
`failover_mode` tinyint(1) DEFAULT '1', `failover_mode` tinyint(1) DEFAULT '1',
`failover_type` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1',
`uncompressed_module` TINYINT DEFAULT '0',
PRIMARY KEY(`id_rc`) PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;