Skip to content

Commit

Permalink
QA: Additional Fixes for #5555
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Nov 20, 2023
1 parent 2e2ef63 commit ec78e25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions aggregate_graphs.php
Expand Up @@ -1016,11 +1016,11 @@ function changeTotals() {

function changeTotalsType() {
if ($('#total_type').val() == <?php print AGGREGATE_TOTAL_TYPE_SIMILAR;?>) {
if ($('#total_prefix').val() == '') {
if ($('#total_prefix').val() == '' && $('#id').val() == 0) {
$('#total_prefix').attr('value', '<?php print __('Total');?>');
}
} else if ($('#total_type').val() == <?php print AGGREGATE_TOTAL_TYPE_ALL;?>) {
if ($('#total_prefix').val() == '') {
if ($('#total_prefix').val() == '' && $('#id').val() == 0) {
$('#total_prefix').attr('value', '<?php print __('All Items');?>');
}
}
Expand Down
4 changes: 2 additions & 2 deletions aggregate_templates.php
Expand Up @@ -518,11 +518,11 @@ function changeTotals() {

function changeTotalsType() {
if ($('#total_type').val() == <?php print AGGREGATE_TOTAL_TYPE_SIMILAR;?>) {
if ($('#total_prefix').val() == '') {
if ($('#total_prefix').val() == '' && $('#id').val() == 0) {
$('#total_prefix').attr('value', '<?php print __('Total');?>');
}
} else if ($('#total_type').val() == <?php print AGGREGATE_TOTAL_TYPE_ALL;?>) {
if ($('#total_prefix').val() == '') {
if ($('#total_prefix').val() == '' && $('#id').val() == 0) {
$('#total_prefix').attr('value', '<?php print __('All Items');?>');
}
}
Expand Down
21 changes: 15 additions & 6 deletions lib/api_aggregate.php
Expand Up @@ -1320,12 +1320,19 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
static $special_comments = null;
static $special_hrules = null;

if (cacti_sizeof($member_graphs)) {
$template_graph[] = $member_graphs[0];
} else {
$template_graph = array();
}

$comments_hrules = db_fetch_assoc('SELECT *
FROM graph_templates_item
WHERE graph_type_id IN(' . GRAPH_ITEM_TYPE_COMMENT . ',' . GRAPH_ITEM_TYPE_HRULE . ')' .
(cacti_sizeof($member_graphs) ? ' AND ' . array_to_sql_or($member_graphs, 'local_graph_id'):'') .
(cacti_sizeof($template_graph) ? ' AND ' . array_to_sql_or($template_graph, 'local_graph_id'):'') .
(cacti_sizeof($skipped_items) ? ' AND local_graph_id NOT IN(' . implode(',', $skipped_items) . ')':'') . '
ORDER BY graph_type_id DESC');
AND (text_format != "" || value != "")
ORDER BY local_graph_id, sequence ASC');

$next_item_sequence = db_fetch_cell_prepared('SELECT MAX(sequence)
FROM graph_templates_item
Expand Down Expand Up @@ -1456,10 +1463,12 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
}
}

// add an empty line before nth percentile
db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, 1, 1, '', '', 'on', 2, ?)", array($local_graph_id, $next_item_sequence++));
// add an empty line before nth percentile for the first item only
if (cacti_sizeof($special_hrules) == 1) {
db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, 1, 1, '', '', 'on', 2, ?)", array($local_graph_id, $next_item_sequence++));
}

db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, graph_type_id, color_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
Expand Down

0 comments on commit ec78e25

Please sign in to comment.