diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index b03a30d31..55fb874c8 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -1719,6 +1719,15 @@ class Awards extends CI_Controller { $this->load->model('dxcc'); $this->load->model('bands'); + $data['worked_bands'] = $this->bands->get_worked_bands('dxcc'); + + if ($this->input->post('band') == 'All') { + $bands = $data['worked_bands']; + } + else { + $bands[] = $this->input->post('band'); + } + $bands[] = $this->security->xss_clean($this->input->post('band')); $postdata['qsl'] = ($this->input->post('qsl',true) ?? 0) == 0 ? NULL: 1; diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 2c5668a5a..b127a520a 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -86,14 +86,11 @@ class DXCC extends CI_Model { continue; } - // Ensure string key for consistency - $dxccKey = (string)$dxcc->dxcc; - // Track worked status for this DXCC - if (!isset($dxccWorkedStatus[$dxccKey])) { - $dxccWorkedStatus[$dxccKey] = 0; + if (!isset($dxccWorkedStatus[$dxcc->dxcc])) { + $dxccWorkedStatus[$dxcc->dxcc] = 0; } - $dxccWorkedStatus[$dxccKey]++; + $dxccWorkedStatus[$dxcc->dxcc]++; // Check if confirmed based on the confirmation types selected in postdata $isConfirmed = false; @@ -120,19 +117,19 @@ class DXCC extends CI_Model { } if ($isConfirmed) { - $dxccMatrix[$dxccKey][$dxcc->col_band] = '
dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>'.$confirmationLetters.'
'; + $dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '
dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>'.$confirmationLetters.'
'; // Track confirmed DXCCs for summary - if (!isset($confirmedDxccs[$dxcc->col_band][$dxccKey])) { - $confirmedDxccs[$dxcc->col_band][$dxccKey] = true; + if (!isset($confirmedDxccs[$dxcc->col_band][$dxcc->dxcc])) { + $confirmedDxccs[$dxcc->col_band][$dxcc->dxcc] = true; $summary['confirmed'][$dxcc->col_band]++; } } else { - $dxccMatrix[$dxccKey][$dxcc->col_band] = '
dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W
'; + $dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '
dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W
'; } // Track worked DXCCs for summary - if (!isset($workedDxccs[$dxcc->col_band][$dxccKey])) { - $workedDxccs[$dxcc->col_band][$dxccKey] = true; + if (!isset($workedDxccs[$dxcc->col_band][$dxcc->dxcc])) { + $workedDxccs[$dxcc->col_band][$dxcc->dxcc] = true; $summary['worked'][$dxcc->col_band]++; } } @@ -182,8 +179,8 @@ class DXCC extends CI_Model { if (!isset($confirmedDxccs[$dxcc->col_band][$dxccKey])) { $confirmedDxccs[$dxcc->col_band][$dxccKey] = true; $summary['confirmed'][$dxcc->col_band]++; - } - } else { + } + } else { $dxccMatrix[$dxccKey][$dxcc->col_band] = '
dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W
'; } @@ -246,13 +243,25 @@ class DXCC extends CI_Model { // If this is for the map, return simplified format if ($map) { $mapDxccs = []; - foreach ($dxccMatrix as $dxcc => $data) { - if (!isset($totalWorkedDxccs[$dxcc])) { - $mapDxccs[$dxcc] = '-'; // Not worked - } elseif (isset($totalConfirmedDxccs[$dxcc])) { - $mapDxccs[$dxcc] = 'C'; // Confirmed - } else { - $mapDxccs[$dxcc] = 'W'; // Worked but not confirmed + if ($bands[0] == 'SAT') { + foreach ($dxccMatrix as $dxcc => $data) { + if (isset($confirmedDxccs['SAT'][$dxcc])) { + $mapDxccs[$dxcc] = 'C'; // Confirmed + } elseif (isset($workedDxccs['SAT'][$dxcc])) { + $mapDxccs[$dxcc] = 'W'; // Worked but not confirmed + } else { + $mapDxccs[$dxcc] = '-'; // Not worked + } + } + } else { + foreach ($dxccMatrix as $dxcc => $data) { + if (isset($totalConfirmedDxccs[$dxcc])) { + $mapDxccs[$dxcc] = 'C'; // Confirmed + } elseif (isset($totalWorkedDxccs[$dxcc])) { + $mapDxccs[$dxcc] = 'W'; // Worked but not confirmed + } else { + $mapDxccs[$dxcc] = '-'; // Not worked + } } } return $mapDxccs; diff --git a/assets/js/sections/dxccmap.js b/assets/js/sections/dxccmap.js index 962ef239c..ca3ad4f7b 100644 --- a/assets/js/sections/dxccmap.js +++ b/assets/js/sections/dxccmap.js @@ -157,7 +157,8 @@ function load_dxcc_map2(data, worked, confirmed, notworked) { legend.onAdd = function(map) { var div = L.DomUtil.create("div", "legend"); - div.innerHTML += "

Colors

"; + var band = $('#band2').val(); + div.innerHTML += "

Band: " + band + "

"; div.innerHTML += '' + lang_general_word_confirmed + ' ('+confirmedcount+')
'; div.innerHTML += '' + lang_general_word_worked_not_confirmed + ' ('+workednotconfirmedcount+')
'; div.innerHTML += '' + lang_general_word_not_worked + ' ('+notworkedcount+')
';