[WAC Award] Query speedup

This commit is contained in:
Andreas Kristiansen
2026-03-11 11:22:14 +01:00
parent 2cbfbfdf13
commit ce7f62130d
4 changed files with 394 additions and 324 deletions

View File

@@ -498,7 +498,6 @@ class Awards extends CI_Controller {
public function vucc_band(){ public function vucc_band(){
$this->load->model('vucc'); $this->load->model('vucc');
$data['user_map_custom'] = $this->optionslib->get_map_custom();
$band = str_replace('"', "", $this->security->xss_clean($this->input->get("Band"))); $band = str_replace('"', "", $this->security->xss_clean($this->input->get("Band")));
$type = str_replace('"', "", $this->security->xss_clean($this->input->get("Type"))); $type = str_replace('"', "", $this->security->xss_clean($this->input->get("Type")));
$data['vucc_array'] = $this->vucc->vucc_details($band, $type); $data['vucc_array'] = $this->vucc->vucc_details($band, $type);
@@ -2209,30 +2208,34 @@ class Awards extends CI_Controller {
$data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view $data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view
if($this->input->method() === 'post') { if($this->input->method() === 'post') {
$postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl')); $postdata['qsl'] = ($this->input->post('qsl',true) ?? 0) == 0 ? NULL: 1;
$postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw')); $postdata['lotw'] = ($this->input->post('lotw',true) ?? 0) == 0 ? NULL: 1;
$postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl')); $postdata['eqsl'] = ($this->input->post('eqsl',true) ?? 0) == 0 ? NULL: 1;
$postdata['qrz'] = $this->security->xss_clean($this->input->post('qrz')); $postdata['qrz'] = ($this->input->post('qrz',true) ?? 0) == 0 ? NULL: 1;
$postdata['worked'] = $this->security->xss_clean($this->input->post('worked')); $postdata['clublog'] = ($this->input->post('clublog',true) ?? 0) == 0 ? NULL: 1;
$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')); $postdata['band'] = $this->security->xss_clean($this->input->post('band'));
$postdata['mode'] = $this->security->xss_clean($this->input->post('mode')); $postdata['mode'] = $this->security->xss_clean($this->input->post('mode'));
$postdata['sat'] = $this->security->xss_clean($this->input->post('sats')); $postdata['sat'] = $this->security->xss_clean($this->input->post('sats'));
$postdata['orbit'] = $this->security->xss_clean($this->input->post('orbits')); $postdata['orbit'] = $this->security->xss_clean($this->input->post('orbits'));
$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'));
} }
else { // Setting default values at first load of page else { // Setting default values at first load of page
$postdata['qsl'] = 1; $postdata['qsl'] = 1;
$postdata['lotw'] = 1; $postdata['lotw'] = 1;
$postdata['eqsl'] = 0; $postdata['eqsl'] = null;
$postdata['qrz'] = 0; $postdata['qrz'] = null;
$postdata['worked'] = 1; $postdata['clublog'] = null;
$postdata['confirmed'] = 1;
$postdata['notworked'] = 1;
$postdata['band'] = 'All'; $postdata['band'] = 'All';
$postdata['mode'] = 'All'; $postdata['mode'] = 'All';
$postdata['sat'] = 'All'; $postdata['sat'] = 'All';
$postdata['orbit'] = 'All'; $postdata['orbit'] = 'All';
$postdata['worked'] = 1;
$postdata['confirmed'] = 1;
$postdata['notworked'] = 1;
$postdata['band'] = 'All';
} }
if ($logbooks_locations_array) { if ($logbooks_locations_array) {
@@ -2245,11 +2248,18 @@ class Awards extends CI_Controller {
$data['wac_summary'] = null; $data['wac_summary'] = null;
} }
$data['posted_band'] = $postdata['band'];
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/wac.js',
];
// Render page // Render page
$data['page_title'] = sprintf(__("Awards - %s"), __("Worked All Continents (WAC)")); $data['page_title'] = sprintf(__("Awards - %s"), __("Worked All Continents (WAC)"));
$this->load->view('interface_assets/header', $data); $this->load->view('interface_assets/header', $data);
$this->load->view('awards/wac/index'); $this->load->view('awards/wac/index');
$this->load->view('interface_assets/footer'); $this->load->view('interface_assets/footer', $footerData);
} }
public function wae () { public function wae () {

View File

@@ -2,265 +2,277 @@
class Wac extends CI_Model{ class Wac extends CI_Model{
private $validContinents = ['AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN']; private $validContinents = ['AF', 'AN', 'AS', 'EU', 'NA', 'OC', 'SA'];
function __construct() { function __construct() {
$this->load->library('Genfunctions'); if(!$this->load->is_loaded('Genfunctions')) {
$this->load->library('Genfunctions');
}
}
/*
* Gets all WAC data with confirmation status in efficient query using MAX aggregation
*/
function getWacData($location_list, $postdata) {
$bindings = [];
$sql = "SELECT thcv.col_cont, 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 thcv.col_cont IN ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')
AND thcv.col_cont != ''";
// Mode filter
if ($postdata['mode'] != 'All') {
$sql .= " AND (thcv.col_mode = ? OR thcv.col_submode = ?)";
$bindings[] = $postdata['mode'];
$bindings[] = $postdata['mode'];
}
$sql .= " AND thcv.col_prop_mode != 'SAT'";
$sql .= " GROUP BY thcv.col_cont, thcv.col_band";
$query = $this->db->query($sql, $bindings);
return $query->result();
}
/*
* Gets all WAC satellite data with confirmation status
*/
function getWacDataSat($location_list, $postdata) {
$bindings = [];
$sql = "SELECT thcv.col_cont, '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
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
WHERE station_id IN (" . $location_list . ")
AND thcv.col_cont IN ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')
AND thcv.col_cont != ''";
// Mode filter
if ($postdata['mode'] != 'All') {
$sql .= " AND (thcv.col_mode = ? OR thcv.col_submode = ?)";
$bindings[] = $postdata['mode'];
$bindings[] = $postdata['mode'];
}
// Satellite filter
if ($postdata['sat'] != 'All') {
$sql .= " AND thcv.col_sat_name = ?";
$bindings[] = $postdata['sat'];
}
// Orbit filter
$sql .= $this->addOrbitToQuery($postdata, $bindings);
$sql .= " AND thcv.col_prop_mode = 'SAT'";
$sql .= " GROUP BY thcv.col_cont";
$query = $this->db->query($sql, $bindings);
return $query->result();
} }
function get_wac_array($bands, $postdata, $location_list) { function get_wac_array($bands, $postdata, $location_list) {
$wac = array();
foreach ($this->validContinents as $cont) {
$wac[$cont]['count'] = 0; // Inits each wac's count
}
$qsl = $this->genfunctions->gen_qsl_from_postdata($postdata); $qsl = $this->genfunctions->gen_qsl_from_postdata($postdata);
// Initialize matrix with all continents
foreach ($this->validContinents as $cont) {
foreach ($bands as $band) {
if (($postdata['band'] != 'SAT') && ($band == 'SAT')) {
continue;
}
$wacMatrix[$cont][$band] = '-';
}
}
// Initialize summary counters
foreach ($bands as $band) { foreach ($bands as $band) {
foreach ($this->validContinents as $cont) { if (($postdata['band'] != 'SAT') && ($band == 'SAT')) {
$bandWac[$cont][$band] = '-'; // Sets all to dash to indicate no result continue;
}
$summary['worked'][$band] = 0;
$summary['confirmed'][$band] = 0;
}
$summary['worked']['Total'] = 0;
$summary['confirmed']['Total'] = 0;
// Track unique continent/band combinations
$workedContinents = []; // [band][continent] => true
$confirmedContinents = []; // [band][continent] => true
// Track worked status for each continent
$continentWorkedStatus = []; // [continent] => count
// Create a lookup array for valid bands
$validBands = array_flip($bands);
// Get all WAC data in efficient queries
$wacData = $this->getWacData($location_list, $postdata);
// Process regular band data
foreach ($wacData as $wac) {
// Skip if this band is not in our requested bands list
if (!isset($validBands[$wac->col_band])) {
continue;
} }
if ($postdata['worked'] != NULL) { // Track worked status for this continent
$wacBand = $this->getWACWorked($location_list, $band, $postdata); if (!isset($continentWorkedStatus[$wac->col_cont])) {
foreach ($wacBand as $line) { $continentWorkedStatus[$wac->col_cont] = 0;
$bandWac[$line->col_cont][$band] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cont) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","WAC","")\'>W</a></div>'; }
$wac[$line->col_cont]['count']++; $continentWorkedStatus[$wac->col_cont]++;
// Check if confirmed based on the confirmation types selected in postdata
$isConfirmed = false;
$confirmationLetters = '';
if (isset($postdata['qsl']) && $postdata['qsl'] == 1 && $wac->qsl > 0) {
$isConfirmed = true;
$confirmationLetters .= 'Q';
}
if (isset($postdata['lotw']) && $postdata['lotw'] == 1 && $wac->lotw > 0) {
$isConfirmed = true;
$confirmationLetters .= 'L';
}
if (isset($postdata['eqsl']) && $postdata['eqsl'] == 1 && $wac->eqsl > 0) {
$isConfirmed = true;
$confirmationLetters .= 'E';
}
if (isset($postdata['qrz']) && $postdata['qrz'] == 1 && $wac->qrz > 0) {
$isConfirmed = true;
$confirmationLetters .= 'Z';
}
if (isset($postdata['clublog']) && $postdata['clublog'] == 1 && $wac->clublog > 0) {
$isConfirmed = true;
$confirmationLetters .= 'C';
}
if ($isConfirmed) {
$wacMatrix[$wac->col_cont][$wac->col_band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $wac->col_cont) . '","' . $wac->col_band . '","All", "All","'. $postdata['mode'] . '","WAC","'.$qsl.'","","")\'>'.$confirmationLetters.'</a></div>';
// Track confirmed continents for summary
if (!isset($confirmedContinents[$wac->col_band][$wac->col_cont])) {
$confirmedContinents[$wac->col_band][$wac->col_cont] = true;
$summary['confirmed'][$wac->col_band]++;
} }
} else {
$wacMatrix[$wac->col_cont][$wac->col_band] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $wac->col_cont) . '","' . $wac->col_band . '","All", "All","'. $postdata['mode'] . '","WAC","","","")\'>W</a></div>';
} }
if ($postdata['confirmed'] != NULL) {
$wacBand = $this->getWACConfirmed($location_list, $band, $postdata); // Track worked continents for summary
foreach ($wacBand as $line) { if (!isset($workedContinents[$wac->col_band][$wac->col_cont])) {
$bandWac[$line->col_cont][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cont) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","WAC","'.$qsl.'")\'>C</a></div>'; $workedContinents[$wac->col_band][$wac->col_cont] = true;
$wac[$line->col_cont]['count']++; $summary['worked'][$wac->col_band]++;
}
} }
} }
// We want to remove the worked continents in the list, since we do not want to display them // Process SAT data if needed
if ($postdata['worked'] == NULL) { if ($postdata['band'] == 'SAT') {
$wacBand = $this->getWACWorked($location_list, $postdata['band'], $postdata); if (in_array('SAT', $bands)) {
foreach ($wacBand as $line) { $wacDataSat = $this->getWacDataSat($location_list, $postdata);
unset($bandWac[$line->col_cont]);
}
}
// We want to remove the confirmed continents in the list, since we do not want to display them foreach ($wacDataSat as $wac) {
if ($postdata['confirmed'] == NULL) { // Track worked status for this continent
$wacBand = $this->getWACConfirmed($location_list, $postdata['band'], $postdata); if (!isset($continentWorkedStatus[$wac->col_cont])) {
foreach ($wacBand as $line) { $continentWorkedStatus[$wac->col_cont] = 0;
unset($bandWac[$line->col_cont]);
}
}
if ($postdata['notworked'] == NULL) {
foreach ($this->validContinents as $cont) {
if ($wac[$cont]['count'] == 0) {
if (isset($bandWac)) {
unset($bandWac[$cont]);
} }
}; $continentWorkedStatus[$wac->col_cont]++;
// Check if confirmed based on the confirmation types selected in postdata
$isConfirmed = false;
$confirmationLetters = '';
if (isset($postdata['qsl']) && $postdata['qsl'] == 1 && $wac->qsl > 0) {
$isConfirmed = true;
$confirmationLetters .= 'Q';
}
if (isset($postdata['lotw']) && $postdata['lotw'] == 1 && $wac->lotw > 0) {
$isConfirmed = true;
$confirmationLetters .= 'L';
}
if (isset($postdata['eqsl']) && $postdata['eqsl'] == 1 && $wac->eqsl > 0) {
$isConfirmed = true;
$confirmationLetters .= 'E';
}
if (isset($postdata['qrz']) && $postdata['qrz'] == 1 && $wac->qrz > 0) {
$isConfirmed = true;
$confirmationLetters .= 'Z';
}
if (isset($postdata['clublog']) && $postdata['clublog'] == 1 && $wac->clublog > 0) {
$isConfirmed = true;
$confirmationLetters .= 'C';
}
if ($isConfirmed) {
$wacMatrix[$wac->col_cont]['SAT'] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $wac->col_cont) . '","SAT","All", "All","'. $postdata['mode'] . '","WAC","'.$qsl.'","","")\'>'.$confirmationLetters.'</a></div>';
// Track confirmed continents for summary
if (!isset($confirmedContinents['SAT'][$wac->col_cont])) {
$confirmedContinents['SAT'][$wac->col_cont] = true;
$summary['confirmed']['SAT']++;
}
} else {
if ($postdata['worked'] != NULL) {
$wacMatrix[$wac->col_cont]['SAT'] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $wac->col_cont) . '","SAT","All", "All","'. $postdata['mode'] . '","WAC","","","")\'>W</a></div>';
}
}
// Track worked continents for summary
if (!isset($workedContinents['SAT'][$wac->col_cont])) {
$workedContinents['SAT'][$wac->col_cont] = true;
$summary['worked']['SAT']++;
}
}
} }
} }
if (isset($bandWac)) { // Calculate totals across all bands (excluding SAT)
return $bandWac; $totalWorkedContinents = [];
$totalConfirmedContinents = [];
foreach ($workedContinents as $band => $continents) {
foreach ($continents as $cont => $true) {
if (!isset($totalWorkedContinents[$cont])) {
$totalWorkedContinents[$cont] = true;
if ($band === 'SAT') {
continue;
}
$summary['worked']['Total']++;
}
}
}
foreach ($confirmedContinents as $band => $continents) {
foreach ($continents as $cont => $true) {
if (!isset($totalConfirmedContinents[$cont])) {
$totalConfirmedContinents[$cont] = true;
if ($band === 'SAT') {
continue;
}
$summary['confirmed']['Total']++;
}
}
}
if (isset($wacMatrix)) {
// Return both the matrix data and summary
return ['matrix' => $wacMatrix, 'summary' => $summary];
} else { } else {
return 0; return ['matrix' => [], 'summary' => $summary];
} }
} }
/*
* Function returns all worked, but not confirmed continents
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWACWorked($location_list, $band, $postdata) {
$bindings=[];
$sql = "SELECT distinct col_cont FROM " . $this->config->item('table_name') . " thcv
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
where station_id in (" . $location_list . ") and col_cont in ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
if ($band == 'SAT') {
if ($postdata['sat'] != 'All') {
$sql .= " and col_sat_name = ?";
$bindings[]=$postdata['sat'];
}
}
$sql .= $this->addOrbitToQuery($postdata,$bindings);
$sql .= " and not exists (select 1 from " . $this->config->item('table_name') . " thcv2
LEFT JOIN satellite on thcv2.COL_SAT_NAME = satellite.name
where station_id in (" . $location_list .
") and col_cont = thcv.col_cont and col_cont <> '' ";
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
if ($band == 'SAT') {
if ($postdata['sat'] != 'All') {
$sql .= " and col_sat_name = ?";
$bindings[]=$postdata['sat'];
}
}
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->addOrbitToQuery($postdata,$bindings);
$sql .= $this->genfunctions->addQslToQuery($postdata);
$sql .= ")";
$query = $this->db->query($sql,$bindings);
return $query->result();
}
/*
* Function returns all confirmed continents on given band and on LoTW or QSL
* $postdata contains data from the form, in this case Lotw or QSL are used
*/
function getWACConfirmed($location_list, $band, $postdata) {
$bindings=[];
$sql = "SELECT distinct col_cont FROM " . $this->config->item('table_name') . " thcv
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
where station_id in (" . $location_list . ") and col_cont in ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')";
if ($postdata['mode'] != 'All') {
$sql .= " and (col_mode = ? or col_submode = ?)";
$bindings[]=$postdata['mode'];
$bindings[]=$postdata['mode'];
}
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
if ($band == 'SAT') {
if ($postdata['sat'] != 'All') {
$sql .= " and col_sat_name = ?";
$bindings[]=$postdata['sat'];
}
}
$sql .= $this->genfunctions->addQslToQuery($postdata);
$sql .= $this->addOrbitToQuery($postdata,$bindings);
$query = $this->db->query($sql,$bindings);
return $query->result();
}
/* /*
* Function gets worked and confirmed summary on each band on the active stationprofile * Function gets worked and confirmed summary on each band on the active stationprofile
* This is now integrated into get_wac_array for efficiency
*/ */
function get_wac_summary($bands, $postdata, $location_list) { function get_wac_summary($bands, $postdata, $location_list) {
foreach ($bands as $band) { $result = $this->get_wac_array($bands, $postdata, $location_list);
$worked = $this->getSummaryByBand($band, $postdata, $location_list); return $result['summary'];
$confirmed = $this->getSummaryByBandConfirmed($band, $postdata, $location_list);
$wacSummary['worked'][$band] = $worked[0]->count;
$wacSummary['confirmed'][$band] = $confirmed[0]->count;
}
$workedTotal = $this->getSummaryByBand($postdata['band'], $postdata, $location_list);
$confirmedTotal = $this->getSummaryByBandConfirmed($postdata['band'], $postdata, $location_list);
$wacSummary['worked']['Total'] = $workedTotal[0]->count;
$wacSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
return $wacSummary;
}
function getSummaryByBand($band, $postdata, $location_list) {
$bindings=[];
$sql = "SELECT count(distinct thcv.col_cont) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
$sql .= " where station_id in (" . $location_list . ") and col_cont in ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode = ?";
$bindings[]=$band;
if ($band != 'All' && $postdata['sat'] != 'All') {
$sql .= " and col_sat_name = ?";
$bindings[]=$postdata['sat'];
}
} else if ($band == 'All') {
$this->load->model('bands');
$bandslots = $this->bands->get_worked_bands();
$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'];
}
$sql .= $this->addOrbitToQuery($postdata,$bindings);
$query = $this->db->query($sql,$bindings);
return $query->result();
}
function getSummaryByBandConfirmed($band, $postdata, $location_list){
$bindings=[];
$sql = "SELECT count(distinct thcv.col_cont) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
$sql .= " where station_id in (" . $location_list . ") and col_cont in ('AF', 'EU', 'AS', 'SA', 'NA', 'OC', 'AN')";
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
if ($postdata['sat'] != 'All') {
$sql .= " and col_sat_name = ?";
$bindings[]=$postdata['sat'];
}
} else if ($band == 'All') {
$this->load->model('bands');
$bandslots = $this->bands->get_worked_bands();
$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'];
}
$sql .= $this->genfunctions->addQslToQuery($postdata);
$sql .= $this->addOrbitToQuery($postdata,$bindings);
$query = $this->db->query($sql,$bindings);
return $query->result();
} }
// Adds orbit type to query // Adds orbit type to query

