diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 3379dc64a..168d5adac 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -666,37 +666,41 @@ class Awards extends CI_Controller { $data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view - if($this->input->method() === 'post') { - $postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl')); - $postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw')); - $postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl')); - $postdata['qrz'] = $this->security->xss_clean($this->input->post('qrz')); - $postdata['worked'] = $this->security->xss_clean($this->input->post('worked')); - $postdata['confirmed'] = $this->security->xss_clean($this->input->post('confirmed')); - $postdata['notworked'] = $this->security->xss_clean($this->input->post('notworked')); - $postdata['band'] = $this->security->xss_clean($this->input->post('band')); + if($this->input->method() === 'post') { + $postdata['qsl'] = ($this->input->post('qsl',true) ?? 0) == 0 ? NULL: 1; + $postdata['lotw'] = ($this->input->post('lotw',true) ?? 0) == 0 ? NULL: 1; + $postdata['eqsl'] = ($this->input->post('eqsl',true) ?? 0) == 0 ? NULL: 1; + $postdata['qrz'] = ($this->input->post('qrz',true) ?? 0) == 0 ? NULL: 1; + $postdata['clublog'] = ($this->input->post('clublog',true) ?? 0) == 0 ? NULL: 1; + $postdata['worked'] = ($this->input->post('worked',true) ?? 0) == 0 ? NULL: 1; + $postdata['confirmed'] = ($this->input->post('confirmed',true) ?? 0) == 0 ? NULL: 1; + $postdata['notworked'] = ($this->input->post('notworked',true) ?? 0) == 0 ? NULL: 1; + $postdata['band'] = $this->security->xss_clean($this->input->post('band')); $postdata['mode'] = $this->security->xss_clean($this->input->post('mode')); $postdata['datefrom'] = $this->security->xss_clean($this->input->post('dateFrom')); $postdata['dateto'] = $this->security->xss_clean($this->input->post('dateTo')); - } - else { // Setting default values at first load of page - $postdata['qsl'] = 1; - $postdata['lotw'] = 1; - $postdata['eqsl'] = 0; - $postdata['qrz'] = 0; - $postdata['worked'] = 1; - $postdata['confirmed'] = 1; - $postdata['notworked'] = 1; - $postdata['band'] = 'All'; + } + else { // Setting default values at first load of page + $postdata['qsl'] = 1; + $postdata['lotw'] = 1; + $postdata['eqsl'] = NULL; + $postdata['qrz'] = NULL; + $postdata['clublog'] = NULL; + $postdata['worked'] = 1; + $postdata['confirmed'] = 1; + $postdata['notworked'] = 1; + $postdata['band'] = 'All'; $postdata['mode'] = 'All'; $postdata['datefrom'] = null; $postdata['dateto'] = null; - } + } if ($logbooks_locations_array) { $location_list = "'".implode("','",$logbooks_locations_array)."'"; - $data['cq_array'] = $this->cq->get_cq_array($bands, $postdata, $location_list); - $data['cq_summary'] = $this->cq->get_cq_summary($bands, $postdata, $location_list); + $cq_result = $this->cq->get_cq_array($bands, $postdata, $location_list); + // Extract bands data and summary from the result + $data['cq_array'] = ($cq_result && isset($cq_result['bands'])) ? $cq_result['bands'] : null; + $data['cq_summary'] = ($cq_result && isset($cq_result['summary'])) ? $cq_result['summary'] : null; } else { $location_list = null; $data['cq_array'] = null; @@ -1618,7 +1622,8 @@ class Awards extends CI_Controller { if ($logbooks_locations_array) { $location_list = "'".implode("','",$logbooks_locations_array)."'"; - $cq_array = $this->cq->get_cq_array($bands, $postdata, $location_list, $this->user_map_color_qso, $this->user_map_color_qsoconfirm); + $cq_result = $this->cq->get_cq_array($bands, $postdata, $location_list); + $cq_array = ($cq_result && isset($cq_result['bands'])) ? $cq_result['bands'] : null; } else { $location_list = null; $cq_array = null; diff --git a/application/models/Cq.php b/application/models/Cq.php index 8632ba971..d5966bd73 100644 --- a/application/models/Cq.php +++ b/application/models/Cq.php @@ -22,124 +22,190 @@ class CQ extends CI_Model{ } } - // Get all worked zones for all bands in ONE query - if ($postdata['worked'] != NULL) { - $cqBand = $this->getCQWorkedAllBands($location_list, $bands, $postdata); - foreach ($cqBand as $line) { - $band = $line->col_band; - $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W
'; - $cqZ[$line->col_cqz]['count']++; + // Initialize summary counters only for the bands passed in + foreach ($bands as $band) { + $summary['worked'][$band] = 0; + $summary['confirmed'][$band] = 0; + } + $summary['worked']['Total'] = 0; + $summary['confirmed']['Total'] = 0; + + // Track unique zone/band combinations for totals + $workedZones = []; // [band][zone] = true + $confirmedZones = []; // [band][zone] = true + + // Create a lookup array for valid bands + $validBands = array_flip($bands); // ['160m' => true, '80m' => true, etc] + + $cqdata = $this->getCqZoneData($location_list, $postdata); + $cqdata_sat = $this->getCqZoneDataSat($location_list, $postdata); + + foreach ($cqdata as $cq) { + // Skip if this band is not in our requested bands list + if (!isset($validBands[$cq->col_band])) { + continue; + } + + $cqZ[$cq->col_cqz]['count']++; // Count each cq zone + + // Check if confirmed based on the confirmation types selected in postdata + $isConfirmed = false; + $confirmationLetters = ''; + if (isset($postdata['qsl']) && $postdata['qsl'] == 1 && $cq->qsl == 1) { + $isConfirmed = true; + $confirmationLetters .= 'Q'; + } + if (isset($postdata['lotw']) && $postdata['lotw'] == 1 && $cq->lotw == 1) { + $isConfirmed = true; + $confirmationLetters .= 'L'; + } + if (isset($postdata['eqsl']) && $postdata['eqsl'] == 1 && $cq->eqsl == 1) { + $isConfirmed = true; + $confirmationLetters .= 'E'; + } + if (isset($postdata['qrz']) && $postdata['qrz'] == 1 && $cq->qrz == 1) { + $isConfirmed = true; + $confirmationLetters .= 'Z'; + } + if (isset($postdata['clublog']) && $postdata['clublog'] == 1 && $cq->clublog == 1) { + $isConfirmed = true; + $confirmationLetters .= 'C'; + } + + if ($isConfirmed) { + $bandCq[$cq->col_cqz][$cq->col_band] = '
col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>' . $confirmationLetters . '
'; + // Track confirmed zones for summary + if (!isset($confirmedZones[$cq->col_band][$cq->col_cqz])) { + $confirmedZones[$cq->col_band][$cq->col_cqz] = true; + $summary['confirmed'][$cq->col_band]++; + } + } else { + $bandCq[$cq->col_cqz][$cq->col_band] = '
col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W
'; + } + + // Track worked zones for summary + if (!isset($workedZones[$cq->col_band][$cq->col_cqz])) { + $workedZones[$cq->col_band][$cq->col_cqz] = true; + $summary['worked'][$cq->col_band]++; } } - // Get all confirmed zones for all bands in ONE query - if ($postdata['confirmed'] != NULL) { - $cqBand = $this->getCQConfirmedAllBands($location_list, $bands, $postdata); - foreach ($cqBand as $line) { - $band = $line->col_band; - $bandCq[$line->col_cqz][$band] = '
col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>C
'; - $cqZ[$line->col_cqz]['count']++; + foreach ($cqdata_sat as $cq) { + // Skip if this band is not in our requested bands list + if (!isset($validBands[$cq->col_band])) { + continue; + } + + $cqZ[$cq->col_cqz]['count']++; // Count each cq zone + + // Check if confirmed based on the confirmation types selected in postdata + $isConfirmed = false; + $confirmationLetters = ''; + if (isset($postdata['qsl']) && $postdata['qsl'] == 1 && $cq->qsl == 1) { + $isConfirmed = true; + $confirmationLetters .= 'Q'; + } + if (isset($postdata['lotw']) && $postdata['lotw'] == 1 && $cq->lotw == 1) { + $isConfirmed = true; + $confirmationLetters .= 'L'; + } + if (isset($postdata['eqsl']) && $postdata['eqsl'] == 1 && $cq->eqsl == 1) { + $isConfirmed = true; + $confirmationLetters .= 'E'; + } + if (isset($postdata['qrz']) && $postdata['qrz'] == 1 && $cq->qrz == 1) { + $isConfirmed = true; + $confirmationLetters .= 'Z'; + } + if (isset($postdata['clublog']) && $postdata['clublog'] == 1 && $cq->clublog == 1) { + $isConfirmed = true; + $confirmationLetters .= 'C'; + } + + if ($isConfirmed) { + $bandCq[$cq->col_cqz][$cq->col_band] = '
col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>' . $confirmationLetters . '
'; + // Track confirmed zones for summary + if (!isset($confirmedZones[$cq->col_band][$cq->col_cqz])) { + $confirmedZones[$cq->col_band][$cq->col_cqz] = true; + $summary['confirmed'][$cq->col_band]++; + } + } else { + $bandCq[$cq->col_cqz][$cq->col_band] = '
col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W
'; + } + + // Track worked zones for summary + if (!isset($workedZones[$cq->col_band][$cq->col_cqz])) { + $workedZones[$cq->col_band][$cq->col_cqz] = true; + $summary['worked'][$cq->col_band]++; } } - // We want to remove the worked zones in the list, since we do not want to display them - if ($postdata['worked'] == NULL) { - // Use optimized query for all bands at once - $cqBand = $this->getCQWorkedAllBands($location_list, $bands, $postdata); - foreach ($cqBand as $line) { - unset($bandCq[$line->col_cqz]); + // Calculate totals across all bands (excluding SAT) + $totalWorkedZones = []; + $totalConfirmedZones = []; + foreach ($workedZones as $band => $zones) { + // Skip SAT for totals + if ($band === 'SAT') { + continue; + } + foreach ($zones as $zone => $true) { + if (!isset($totalWorkedZones[$zone])) { + $totalWorkedZones[$zone] = true; + $summary['worked']['Total']++; + } + } + } + foreach ($confirmedZones as $band => $zones) { + // Skip SAT for totals + if ($band === 'SAT') { + continue; + } + foreach ($zones as $zone => $true) { + if (!isset($totalConfirmedZones[$zone])) { + $totalConfirmedZones[$zone] = true; + $summary['confirmed']['Total']++; + } } } - // We want to remove the confirmed zones in the list, since we do not want to display them - if ($postdata['confirmed'] == NULL) { - // Use optimized query for all bands at once - $cqBand = $this->getCQConfirmedAllBands($location_list, $bands, $postdata); - foreach ($cqBand as $line) { - unset($bandCq[$line->col_cqz]); + // Remove zones based on postdata filters + for ($i = 1; $i <= 40; $i++) { + // Remove not-worked zones if filter is disabled + if ($postdata['notworked'] == NULL && $cqZ[$i]['count'] == 0) { + unset($bandCq[$i]); + continue; } - } - if ($postdata['notworked'] == NULL) { - for ($i = 1; $i <= 40; $i++) { - if ($cqZ[$i]['count'] == 0) { - unset($bandCq[$i]); - }; + // Remove worked-only zones if filter is disabled + if ($postdata['worked'] == NULL && $cqZ[$i]['count'] > 0 && !isset($totalConfirmedZones[$i])) { + unset($bandCq[$i]); + continue; + } + + // Remove confirmed zones if filter is disabled + if ($postdata['confirmed'] == NULL && isset($totalConfirmedZones[$i])) { + unset($bandCq[$i]); + continue; } } if (isset($bandCq)) { - return $bandCq; + // Return both the band data and summary + return ['bands' => $bandCq, 'summary' => $summary]; } else { return 0; } } - /* - * Function returns all worked, but not confirmed states - * $postdata contains data from the form, in this case Lotw or QSL are used - */ - function getCQWorked($location_list, $band, $postdata) { + function getCqZoneData($location_list, $postdata) { $bindings=[]; - $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv - where station_id in (" . $location_list . ") and col_cqz <= 40 and col_cqz <> ''"; - - if ($postdata['mode'] != 'All') { - $sql .= " and (col_mode = ? or col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " and col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " and col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= $this->genfunctions->addBandToQuery($band,$bindings); - - $sql .= " and not exists (select 1 from " . $this->config->item('table_name') . - " where station_id in (" . $location_list . - ") and col_cqz = thcv.col_cqz and col_cqz <> '' "; - - if ($postdata['mode'] != 'All') { - $sql .= " and (col_mode = ? or col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " and col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " and col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= $this->genfunctions->addBandToQuery($band,$bindings); - - $sql .= $this->genfunctions->addQslToQuery($postdata); - - $sql .= ")"; - - $query = $this->db->query($sql,$bindings); - - return $query->result(); - } - - /* - * Function returns all confirmed states on given band and on LoTW or QSL - * $postdata contains data from the form, in this case Lotw or QSL are used - */ - function getCQConfirmed($location_list, $band, $postdata) { - $bindings=[]; - $sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv + $sql = "SELECT thcv.col_cqz, thcv.col_band, + MAX(case when thcv.col_lotw_qsl_rcvd ='Y' then 1 else 0 end) as lotw, + MAX(case when thcv.col_qsl_rcvd = 'Y' then 1 else 0 end) as qsl, + MAX(case when thcv.col_eqsl_qsl_rcvd = 'Y' then 1 else 0 end) as eqsl, + MAX(case when thcv.COL_QRZCOM_QSO_DOWNLOAD_STATUS= 'Y' then 1 else 0 end) as qrz, + MAX(case when thcv.COL_CLUBLOG_QSO_DOWNLOAD_STATUS = 'Y' then 1 else 0 end) as clublog + FROM " . $this->config->item('table_name') . " thcv where station_id in (" . $location_list . ") and col_cqz <= 40 and col_cqz <> ''"; if ($postdata['mode'] != 'All') { @@ -158,108 +224,45 @@ class CQ extends CI_Model{ $bindings[]=$postdata['dateto'] . ' 23:59:59'; } - $sql .= $this->genfunctions->addBandToQuery($band,$bindings); + $sql .= " and col_prop_mode != 'SAT'"; - $sql .= $this->genfunctions->addQslToQuery($postdata); + $sql .= " GROUP BY thcv.col_cqz, thcv.col_band"; $query = $this->db->query($sql,$bindings); return $query->result(); } - - /* - * Function returns all worked (but not confirmed) states for ALL bands in one query - * Returns both col_cqz and col_band to avoid N+1 queries - */ - function getCQWorkedAllBands($location_list, $bands, $postdata) { + function getCqZoneDataSat($location_list, $postdata) { $bindings=[]; - $sql = "SELECT DISTINCT col_cqz, col_band FROM " . $this->config->item('table_name') . " thcv - WHERE station_id IN (" . $location_list . ") - AND col_cqz <= 40 AND col_cqz <> '' - AND col_band IN ('" . implode("','", $bands) . "')"; + $sql = "SELECT thcv.col_cqz, 'SAT' as col_band, + MAX(case when thcv.col_lotw_qsl_rcvd ='Y' then 1 else 0 end) as lotw, + MAX(case when thcv.col_qsl_rcvd = 'Y' then 1 else 0 end) as qsl, + MAX(case when thcv.col_eqsl_qsl_rcvd = 'Y' then 1 else 0 end) as eqsl, + MAX(case when thcv.COL_QRZCOM_QSO_DOWNLOAD_STATUS= 'Y' then 1 else 0 end) as qrz, + MAX(case when thcv.COL_CLUBLOG_QSO_DOWNLOAD_STATUS = 'Y' then 1 else 0 end) as clublog + FROM " . $this->config->item('table_name') . " thcv + where station_id in (" . $location_list . ") and col_cqz <= 40 and col_cqz <> ''"; if ($postdata['mode'] != 'All') { - $sql .= " AND (col_mode = ? OR col_submode = ?)"; + $sql .= " and (col_mode = ? or col_submode = ?)"; $bindings[]=$postdata['mode']; $bindings[]=$postdata['mode']; } if ($postdata['datefrom'] != NULL) { - $sql .= " AND col_time_on >= ?"; + $sql .= " and col_time_on >= ?"; $bindings[]=$postdata['datefrom'] . ' 00:00:00'; } if ($postdata['dateto'] != NULL) { - $sql .= " AND col_time_on <= ?"; + $sql .= " and col_time_on <= ?"; $bindings[]=$postdata['dateto'] . ' 23:59:59'; } - $sql .= " AND col_prop_mode != 'SAT'"; + $sql .= " and col_prop_mode = 'SAT'"; - // Optimized NOT IN subquery instead of NOT EXISTS - /*$sql .= " AND col_cqz NOT IN ( - SELECT col_cqz FROM " . $this->config->item('table_name') . " - WHERE station_id IN (" . $location_list . ") - AND col_cqz <> '' - AND col_band IN ('" . implode("','", $bands) . "') - AND col_prop_mode != 'SAT'"; - - if ($postdata['mode'] != 'All') { - $sql .= " AND (col_mode = ? OR col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " AND col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " AND col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= $this->genfunctions->addQslToQuery($postdata); - - $sql .= ")";*/ - - $query = $this->db->query($sql,$bindings); - - return $query->result(); - } - - /* - * Function returns all confirmed states for ALL bands in one query - * Returns both col_cqz and col_band to avoid N+1 queries - */ - function getCQConfirmedAllBands($location_list, $bands, $postdata) { - $bindings=[]; - $sql = "SELECT DISTINCT col_cqz, col_band FROM " . $this->config->item('table_name') . " thcv - WHERE station_id IN (" . $location_list . ") - AND col_cqz <= 40 AND col_cqz <> '' - AND col_band IN ('" . implode("','", $bands) . "')"; - - if ($postdata['mode'] != 'All') { - $sql .= " AND (col_mode = ? OR col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " AND col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " AND col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= " AND col_prop_mode != 'SAT'"; - - $sql .= $this->genfunctions->addQslToQuery($postdata); + $sql .= " GROUP BY thcv.col_cqz"; $query = $this->db->query($sql,$bindings); @@ -268,34 +271,23 @@ class CQ extends CI_Model{ /* * Function gets worked and confirmed summary on each band on the active stationprofile - * Optimized to use just 2 queries instead of N queries per band + * Now uses data from get_cq_array instead of separate queries - much more efficient! */ function get_cq_summary($bands, $postdata, $location_list) { - $bandslots = $this->bands->get_worked_bands('cq'); + $result = $this->get_cq_array($bands, $postdata, $location_list); - foreach ($bandslots as $band) { + if ($result && isset($result['summary'])) { + return $result['summary']; + } + + // Fallback to empty structure if something went wrong + $cqSummary = []; + foreach ($bands as $band) { $cqSummary['worked'][$band] = '-'; $cqSummary['confirmed'][$band] = '-'; } - - // Get all worked counts in ONE query - $workedAll = $this->getSummaryByBandAllBands($bands, $postdata, $location_list, $bandslots); - foreach ($workedAll as $row) { - $cqSummary['worked'][$row->col_band] = $row->count; - } - - // Get all confirmed counts in ONE query - $confirmedAll = $this->getSummaryByBandConfirmedAllBands($bands, $postdata, $location_list, $bandslots); - foreach ($confirmedAll as $row) { - $cqSummary['confirmed'][$row->col_band] = $row->count; - } - - - $workedTotal = $this->getSummaryByBand($postdata['band'], $postdata, $location_list, $bandslots); - $confirmedTotal = $this->getSummaryByBandConfirmed($postdata['band'], $postdata, $location_list, $bandslots); - - $cqSummary['worked']['Total'] = $workedTotal[0]->count; - $cqSummary['confirmed']['Total'] = $confirmedTotal[0]->count; + $cqSummary['worked']['Total'] = '-'; + $cqSummary['confirmed']['Total'] = '-'; return $cqSummary; } @@ -345,123 +337,4 @@ class CQ extends CI_Model{ return $query->result(); } - function getSummaryByBandConfirmed($band, $postdata, $location_list, $bandslots){ - $bindings=[]; - $sql = "SELECT count(distinct thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; - - $sql .= " where station_id in (" . $location_list . ') and col_cqz <= 40 and col_cqz > 0'; - - if ($band == 'SAT') { - $sql .= " and thcv.col_prop_mode = ?"; - $bindings[]=$band; - } else if ($band == 'All') { - $this->load->model('bands'); - - // $bandslots = $this->bands->get_worked_bands('cq'); - - $bandslots_list = "'".implode("','",$bandslots)."'"; - - $sql .= " and thcv.col_band in (" . $bandslots_list . ")" . - " and thcv.col_prop_mode !='SAT'"; - } else { - $sql .= " and thcv.col_prop_mode !='SAT'"; - $sql .= " and thcv.col_band = ?"; - $bindings[]=$band; - } - - if ($postdata['mode'] != 'All') { - $sql .= " and (col_mode = ? or col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " and col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " and col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= $this->genfunctions->addQslToQuery($postdata); - - $query = $this->db->query($sql,$bindings); - - return $query->result(); - } - - /* - * Gets worked CQ zone counts for ALL bands in one query using GROUP BY - * Returns col_band and count for each band - */ - function getSummaryByBandAllBands($bands, $postdata, $location_list, $bandslots) { - $bindings=[]; - $sql = "SELECT col_band, COUNT(DISTINCT thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; - - $sql .= " WHERE station_id IN (" . $location_list . ') AND col_cqz <= 40 AND col_cqz > 0'; - $sql .= " AND col_band IN ('" . implode("','", $bands) . "')"; - $sql .= " AND col_prop_mode != 'SAT'"; - - if ($postdata['mode'] != 'All') { - $sql .= " AND (col_mode = ? OR col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " AND col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " AND col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= " GROUP BY col_band"; - - $query = $this->db->query($sql,$bindings); - - return $query->result(); - } - - /* - * Gets confirmed CQ zone counts for ALL bands in one query using GROUP BY - * Returns col_band and count for each band - */ - function getSummaryByBandConfirmedAllBands($bands, $postdata, $location_list, $bandslots) { - $bindings=[]; - $sql = "SELECT col_band, COUNT(DISTINCT thcv.col_cqz) as count FROM " . $this->config->item('table_name') . " thcv"; - - $sql .= " WHERE station_id IN (" . $location_list . ') AND col_cqz <= 40 AND col_cqz > 0'; - $sql .= " AND col_band IN ('" . implode("','", $bands) . "')"; - $sql .= " AND col_prop_mode != 'SAT'"; - - if ($postdata['mode'] != 'All') { - $sql .= " AND (col_mode = ? OR col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; - } - - if ($postdata['datefrom'] != NULL) { - $sql .= " AND col_time_on >= ?"; - $bindings[]=$postdata['datefrom'] . ' 00:00:00'; - } - - if ($postdata['dateto'] != NULL) { - $sql .= " AND col_time_on <= ?"; - $bindings[]=$postdata['dateto'] . ' 23:59:59'; - } - - $sql .= $this->genfunctions->addQslToQuery($postdata); - - $sql .= " GROUP BY col_band"; - - $query = $this->db->query($sql,$bindings); - - return $query->result(); - } - } diff --git a/application/views/awards/cq/index.php b/application/views/awards/cq/index.php index e48984808..b002eac0f 100644 --- a/application/views/awards/cq/index.php +++ b/application/views/awards/cq/index.php @@ -113,14 +113,18 @@ input->post('lotw', TRUE) || $this->input->method() !== 'post') echo ' checked="checked"'; ?> > -
+
input->post('eqsl', TRUE)) echo ' checked="checked"'; ?> >
-
+
input->post('qrz', TRUE)) echo ' checked="checked"'; ?> >
+
+ input->post('clublog', TRUE)) echo ' checked="checked"'; ?> > + +
@@ -185,6 +189,13 @@ '.__("(Q)SL-Paper-Card").", "; + echo __("(L)oTW").", "; + echo __("(e)QSL").", "; + echo __('QR(Z)-"confirmation"').", "; + echo __("(C)lublog").", "; + echo __("(W)orked").''; echo "