From 43e7d9cb9dcdb5c7457044165d94d64a523c9288 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 10 Aug 2025 17:44:25 +0100 Subject: [PATCH] Fix undefined index errors in statistics tables Initialize bandcalls and modecalls arrays with default zero values in Stats.php to prevent undefined index errors. Update qsotable.php and uniquetable.php views to display 0 when mode or band totals are not set. --- application/models/Stats.php | 10 ++++++++++ application/views/statistics/qsotable.php | 2 +- application/views/statistics/uniquetable.php | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/application/models/Stats.php b/application/models/Stats.php index 8fb9bf20..2cdbf1c7 100644 --- a/application/models/Stats.php +++ b/application/models/Stats.php @@ -88,10 +88,20 @@ } } + // Initialize bandcalls array with all bands set to 0 + foreach ($bands as $band) { + $bandcalls[$band] = 0; + } + foreach ($bandunique as $band) { $bandcalls[$band->band] = $band->calls; } + // Initialize modecalls array with all modes set to 0 + foreach ($modes as $mode) { + $modecalls[$mode] = 0; + } + foreach ($modeunique as $mode) { //if ($mode->col_submode == null) { if ($mode->col_submode == null || $mode->col_submode == "") { diff --git a/application/views/statistics/qsotable.php b/application/views/statistics/qsotable.php index 7f963fb3..0b80943f 100644 --- a/application/views/statistics/qsotable.php +++ b/application/views/statistics/qsotable.php @@ -17,7 +17,7 @@ if ($qsoarray) { foreach ($value as $key => $val) { echo '' . $val . ''; } - echo '' . $modetotal[$mode] . ''; + echo '' . (isset($modetotal[$mode]) ? $modetotal[$mode] : 0) . ''; echo ''; } echo ''.lang('statistics_total').''; diff --git a/application/views/statistics/uniquetable.php b/application/views/statistics/uniquetable.php index 0a25b170..7685bf2c 100644 --- a/application/views/statistics/uniquetable.php +++ b/application/views/statistics/uniquetable.php @@ -17,13 +17,13 @@ if ($qsoarray) { foreach ($value as $key => $val) { echo '' . $val . ''; } - echo '' . $modeunique[$mode] . ''; + echo '' . (isset($modeunique[$mode]) ? $modeunique[$mode] : 0) . ''; echo ''; } echo ''.lang('statistics_total').''; foreach($bands as $band) { - echo '' . $bandunique[$band] . ''; + echo '' . (isset($bandunique[$band]) ? $bandunique[$band] : 0) . ''; } echo '' . $total->calls . ''; echo '';