Added the option 'last value' for the items 'general' and 'exception' in reports. TICKET: #1819

(cherry picked from commit 0952b96b49)

Conflicts:
	pandora_console/include/javascript/pandora.js
This commit is contained in:
mdtrooper 2015-02-23 13:43:26 +01:00
parent 42d90c5793
commit 30a05aa62f
4 changed files with 280 additions and 160 deletions

View File

@ -568,8 +568,25 @@ html_print_input_hidden('id_item', $idItem);
<td style=""> <td style="">
<?php <?php
html_print_extended_select_for_time ('period', $period, '', '', '0', 10); html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
?></td> ?>
</td>
</tr> </tr>
<tr id="row_last_value" style="" class="datos">
<td style="vertical-align: top;" class="datos">
<?php
echo __('Last value');
ui_print_help_tip(__('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information'));
?>
</td>
<td style="">
<?php
html_print_checkbox('last_value', '1',
($period === 0), false, false, 'set_last_value_period();');
?>
</td>
</tr>
<tr id="row_resolution" style="" class="datos"> <tr id="row_resolution" style="" class="datos">
<td style="vertical-align: top;"> <td style="vertical-align: top;">
<?php <?php
@ -1186,17 +1203,17 @@ function print_SLA_list($width, $action, $idItem = null) {
$server_name_element = ''; $server_name_element = '';
if ($meta && $server_name != '') if ($meta && $server_name != '')
$server_name_element .= ' (' . $server_name . ')'; $server_name_element .= ' (' . $server_name . ')';
echo '<tr id="sla_' . $item['id'] . '" style="" class="datos">'; echo '<tr id="sla_' . $item['id'] . '" style="" class="datos">';
echo '<td class="sla_list_agent_col">' . printSmallFont($nameAgent) . $server_name_element . '</td>'; echo '<td class="sla_list_agent_col">' . printSmallFont($nameAgent) . $server_name_element . '</td>';
echo '<td class="sla_list_module_col">' . printSmallFont($nameModule) . '</td>'; echo '<td class="sla_list_module_col">' . printSmallFont($nameModule) . '</td>';
if (enterprise_installed() && $report_item_type == 'SLA_services') { if (enterprise_installed() && $report_item_type == 'SLA_services') {
enterprise_include_once("include/functions_services.php"); enterprise_include_once("include/functions_services.php");
$nameService = enterprise_hook('services_get_name', array($item['id_agent_module'])); $nameService = enterprise_hook('services_get_name', array($item['id_agent_module']));
echo '<td class="sla_list_service_col">' . printSmallFont($nameService) . '</th>'; echo '<td class="sla_list_service_col">' . printSmallFont($nameService) . '</th>';
} }
echo '<td class="sla_list_sla_min_col">' . $item['sla_min'] . '</td>'; echo '<td class="sla_list_sla_min_col">' . $item['sla_min'] . '</td>';
echo '<td class="sla_list_sla_max_col">' . $item['sla_max'] . '</td>'; echo '<td class="sla_list_sla_max_col">' . $item['sla_max'] . '</td>';
echo '<td class="sla_list_sla_limit_col">' . $item['sla_limit'] . '</td>'; echo '<td class="sla_list_sla_limit_col">' . $item['sla_limit'] . '</td>';
@ -1424,7 +1441,8 @@ $(document).ready (function () {
minuteText: '<?php echo __('Minute');?>', minuteText: '<?php echo __('Minute');?>',
secondText: '<?php echo __('Second');?>', secondText: '<?php echo __('Second');?>',
currentText: '<?php echo __('Now');?>', currentText: '<?php echo __('Now');?>',
closeText: '<?php echo __('Close');?>'}); closeText: '<?php echo __('Close');?>'
});
}); });
function create_custom_graph() { function create_custom_graph() {
@ -1451,7 +1469,11 @@ function create_custom_graph() {
jQuery.ajax ({ jQuery.ajax ({
data: params1.join ("&"), data: params1.join ("&"),
type: 'POST', type: 'POST',
url: action= <?php echo '"' . ui_get_full_url(false, false, false, false) . '"'; ?> + "/ajax.php", url: action= <?php
echo '"' .
ui_get_full_url(false, false, false, false) .
'"';
?> + "/ajax.php",
async: false, async: false,
timeout: 10000, timeout: 10000,
success: function (data) { success: function (data) {
@ -1659,13 +1681,13 @@ function addSLARow() {
var slaMin = $("input[name=sla_min]").val(); var slaMin = $("input[name=sla_min]").val();
var slaMax = $("input[name=sla_max]").val(); var slaMax = $("input[name=sla_max]").val();
var slaLimit = $("input[name=sla_limit]").val(); var slaLimit = $("input[name=sla_limit]").val();
var serviceId = $("select#id_service>option:selected").val(); var serviceId = $("select#id_service>option:selected").val();
var serviceName = $("select#id_service>option:selected").text(); var serviceName = $("select#id_service>option:selected").text();
if (((idAgent != '') && (slaMin != '') && (slaMax != '') if (((idAgent != '') && (slaMin != '') && (slaMax != '')
&& (slaLimit != '')) || serviceId != '') { && (slaLimit != '')) || serviceId != '') {
if (nameAgent != '') { if (nameAgent != '') {
//Truncate nameAgent //Truncate nameAgent
var params = []; var params = [];
@ -1682,7 +1704,7 @@ function addSLARow() {
nameAgent = data; nameAgent = data;
} }
}); });
//Truncate nameModule //Truncate nameModule
var params = []; var params = [];
params.push("truncate_text=1"); params.push("truncate_text=1");
@ -1708,7 +1730,7 @@ function addSLARow() {
params.push("sla_max=" + slaMax); params.push("sla_max=" + slaMax);
params.push("sla_limit=" + slaLimit); params.push("sla_limit=" + slaLimit);
params.push("server_id=" + serverId); params.push("server_id=" + serverId);
if (serviceId != '') { if (serviceId != '') {
params.push("id_service=" + serviceId); params.push("id_service=" + serviceId);
} }
@ -1899,7 +1921,8 @@ function chooseType() {
$("#row_netflow_filter").hide(); $("#row_netflow_filter").hide();
$("#row_max_values").hide(); $("#row_max_values").hide();
$("#row_resolution").hide(); $("#row_resolution").hide();
$("#row_last_value").hide();
// SLA list default state // SLA list default state
$("#sla_list").hide(); $("#sla_list").hide();
$(".sla_list_agent_col").show(); $(".sla_list_agent_col").show();
@ -1983,7 +2006,7 @@ function chooseType() {
$("#row_only_display_wrong").show(); $("#row_only_display_wrong").show();
$("#row_working_time").show(); $("#row_working_time").show();
$("#row_sort").show(); $("#row_sort").show();
$(".sla_list_agent_col").hide(); $(".sla_list_agent_col").hide();
$(".sla_list_module_col").hide(); $(".sla_list_module_col").hide();
$(".sla_list_service_col").show(); $(".sla_list_service_col").show();
@ -2137,7 +2160,7 @@ function chooseType() {
$("#row_event_filter").show(); $("#row_event_filter").show();
$("#row_event_graphs").show(); $("#row_event_graphs").show();
$("#row_event_graph_by_agent").hide(); $("#row_event_graph_by_agent").hide();
$('#agent_autocomplete').hide(); $('#agent_autocomplete').hide();
$('#agent_autocomplete_events').show(); $('#agent_autocomplete_events').show();
break; break;
@ -2159,6 +2182,12 @@ function chooseType() {
$("#row_order_uptodown").show(); $("#row_order_uptodown").show();
$("#row_show_resume").show(); $("#row_show_resume").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
$("#row_last_value").show();
if ($("#hidden-period").val() == 0) {
$("#row_period").hide();
$("input[name='last_value']").prop("checked", true);
}
break; break;
case 'group_report': case 'group_report':
$("#row_group").show(); $("#row_group").show();
@ -2191,6 +2220,12 @@ function chooseType() {
$("#row_show_resume").show(); $("#row_show_resume").show();
$("#row_show_graph").show(); $("#row_show_graph").show();
$("#row_show_in_two_columns").show(); $("#row_show_in_two_columns").show();
$("#row_last_value").show();
if ($("#hidden-period").val() == 0) {
$("#row_period").hide();
$("input[name='last_value']").prop("checked", true);
}
break; break;
case 'agent_module': case 'agent_module':
$("#row_description").show(); $("#row_description").show();
@ -2292,4 +2327,19 @@ function chooseType() {
break; break;
} }
} }
function set_last_value_period() {
var checked = $("input[name='last_value']").prop("checked");
if (checked) {
$("#row_period").hide();
period_set_value($("#hidden-period").attr('class'), 0);
alert("<?php
echo __('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information');
?>");
}
else {
$("#row_period").show();
}
}
</script> </script>

View File

@ -639,7 +639,13 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">'; echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script, html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script,
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style); $nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
echo ' <a href="javascript:">'.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'), 'style' => 'width: 18px;')).'</a>'; echo ' <a href="javascript:">' .
html_print_image('images/pencil.png', true,
array('class' => $uniq_name . '_toggler',
'alt' => __('Custom'),
'title' => __('Custom'),
'style' => 'width: 18px;')) .
'</a>';
echo '</div>'; echo '</div>';
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">'; echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
@ -648,7 +654,12 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
html_print_input_hidden ($name, $selected, false, $uniq_name); html_print_input_hidden ($name, $selected, false, $uniq_name);
html_print_select ($units, $uniq_name . '_units', 1, "" . $script, html_print_select ($units, $uniq_name . '_units', 1, "" . $script,
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style); $nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
echo ' <a href="javascript:">'.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'), 'style' => 'width: 18px;')).'</a>'; echo ' <a href="javascript:">' .
html_print_image('images/default_list.png', true,
array('class' => $uniq_name . '_toggler',
'alt' => __('List'),
'title' => __('List'), 'style' => 'width: 18px;')) .
'</a>';
echo '</div>'; echo '</div>';
echo "<script type='text/javascript'> echo "<script type='text/javascript'>
$(document).ready (function () { $(document).ready (function () {

View File

@ -52,7 +52,7 @@ function reporting_get_agentmodule_data_average ($id_agent_module, $period=0, $d
// Initialize variables // Initialize variables
if (empty ($date)) $date = get_system_time (); if (empty ($date)) $date = get_system_time ();
$datelimit = $date - $period; $datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
$id_module_type = modules_get_agentmodule_type ($id_agent_module); $id_module_type = modules_get_agentmodule_type ($id_agent_module);
@ -157,9 +157,9 @@ function reporting_get_agentmodule_data_max ($id_agent_module, $period=0, $date
// Initialize variables // Initialize variables
if (empty ($date)) $date = get_system_time (); if (empty ($date)) $date = get_system_time ();
$datelimit = $date - $period; $datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
$id_module_type = modules_get_agentmodule_type ($id_agent_module); $id_module_type = modules_get_agentmodule_type ($id_agent_module);
$module_type = modules_get_moduletype_name ($id_module_type); $module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type); $uncompressed_module = is_module_uncompressed ($module_type);
@ -308,16 +308,21 @@ function reporting_get_agentmodule_data_min ($id_agent_module, $period=0, $date
* *
* @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 ($id_agent_module, $period=0, $date = 0) { function reporting_get_agentmodule_data_sum ($id_agent_module,
$period = 0, $date = 0) {
global $config; global $config;
// Initialize variables // Initialize variables
if (empty ($date)) $date = get_system_time (); if (empty ($date)) $date = get_system_time ();
$datelimit = $date - $period; $datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
$id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo','id_agente_modulo', $id_agent_module); $id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo',
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo', $id_module_type); 'id_agente_modulo', $id_agent_module);
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo',
$id_module_type);
$module_interval = modules_get_interval ($id_agent_module); $module_interval = modules_get_interval ($id_agent_module);
$uncompressed_module = is_module_uncompressed ($module_name); $uncompressed_module = is_module_uncompressed ($module_name);
@ -330,11 +335,12 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date
$module_inc = is_module_inc ($module_name); $module_inc = is_module_inc ($module_name);
// Get module data // Get module data
$interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos $interval_data = db_get_all_rows_sql('
WHERE id_agente_modulo = ' . (int) $id_agent_module . SELECT * FROM tagente_datos
' AND utimestamp > ' . (int) $datelimit . WHERE id_agente_modulo = ' . (int) $id_agent_module . '
' AND utimestamp < ' . (int) $date . AND utimestamp > ' . (int) $datelimit . '
' ORDER BY utimestamp ASC', $search_in_history_db); AND utimestamp < ' . (int) $date . '
ORDER BY utimestamp ASC', $search_in_history_db);
if ($interval_data === false) $interval_data = array (); if ($interval_data === false) $interval_data = array ();
// Uncompressed module data // Uncompressed module data
@ -412,7 +418,7 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date
*/ */
function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) { function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) {
global $config; global $config;
if (empty($id_agent_module)) if (empty($id_agent_module))
return false; return false;
@ -425,7 +431,7 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_valu
} }
// Limit date to start searching data // Limit date to start searching data
$datelimit = $date - $period; $datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
// Get interval data // Get interval data
@ -581,7 +587,7 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0, $min_valu
*/ */
function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) { function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $min_value = 1, $max_value = false, $date = 0, $daysWeek = null, $timeFrom = null, $timeTo = null) {
global $config; global $config;
if (empty($id_agent_module)) if (empty($id_agent_module))
return false; return false;
@ -681,15 +687,15 @@ function reporting_get_agentmodule_sla_array ($id_agent_module, $period = 0, $mi
// Add unknown periods to data // Add unknown periods to data
for ($i = 0; isset($events_unknown[$i]); $i++) { for ($i = 0; isset($events_unknown[$i]); $i++) {
$eu = $events_unknown[$i]; $eu = $events_unknown[$i];
if ($eu['event_type'] == 'going_unknown') { if ($eu['event_type'] == 'going_unknown') {
$interval_data_indexed[$eu['utimestamp']]['data'] = 0; $interval_data_indexed[$eu['utimestamp']]['data'] = 0;
$interval_data_indexed[$eu['utimestamp']]['status'] = 4; $interval_data_indexed[$eu['utimestamp']]['status'] = 4;
// Search the corresponding recovery event. // Search the corresponding recovery event.
for ($j = $i+1; isset($events_unknown[$j]); $j++) { for ($j = $i+1; isset($events_unknown[$j]); $j++) {
$eu = $events_unknown[$j]; $eu = $events_unknown[$j];
if ($eu['event_type'] != 'going_unknown' && substr ($eu['event_type'], 0, 5) == 'going') { if ($eu['event_type'] != 'going_unknown' && substr ($eu['event_type'], 0, 5) == 'going') {
$interval_data_indexed[$eu['utimestamp']]['data'] = 0; $interval_data_indexed[$eu['utimestamp']]['data'] = 0;
$interval_data_indexed[$eu['utimestamp']]['status'] = 6; $interval_data_indexed[$eu['utimestamp']]['status'] = 6;
@ -5360,28 +5366,34 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$mod_name = modules_get_agentmodule_name ($row['id_agent_module']); $mod_name = modules_get_agentmodule_name ($row['id_agent_module']);
$ag_name = modules_get_agentmodule_agent_name ($row['id_agent_module']); $ag_name = modules_get_agentmodule_agent_name ($row['id_agent_module']);
switch ($row['operation']) { if ($content['period'] == 0) {
case 'sum': $data_res[$key] =
$data_res[$key] = modules_get_last_value($row['id_agent_module']);
reporting_get_agentmodule_data_sum( }
$row['id_agent_module'], $content['period'], $report["datetime"]); else {
break; switch ($row['operation']) {
case 'max': case 'sum':
$data_res[$key] = $data_res[$key] =
reporting_get_agentmodule_data_max( reporting_get_agentmodule_data_sum(
$row['id_agent_module'], $content['period']); $row['id_agent_module'], $content['period'], $report["datetime"]);
break; break;
case 'min': case 'max':
$data_res[$key] = $data_res[$key] =
reporting_get_agentmodule_data_min( reporting_get_agentmodule_data_max(
$row['id_agent_module'], $content['period']); $row['id_agent_module'], $content['period']);
break; break;
case 'avg': case 'min':
default: $data_res[$key] =
$data_res[$key] = reporting_get_agentmodule_data_min(
reporting_get_agentmodule_data_average( $row['id_agent_module'], $content['period']);
$row['id_agent_module'], $content['period']); break;
break; case 'avg':
default:
$data_res[$key] =
reporting_get_agentmodule_data_average(
$row['id_agent_module'], $content['period']);
break;
}
} }
$unit = db_get_value('unit', 'tagente_modulo', $unit = db_get_value('unit', 'tagente_modulo',
@ -5592,20 +5604,27 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$found = false; $found = false;
if (strcmp($a, $agent_name) == 0 if (strcmp($a, $agent_name) == 0
&& strcmp($m, $module_name . ' (' . $g['operation'] . ')') == 0) { && strcmp($m, $module_name . ' (' . $g['operation'] . ')') == 0) {
switch ($g['operation']) {
case 'sum': if ($content['period'] == 0) {
$value_res = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]); $value_res =
break; modules_get_last_value($g['id_agent_module']);
case 'max': }
$value_res = reporting_get_agentmodule_data_max ($g['id_agent_module'], $content['period']); else {
break; switch ($g['operation']) {
case 'min': case 'sum':
$value_res = reporting_get_agentmodule_data_min ($g['id_agent_module'], $content['period']); $value_res = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
break; break;
case 'avg': case 'max':
default: $value_res = reporting_get_agentmodule_data_max ($g['id_agent_module'], $content['period']);
$value_res = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']); break;
break; case 'min':
$value_res = reporting_get_agentmodule_data_min ($g['id_agent_module'], $content['period']);
break;
case 'avg':
default:
$value_res = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
break;
}
} }
if ($value_res === false) { if ($value_res === false) {
@ -5666,20 +5685,27 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
continue; continue;
} }
} }
switch ($generals[$i]['operation']) {
case 'sum': if ($content['period'] == 0) {
$min = reporting_get_agentmodule_data_sum ($generals[$i]['id_agent_module'], $content['period'], $report["datetime"]); $min =
break; modules_get_last_value($generals[$i]['id_agent_module']);
case 'max': }
$min = reporting_get_agentmodule_data_max ($generals[$i]['id_agent_module'], $content['period']); else {
break; switch ($generals[$i]['operation']) {
case 'min': case 'sum':
$min = reporting_get_agentmodule_data_min ($generals[$i]['id_agent_module'], $content['period']); $min = reporting_get_agentmodule_data_sum ($generals[$i]['id_agent_module'], $content['period'], $report["datetime"]);
break; break;
case 'avg': case 'max':
default: $min = reporting_get_agentmodule_data_max ($generals[$i]['id_agent_module'], $content['period']);
$min = reporting_get_agentmodule_data_average ($generals[$i]['id_agent_module'], $content['period']); break;
break; case 'min':
$min = reporting_get_agentmodule_data_min ($generals[$i]['id_agent_module'], $content['period']);
break;
case 'avg':
default:
$min = reporting_get_agentmodule_data_average ($generals[$i]['id_agent_module'], $content['period']);
break;
}
} }
$i++; $i++;
@ -5718,20 +5744,27 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
continue; continue;
} }
} }
switch ($g['operation']) {
case 'sum': if ($content['period'] == 0) {
$value = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]); $value =
break; modules_get_last_value($g['id_agent_module']);
case 'max': }
$value = reporting_get_agentmodule_data_max ($g['id_agent_module'], $content['period']); else {
break; switch ($g['operation']) {
case 'min': case 'sum':
$value = reporting_get_agentmodule_data_min ($g['id_agent_module'], $content['period']); $value = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
break; break;
case 'avg': case 'max':
default: $value = reporting_get_agentmodule_data_max ($g['id_agent_module'], $content['period']);
$value = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']); break;
break; case 'min':
$value = reporting_get_agentmodule_data_min ($g['id_agent_module'], $content['period']);
break;
case 'avg':
default:
$value = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
break;
}
} }
if ($value !== false) { if ($value !== false) {
@ -6247,16 +6280,25 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
} }
} }
switch ($exceptions[$i]['operation']) { if ($content['period'] == 0) {
case 'avg': $min =
$min = reporting_get_agentmodule_data_average($exceptions[$i]['id_agent_module'], $content['period']); modules_get_last_value($exceptions[$i]['id_agent_module']);
break; }
case 'max': else {
$min = reporting_get_agentmodule_data_max($exceptions[$i]['id_agent_module'], $content['period']); switch ($exceptions[$i]['operation']) {
break; case 'avg':
case 'min': $min = reporting_get_agentmodule_data_average(
$min = reporting_get_agentmodule_data_min($exceptions[$i]['id_agent_module'], $content['period']); $exceptions[$i]['id_agent_module'], $content['period']);
break; break;
case 'max':
$min = reporting_get_agentmodule_data_max(
$exceptions[$i]['id_agent_module'], $content['period']);
break;
case 'min':
$min = reporting_get_agentmodule_data_min(
$exceptions[$i]['id_agent_module'], $content['period']);
break;
}
} }
$i++; $i++;
@ -6286,16 +6328,22 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$unit = db_get_value('unit', 'tagente_modulo', $unit = db_get_value('unit', 'tagente_modulo',
'id_agente_modulo', $exc['id_agent_module']); 'id_agente_modulo', $exc['id_agent_module']);
switch ($exc['operation']) { if ($content['period'] == 0) {
case 'avg': $value =
$value = reporting_get_agentmodule_data_average ($exc['id_agent_module'], $content['period']); modules_get_last_value($exceptions[$i]['id_agent_module']);
break; }
case 'max': else {
$value = reporting_get_agentmodule_data_max ($exc['id_agent_module'], $content['period']); switch ($exc['operation']) {
break; case 'avg':
case 'min': $value = reporting_get_agentmodule_data_average ($exc['id_agent_module'], $content['period']);
$value = reporting_get_agentmodule_data_min ($exc['id_agent_module'], $content['period']); break;
break; case 'max':
$value = reporting_get_agentmodule_data_max ($exc['id_agent_module'], $content['period']);
break;
case 'min':
$value = reporting_get_agentmodule_data_min ($exc['id_agent_module'], $content['period']);
break;
}
} }
if ($value !== false) { if ($value !== false) {
@ -6476,7 +6524,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table->colspan[3][0] = 3; $table->colspan[3][0] = 3;
$table->cellstyle[3][0] = 'text-align: center;'; $table->cellstyle[3][0] = 'text-align: center;';
$data = array(); $data = array();
if ($show_graph == 1 || $show_graph == 2) { if ($show_graph == 1 || $show_graph == 2) {
$data[0] = pie3d_graph(false, $data_pie_graph, $data[0] = pie3d_graph(false, $data_pie_graph,
@ -7993,4 +8041,4 @@ function reporting_network_interfaces_table ($content, $report, $mini, $item_tit
} }
} }
} }
?> ?>

View File

@ -501,25 +501,27 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
*/ */
function period_select_init(name) { function period_select_init(name) {
// Manual mode is hidden by default // Manual mode is hidden by default
$('#'+name+'_manual').hide(); $('#' + name + '_manual').hide();
$('#'+name+'_default').show(); $('#' + name + '_default').show();
// If the text input is empty, we put on it 5 minutes by default // If the text input is empty, we put on it 5 minutes by default
if($('#text-'+name+'_text').val() == '') { if ($('#text-' + name + '_text').val() == '') {
$('#text-'+name+'_text').val(300); $('#text-' + name + '_text').val(300);
// Set the value in the hidden field too // Set the value in the hidden field too
$('.'+name).val(300); $('.' + name).val(300);
if($('#'+name+'_select option:eq(0)').val() == 0) { if ($('#' + name + '_select option:eq(0)').val() == 0) {
$('#'+name+'_select option:eq(2)').attr('selected', 'selected'); $('#' + name + '_select option:eq(2)')
.attr('selected', 'selected');
} }
else { else {
$('#'+name+'_select option:eq(1)').attr('selected', 'selected'); $('#' + name + '_select option:eq(1)')
.attr('selected', 'selected');
} }
} }
else if($('#text-'+name+'_text').val() == 0) { else if ($('#text-' + name + '_text').val() == 0) {
$('#'+name+'_units option:last').removeAttr('selected'); $('#' + name + '_units option:last').removeAttr('selected');
$('#'+name+'_manual').show(); $('#' + name + '_manual').show();
$('#'+name+'_default').hide(); $('#' + name + '_default').hide();
} }
} }
@ -532,58 +534,67 @@ function period_select_init(name) {
* @param name string with the name of the select for time * @param name string with the name of the select for time
*/ */
function period_select_events(name) { function period_select_events(name) {
$('.'+name+'_toggler').click(function() { $('.' + name + '_toggler').click(function() {
toggleBoth(name); toggleBoth(name);
$('#text-'+name+'_text').focus(); $('#text-' + name + '_text').focus();
}); });
adjustTextUnits(name); adjustTextUnits(name);
// When select a default period, is setted in seconds // When select a default period, is setted in seconds
$('#'+name+'_select').change(function() { $('#' + name + '_select').change(function() {
var value = $('#'+name+'_select').val(); var value = $('#' + name + '_select').val();
if(value == -1) { if (value == -1) {
value = 300; value = 300;
toggleBoth(name); toggleBoth(name);
$('#text-'+name+'_text').focus(); $('#text-' + name + '_text').focus();
} }
$('.'+name).val(value); $('.' + name).val(value);
$('#text-'+name+'_text').val(value); $('#text-' + name + '_text').val(value);
adjustTextUnits(name); adjustTextUnits(name);
}); });
// When select a custom units, the default period changes to 'custom' and // When select a custom units, the default period changes to
// the time in seconds is calculated into hidden input // 'custom' and the time in seconds is calculated into hidden input
$('#'+name+'_units').change(function() { $('#' + name + '_units').change(function() {
selectFirst(name); selectFirst(name);
calculateSeconds(name); calculateSeconds(name);
}); });
// When write any character into custom input, it check to convert it to // When write any character into custom input, it check to convert
// integer and calculate in seconds into hidden input // it to integer and calculate in seconds into hidden input
$('#text-'+name+'_text').keyup (function () { $('#text-' + name + '_text').keyup (function () {
var cleanValue = parseInt($('#text-'+name+'_text').val()); var cleanValue = parseInt($('#text-' + name + '_text').val());
if(isNaN(cleanValue)) { if (isNaN(cleanValue)) {
cleanValue = ''; cleanValue = '';
} }
$('#text-'+name+'_text').val(cleanValue); $('#text-' + name + '_text').val(cleanValue);
selectFirst(name+'_select'); selectFirst(name + '_select');
calculateSeconds(name); calculateSeconds(name);
}); });
} }
function period_set_value(name, value) {
$("#text-" + name + "_text").val(value);
adjustTextUnits(name);
calculateSeconds(name);
selectFirst(name + '_select');
$("#" + name + "_manual").hide();
$("#" + name + "_default").show();
}
/** /**
* *
* Select first option of a select if is not value=0 * Select first option of a select if is not value=0
* *
*/ */
function selectFirst(name) { function selectFirst(name) {
if($('#'+name+' option:eq(0)').val() == 0) { if ($('#'+name+' option:eq(0)').val() == 0) {
$('#'+name+' option:eq(1)').attr('selected', 'selected'); $('#'+name+' option:eq(1)').attr('selected', 'selected');
} }
else { else {
@ -598,16 +609,15 @@ function selectFirst(name) {
* work properly when the divs are into a hiden div * work properly when the divs are into a hiden div
* *
*/ */
function toggleBoth(name) { function toggleBoth(name) {
if($('#'+name+'_default').css('display') == 'none') { if ($('#'+name+'_default').css('display') == 'none') {
$('#'+name+'_default').css('display','inline'); $('#'+name+'_default').css('display','inline');
} }
else { else {
$('#'+name+'_default').css('display','none'); $('#'+name+'_default').css('display','none');
} }
if($('#'+name+'_manual').css('display') == 'none') { if ($('#'+name+'_manual').css('display') == 'none') {
$('#'+name+'_manual').css('display','inline'); $('#'+name+'_manual').css('display','inline');
} }
else { else {
@ -621,9 +631,10 @@ function toggleBoth(name) {
* *
*/ */
function calculateSeconds(name) { function calculateSeconds(name) {
var calculated = $('#text-'+name+'_text').val()*$('#'+name+'_units').val(); var calculated =
$('#text-' + name + '_text').val() * $('#' + name + '_units').val();
$('.'+name).val(calculated); $('.' + name).val(calculated);
} }
/** /**
@ -632,11 +643,11 @@ function calculateSeconds(name) {
* *
*/ */
function period_select_update(name, seconds) { function period_select_update(name, seconds) {
$('#text-'+name+'_text').val(seconds); $('#text-' + name + '_text').val(seconds);
adjustTextUnits(name); adjustTextUnits(name);
calculateSeconds(name); calculateSeconds(name);
$('#'+name+'_manual').show(); $('#' + name + '_manual').show();
$('#'+name+'_default').hide(); $('#' + name + '_default').hide();
} }
/** /**
@ -911,4 +922,4 @@ function show_dialog_qrcode(dialog, text, where, width, height) {
function openURLTagWindow(url) { function openURLTagWindow(url) {
window.open(url, '','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no'); window.open(url, '','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no');
} }