View File

@@ -2,69 +2,53 @@
<!-- Award Info Box --> <!-- Award Info Box -->
<br> <br>
<div id="awardInfoButton"> <div id="awardInfoButton">
<script> <script>
var lang_awards_info_button = "<?= __("Award Info"); ?>"; var lang_awards_info_button = "<?= __("Award Info"); ?>";
var lang_award_info_ln1 = "<?= __("Worked All Continents (WAC)"); ?>"; var lang_award_info_ln1 = "<?= __("Worked All Continents (WAC)"); ?>";
var lang_award_info_ln2 = "<?= __("Sponsored by the International Amateur Radio Union (IARU), the Worked All Continents award is issued for working and confirming all six continents. These are North America, South America, Oceania, Asia, Europe and Africa."); ?>"; var lang_award_info_ln2 = "<?= __("Sponsored by the International Amateur Radio Union (IARU), the Worked All Continents award is issued for working and confirming all six continents. These are North America, South America, Oceania, Asia, Europe and Africa."); ?>";
var lang_award_info_ln3 = ""; var lang_award_info_ln3 = "";
var lang_award_info_ln4 = "<?= sprintf(__("You can find all information about the DXCC Award on the %s."), "<a href='https://www.arrl.org/wac' target='_blank'>" . __("ARRL website") . "</a>"); ?>"; var lang_award_info_ln4 = "<?= sprintf(__("You can find all information about the DXCC Award on the %s."), "<a href='https://www.arrl.org/wac' target='_blank'>" . __("ARRL website") . "</a>"); ?>";
var lang_award_info_ln5 = "<?= __("Fields taken for this Award: Continent (ADIF tag 'CONT'). Must contain a valid continent-abbreviation!"); ?>"; var lang_award_info_ln5 = "<?= __("Fields taken for this Award: Continent (ADIF tag 'CONT'). Must contain a valid continent-abbreviation!"); ?>";
</script> </script>
<h2><?= __("Awards - Worked All Continents (WAC)"); ?></h2> <h2><?= __("Awards - Worked All Continents (WAC)"); ?></h2>
<button type="button" class="btn btn-sm btn-primary me-1" id="displayAwardInfo"><?= __("Award Info"); ?></button> <button type="button" class="btn btn-sm btn-primary me-1" id="displayAwardInfo"><?= __("Award Info"); ?></button>
</div> </div>
<!-- End of Award Info Box --> <!-- End of Award Info Box -->
<form class="form" action="<?php echo site_url('awards/wac'); ?>" method="post" enctype="multipart/form-data"> <form class="form" action="<?php echo site_url('awards/wac'); ?>" method="post" enctype="multipart/form-data">
<fieldset> <fieldset>
<!-- Multiple Checkboxes (inline) -->
<div class="mb-3 row"> <div class="mb-3 row">
<div class="col-md-2" for="checkboxes"><?= __("Worked") . ' / ' . __("Confirmed")?></div> <div class="col-md-2"><?= __("Show QSO with QSL Type"); ?></div>
<div class="col-md-10"> <div class="col-md-10">
<div class="form-check-inline"> <div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="worked" id="worked" value="1" <?php if ($this->input->post('worked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> > <input class="form-check-input" type="checkbox" name="qsl" value="1" id="qsl" <?php if ($this->input->post('qsl') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="worked"><?= __("Show worked"); ?></label> <label class="form-check-label" for="qsl"><?= __("QSL Card"); ?></label>
</div> </div>
<div class="form-check-inline"> <div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="confirmed" id="confirmed" value="1" <?php if ($this->input->post('confirmed') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> > <input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="confirmed"><?= __("Show confirmed"); ?></label> <label class="form-check-label" for="lotw"><?= __("LoTW"); ?></label>
</div> </div>
<div class="form-check-inline"> <div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="notworked" id="notworked" value="1" <?php if ($this->input->post('notworked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> > <input class="form-check-input" type="checkbox" name="eqsl" value="1" id="eqsl" <?php if ($this->input->post('eqsl')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="notworked"><?= __("Show not worked"); ?></label> <label class="form-check-label" for="eqsl"><?= __("eQSL"); ?></label>
</div> </div>
</div> <div class="form-check-inline">
</div> <input class="form-check-input" type="checkbox" name="qrz" value="1" id="qrz" <?php if ($this->input->post('qrz')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="qrz"><?= __("QRZ.com"); ?></label>
<div class="mb-3 row"> </div>
<div class="col-md-2"><?= __("Show QSO with QSL Type"); ?></div> <div class="form-check-inline">
<div class="col-md-10"> <input class="form-check-input" type="checkbox" name="clublog" value="1" id="clublog" <?php if ($this->input->post('clublog')) echo ' checked="checked"'; ?> >
<div class="form-check-inline"> <label class="form-check-label" for="clublog"><?= __("Clublog"); ?></label>
<input class="form-check-input" type="checkbox" name="qsl" value="1" id="qsl" <?php if ($this->input->post('qsl') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> > </div>
<label class="form-check-label" for="qsl"><?= __("QSL Card"); ?></label> </div>
</div> </div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
<label class="form-check-label" for="lotw"><?= __("LoTW"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="eqsl" value="1" id="eqsl" <?php if ($this->input->post('eqsl')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="eqsl"><?= __("eQSL"); ?></label>
</div>
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="qrz" value="1" id="qrz" <?php if ($this->input->post('qrz')) echo ' checked="checked"'; ?> >
<label class="form-check-label" for="qrz"><?= __("QRZ.com"); ?></label>
</div>
</div>
</div>
<div class="mb-3 row"> <div class="mb-3 row">
<label class="col-md-2 control-label" for="band2"><?= __("Band"); ?></label> <label class="col-md-2 control-label" for="band2"><?= __("Band"); ?></label>
<div class="col-md-2"> <div class="col-md-2">
<select id="band2" name="band" class="form-select form-select-sm"> <select id="band2" name="band" class="form-select form-select-sm">
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("Every band"); ?></option> <option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("Every band (w/o SAT)"); ?></option>
<?php foreach($worked_bands as $band) { <?php foreach($worked_bands as $band) {
echo '<option value="' . $band . '"'; echo '<option value="' . $band . '"';
if ($this->input->post('band') == $band) echo ' selected'; if ($this->input->post('band') == $band) echo ' selected';
@@ -91,21 +75,21 @@
<input id="sats" type="hidden" value="All"></input> <input id="sats" type="hidden" value="All"></input>
<?php } ?> <?php } ?>
</div> </div>
<div id="orbitrow" class="mb-3 row" <?php if ($this->input->post('band') != 'SAT' && $this->input->post('band') != 'All') echo "style=\"display: none\""; ?>> <div id="orbitrow" class="mb-3 row" <?php if ($this->input->post('band') != 'SAT' && $this->input->post('band') != 'All') echo "style=\"display: none\""; ?>>
<label class="col-md-2 control-label" id="orbitslabel" for="orbits"><?= __("Orbit"); ?></label> <label class="col-md-2 control-label" id="orbitslabel" for="orbits"><?= __("Orbit"); ?></label>
<div class="col-md-2"> <div class="col-md-2">
<select class="form-select form-select-sm" id="orbits" name="orbits"> <select class="form-select form-select-sm" id="orbits" name="orbits">
<option value="All" <?php if ($this->input->post('orbits') == "All" || $this->input->method() !== 'post') echo ' selected'; ?>><?= __("All")?></option> <option value="All" <?php if ($this->input->post('orbits') == "All" || $this->input->method() !== 'post') echo ' selected'; ?>><?= __("All")?></option>
<?php <?php
foreach($orbits as $orbit){ foreach($orbits as $orbit){
echo '<option value="' . $orbit . '"'; echo '<option value="' . $orbit . '"';
if ($this->input->post('orbits') == $orbit) echo ' selected'; if ($this->input->post('orbits') == $orbit) echo ' selected';
echo '>' . strtoupper($orbit) . '</option>'."\n"; echo '>' . strtoupper($orbit) . '</option>'."\n";
} }
?> ?>
</select> </select>
</div>
</div> </div>
</div>
<div class="mb-3 row"> <div class="mb-3 row">
<label class="col-md-2 control-label" for="mode"><?= __("Mode"); ?></label> <label class="col-md-2 control-label" for="mode"><?= __("Mode"); ?></label>
@@ -132,8 +116,7 @@
<div class="mb-3 row"> <div class="mb-3 row">
<label class="col-md-2 control-label" for="button1id"></label> <label class="col-md-2 control-label" for="button1id"></label>
<div class="col-md-10"> <div class="col-md-10">
<button id="button2id" type="reset" name="button2id" class="btn btn-sm btn-warning"><?= __("Reset"); ?></button> <button id="button1id" type="submit" name="button1id" class="btn btn-sm btn-primary"><?= __("Show"); ?></button>
<button id="button1id" type="submit" name="button1id" class="btn btn-sm btn-primary"><?= __("Show"); ?></button>
</div> </div>
</div> </div>
</fieldset> </fieldset>
@@ -144,6 +127,13 @@
<?php <?php
$i = 1; $i = 1;
if ($wac_array) { if ($wac_array) {
echo __('Legend:');
echo '<pre>'.__("(Q)SL-Paper-Card").", ";
echo __("(L)oTW").", ";
echo __("(e)QSL").", ";
echo __('QR(Z)-"confirmation"').", ";
echo __("(C)lublog").", ";
echo __("(W)orked").'</pre>';
echo " echo "
<table style='width:100%' class='table tablecq table-sm table-bordered table-hover table-striped table-condensed text-center'> <table style='width:100%' class='table tablecq table-sm table-bordered table-hover table-striped table-condensed text-center'>
<thead> <thead>
@@ -151,17 +141,20 @@
<td>#</td> <td>#</td>
<td>" . __("Continent") . "</td>"; <td>" . __("Continent") . "</td>";
foreach($bands as $band) { foreach($bands as $band) {
echo '<td>' . $band . '</td>'; if (($posted_band != 'SAT') && ($band == 'SAT')) {
continue;
}
echo '<td>' . $band . '</td>';
} }
echo '</tr> echo '</tr>
</thead> </thead>
<tbody>'; <tbody>';
foreach ($wac_array as $wac => $value) { // Fills the table with the data foreach ($wac_array['matrix'] as $wac => $value) { // Fills the table with the data
echo '<tr> echo '<tr>
<td>' . $i++ . '</td> <td>' . $i++ . '</td>
<td>'. $wac.'</td>'; <td>'. $wac.'</td>';
foreach ($value as $key) { foreach ($value as $key) {
echo '<td style="text-align: center">' . $key . '</td>'; echo '<td style="text-align: center">' . $key . '</td>';
} }
echo '</tr>'; echo '</tr>';
} }
@@ -173,22 +166,56 @@
<tr><td></td>"; <tr><td></td>";
foreach($bands as $band) { foreach($bands as $band) {
if (($posted_band != 'SAT') && ($band == 'SAT')) {
continue;
}
echo '<td>' . $band . '</td>'; echo '<td>' . $band . '</td>';
} }
echo "<td>" . __("Total") . "</td></tr> if ($posted_band != 'SAT') {
echo "<td>" . __("Total (ex SAT)") . "</td>";
} ?>
</tr>
</thead> </thead>
<tbody> <tbody>
<tr><td>" . __("Total worked") . "</td>"; <?php
echo "<tr><td>" . __("Total worked") . "</td>";
foreach ($wac_summary['worked'] as $wac) { // Fills the table with the data foreach ($wac_summary['worked'] as $wac => $value) { // Fills the table with the data
echo '<td style="text-align: center">' . $wac . '</td>'; if (($posted_band != 'SAT') && ($wac == 'SAT')) {
continue;
}
if (($posted_band == 'SAT') && ($wac == 'Total')) {
continue;
}
echo '<td style="text-align: center">';
if ($wac == 'Total' && $posted_band != 'SAT') {
echo '<b>'.$value.'</b>';
} else {
echo $value;
}
echo '</td>';
} }
echo "</tr><tr> echo "</tr><tr>
<td>" . __("Total confirmed") . "</td>"; <td>" . __("Total confirmed") . "</td>";
foreach ($wac_summary['confirmed'] as $wac) { // Fills the table with the data foreach ($wac_summary['confirmed'] as $wac => $value) { // Fills the table with the data
echo '<td style="text-align: center">' . $wac . '</td>'; if (($posted_band != 'SAT') && ($wac == 'SAT')) {
continue;
}
if (($posted_band == 'SAT') && ($wac == 'Total')) {
continue;
}
echo '<td style="text-align: center">';
if ($wac == 'Total' && $posted_band != 'SAT') {
echo '<b>'.$value.'</b>';
} else {
echo $value;
}
echo '</td>';
} }
echo '</tr> echo '</tr>
@@ -197,7 +224,7 @@
} }
else { else {
echo '<div class="alert alert-danger" role="alert">' . __("Nothing found!") . '</div>'; echo '<div class="alert alert-danger" role="alert">' . __("No QSOS found matching the criteria for this award!") . '</div>';
} }
?> ?>

21
assets/js/sections/wac.js Normal file
View File

@@ -0,0 +1,21 @@
$('#band2').change(function(){
var band = $("#band2 option:selected").text();
if (band != "SAT") {
$("#sats").val('All');
$("#orbits").val('All');
$("#satrow").hide();
$("#orbitrow").hide();
} else {
$("#satrow").show();
$("#orbitrow").show();
}
});
$('#band2').change(); // trigger the change on fresh-load to hide/show SAT-Params
$('#sats').change(function(){
var sat = $("#sats option:selected").text();
$("#band2").val('SAT');
if (sat != "All") {
}
});