mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
Adjustments, award works, map left
This commit is contained in:
@@ -110,6 +110,9 @@ class Awards extends CI_Controller {
|
||||
$this->load->model('dxcc');
|
||||
$this->load->model('modes');
|
||||
$this->load->model('bands');
|
||||
$this->load->model('logbooks_model');
|
||||
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$data['orbits'] = $this->bands->get_worked_orbits();
|
||||
$data['sats_available'] = $this->bands->get_worked_sats();
|
||||
@@ -183,14 +186,22 @@ class Awards extends CI_Controller {
|
||||
$postdata['dateTo'] = null;
|
||||
}
|
||||
|
||||
$dxcclist = $this->dxcc->fetchdxcc($postdata);
|
||||
if ($dxcclist && $dxcclist[0]->adif == "0") {
|
||||
unset($dxcclist[0]);
|
||||
}
|
||||
|
||||
$dxcc_result = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata);
|
||||
$data['dxcc_array'] = ($dxcc_result && isset($dxcc_result['matrix'])) ? $dxcc_result['matrix'] : null;
|
||||
$data['dxcc_summary'] = ($dxcc_result && isset($dxcc_result['summary'])) ? $dxcc_result['summary'] : null;
|
||||
if ($logbooks_locations_array) {
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
$dxcclist = $this->dxcc->fetchdxcc($postdata, $location_list);
|
||||
if ($dxcclist && $dxcclist[0]->adif == "0") {
|
||||
unset($dxcclist[0]);
|
||||
}
|
||||
$dxcc_result = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata, $location_list);
|
||||
// Extract bands data and summary from the result
|
||||
$data['dxcc_array'] = ($dxcc_result && isset($dxcc_result['matrix'])) ? $dxcc_result['matrix'] : null;
|
||||
$data['dxcc_summary'] = ($dxcc_result && isset($dxcc_result['summary'])) ? $dxcc_result['summary'] : null;
|
||||
} else {
|
||||
$location_list = null;
|
||||
$data['dxcc_array'] = null;
|
||||
$data['dxcc_summary'] = null;
|
||||
}
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = sprintf(__("Awards - %s"), __("DXCC"));
|
||||
@@ -1705,59 +1716,70 @@ class Awards extends CI_Controller {
|
||||
This displays the DXCC map
|
||||
*/
|
||||
public function dxcc_map() {
|
||||
$this->load->model('dxcc');
|
||||
$this->load->model('bands');
|
||||
$this->load->model('dxcc');
|
||||
$this->load->model('bands');
|
||||
|
||||
$bands[] = $this->security->xss_clean($this->input->post('band'));
|
||||
$bands[] = $this->security->xss_clean($this->input->post('band'));
|
||||
|
||||
$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['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['includedeleted'] = ($this->input->post('includedeleted',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Africa'] = ($this->input->post('Africa',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Asia'] = ($this->input->post('Asia',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Europe'] = ($this->input->post('Europe',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['NorthAmerica'] = ($this->input->post('NorthAmerica',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['SouthAmerica'] = ($this->input->post('SouthAmerica',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Oceania'] = ($this->input->post('Oceania',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Antarctica'] = ($this->input->post('Antarctica',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['sat'] = $this->security->xss_clean($this->input->post('sat'));
|
||||
$postdata['orbit'] = $this->security->xss_clean($this->input->post('orbit'));
|
||||
$postdata['includedeleted'] = ($this->input->post('includedeleted',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Africa'] = ($this->input->post('Africa',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Asia'] = ($this->input->post('Asia',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Europe'] = ($this->input->post('Europe',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['NorthAmerica'] = ($this->input->post('NorthAmerica',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['SouthAmerica'] = ($this->input->post('SouthAmerica',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Oceania'] = ($this->input->post('Oceania',true) ?? 0) == 0 ? NULL: 1;
|
||||
$postdata['Antarctica'] = ($this->input->post('Antarctica',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['sat'] = $this->security->xss_clean($this->input->post('sat'));
|
||||
$postdata['orbit'] = $this->security->xss_clean($this->input->post('orbit'));
|
||||
|
||||
$postdata['dateFrom'] = $this->security->xss_clean($this->input->post('dateFrom'));
|
||||
$postdata['dateTo'] = $this->security->xss_clean($this->input->post('dateTo'));
|
||||
|
||||
$dxcclist = $this->dxcc->fetchdxcc($postdata);
|
||||
if ($dxcclist[0]->adif == "0") {
|
||||
unset($dxcclist[0]);
|
||||
}
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$dxcc_array = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata, true);
|
||||
$dxcclist = $this->dxcc->fetchdxcc($postdata, $logbooks_locations_array);
|
||||
|
||||
$i = 0;
|
||||
if ($dxcclist[0]->adif == "0") {
|
||||
unset($dxcclist[0]);
|
||||
}
|
||||
|
||||
foreach ($dxcclist as $dxcc) {
|
||||
$newdxcc[$i]['adif'] = $dxcc->adif;
|
||||
$newdxcc[$i]['prefix'] = $dxcc->prefix;
|
||||
$newdxcc[$i]['name'] = ucwords(strtolower($dxcc->name), "- (/");
|
||||
if ($dxcc->Enddate!=null) {
|
||||
$newdxcc[$i]['name'] .= ' (deleted)';
|
||||
}
|
||||
$newdxcc[$i]['lat'] = $dxcc->lat;
|
||||
$newdxcc[$i]['long'] = $dxcc->long;
|
||||
$newdxcc[$i++]['status'] = isset($dxcc_array[$dxcc->adif]) ? $this->returnStatus($dxcc_array[$dxcc->adif]) : 'x';
|
||||
}
|
||||
if ($logbooks_locations_array) {
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
$dxcc_array = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata, $location_list, true);
|
||||
} else {
|
||||
$location_list = null;
|
||||
$dxcc_array = array();
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($newdxcc);
|
||||
$i = 0;
|
||||
|
||||
foreach ($dxcclist as $dxcc) {
|
||||
$newdxcc[$i]['adif'] = $dxcc->adif;
|
||||
$newdxcc[$i]['prefix'] = $dxcc->prefix;
|
||||
$newdxcc[$i]['name'] = ucwords(strtolower($dxcc->name), "- (/");
|
||||
if ($dxcc->Enddate!=null) {
|
||||
$newdxcc[$i]['name'] .= ' (deleted)';
|
||||
}
|
||||
$newdxcc[$i]['lat'] = $dxcc->lat;
|
||||
$newdxcc[$i]['long'] = $dxcc->long;
|
||||
$newdxcc[$i++]['status'] = isset($dxcc_array[$dxcc->adif]) ? $dxcc_array[$dxcc->adif] : 'x';
|
||||
}
|
||||
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($newdxcc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -31,32 +31,15 @@ class DXCC extends CI_Model {
|
||||
return $this->db->get('dxcc_entities');
|
||||
}
|
||||
|
||||
function get_dxcc_array($dxccArray, $bands, $postdata, $map = false) {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
function get_dxcc_array($dxccArray, $bands, $postdata, $location_list, $map = false) {
|
||||
$qsl = $this->genfunctions->gen_qsl_from_postdata($postdata);
|
||||
|
||||
// Initialize matrix with all DXCC entities
|
||||
foreach ($dxccArray as $dxcc) {
|
||||
// Handle both object and array formats
|
||||
if (is_array($dxcc)) {
|
||||
$adif = $dxcc['adif'] ?? '0';
|
||||
$name = $dxcc['name'] ?? '';
|
||||
$prefix = $dxcc['prefix'] ?? '';
|
||||
$enddate = $dxcc['end'] ?? null;
|
||||
} else {
|
||||
$adif = $dxcc->adif ?? '0';
|
||||
$name = $dxcc->name ?? '';
|
||||
$prefix = $dxcc->prefix ?? '';
|
||||
$enddate = $dxcc->end ?? null;
|
||||
}
|
||||
$adif = $dxcc->adif ?? '0';
|
||||
$name = $dxcc->name ?? '';
|
||||
$prefix = $dxcc->prefix ?? '';
|
||||
$enddate = $dxcc->end ?? null;
|
||||
|
||||
if ($adif == '0') {
|
||||
$dxccMatrix[$adif]['name'] = $name;
|
||||
@@ -103,11 +86,14 @@ class DXCC extends CI_Model {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure string key for consistency
|
||||
$dxccKey = (string)$dxcc->dxcc;
|
||||
|
||||
// Track worked status for this DXCC
|
||||
if (!isset($dxccWorkedStatus[$dxcc->dxcc])) {
|
||||
$dxccWorkedStatus[$dxcc->dxcc] = 0;
|
||||
if (!isset($dxccWorkedStatus[$dxccKey])) {
|
||||
$dxccWorkedStatus[$dxccKey] = 0;
|
||||
}
|
||||
$dxccWorkedStatus[$dxcc->dxcc]++;
|
||||
$dxccWorkedStatus[$dxccKey]++;
|
||||
|
||||
// Check if confirmed based on the confirmation types selected in postdata
|
||||
$isConfirmed = false;
|
||||
@@ -134,19 +120,19 @@ class DXCC extends CI_Model {
|
||||
}
|
||||
|
||||
if ($isConfirmed) {
|
||||
$dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $dxcc->dxcc . '","' . $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>' . $confirmationLetters . '</a></div>';
|
||||
$dxccMatrix[$dxccKey][$dxcc->col_band] = '<div class="bg-success awardsBgSuccess" additional_successinfo=">C<"><a href=\'javascript:displayContacts("'.$dxcc->dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>'.$confirmationLetters.'</a></div>';
|
||||
// Track confirmed DXCCs for summary
|
||||
if (!isset($confirmedDxccs[$dxcc->col_band][$dxcc->dxcc])) {
|
||||
$confirmedDxccs[$dxcc->col_band][$dxcc->dxcc] = true;
|
||||
if (!isset($confirmedDxccs[$dxcc->col_band][$dxccKey])) {
|
||||
$confirmedDxccs[$dxcc->col_band][$dxccKey] = true;
|
||||
$summary['confirmed'][$dxcc->col_band]++;
|
||||
}
|
||||
} else {
|
||||
$dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . $dxcc->dxcc . '","' . $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC","","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>W</a></div>';
|
||||
$dxccMatrix[$dxccKey][$dxcc->col_band] = '<div class="bg-danger awardsBgWarning" ><a href=\'javascript:displayContacts("'.$dxcc->dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W</a></div>';
|
||||
}
|
||||
|
||||
// Track worked DXCCs for summary
|
||||
if (!isset($workedDxccs[$dxcc->col_band][$dxcc->dxcc])) {
|
||||
$workedDxccs[$dxcc->col_band][$dxcc->dxcc] = true;
|
||||
if (!isset($workedDxccs[$dxcc->col_band][$dxccKey])) {
|
||||
$workedDxccs[$dxcc->col_band][$dxccKey] = true;
|
||||
$summary['worked'][$dxcc->col_band]++;
|
||||
}
|
||||
}
|
||||
@@ -157,11 +143,14 @@ class DXCC extends CI_Model {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure string key for consistency
|
||||
$dxccKey = (string)$dxcc->dxcc;
|
||||
|
||||
// Track worked status for this DXCC
|
||||
if (!isset($dxccWorkedStatus[$dxcc->dxcc])) {
|
||||
$dxccWorkedStatus[$dxcc->dxcc] = 0;
|
||||
if (!isset($dxccWorkedStatus[$dxccKey])) {
|
||||
$dxccWorkedStatus[$dxccKey] = 0;
|
||||
}
|
||||
$dxccWorkedStatus[$dxcc->dxcc]++;
|
||||
$dxccWorkedStatus[$dxccKey]++;
|
||||
|
||||
// Check if confirmed based on the confirmation types selected in postdata
|
||||
$isConfirmed = false;
|
||||
@@ -188,19 +177,19 @@ class DXCC extends CI_Model {
|
||||
}
|
||||
|
||||
if ($isConfirmed) {
|
||||
$dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $dxcc->dxcc . '","' . $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>' . $confirmationLetters . '</a></div>';
|
||||
$dxccMatrix[$dxccKey][$dxcc->col_band] = '<div class="bg-success awardsBgSuccess" additional_successinfo=">C<"><a href=\'javascript:displayContacts("'.$dxcc->dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>'.$confirmationLetters.'</a></div>';
|
||||
// Track confirmed DXCCs for summary
|
||||
if (!isset($confirmedDxccs[$dxcc->col_band][$dxcc->dxcc])) {
|
||||
$confirmedDxccs[$dxcc->col_band][$dxcc->dxcc] = true;
|
||||
if (!isset($confirmedDxccs[$dxcc->col_band][$dxccKey])) {
|
||||
$confirmedDxccs[$dxcc->col_band][$dxccKey] = true;
|
||||
$summary['confirmed'][$dxcc->col_band]++;
|
||||
}
|
||||
} else {
|
||||
$dxccMatrix[$dxcc->dxcc][$dxcc->col_band] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . $dxcc->dxcc . '","' . $dxcc->col_band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC","","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>W</a></div>';
|
||||
}
|
||||
} else {
|
||||
$dxccMatrix[$dxccKey][$dxcc->col_band] = '<div class="bg-danger awardsBgWarning" ><a href=\'javascript:displayContacts("'.$dxcc->dxcc.'","'. $dxcc->col_band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W</a></div>';
|
||||
}
|
||||
|
||||
// Track worked DXCCs for summary
|
||||
if (!isset($workedDxccs[$dxcc->col_band][$dxcc->dxcc])) {
|
||||
$workedDxccs[$dxcc->col_band][$dxcc->dxcc] = true;
|
||||
if (!isset($workedDxccs[$dxcc->col_band][$dxccKey])) {
|
||||
$workedDxccs[$dxcc->col_band][$dxccKey] = true;
|
||||
$summary['worked'][$dxcc->col_band]++;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +247,7 @@ class DXCC extends CI_Model {
|
||||
if ($map) {
|
||||
$mapDxccs = [];
|
||||
foreach ($dxccMatrix as $dxcc => $data) {
|
||||
if (!isset($dxccWorkedStatus[$dxcc])) {
|
||||
if (!isset($totalWorkedDxccs[$dxcc])) {
|
||||
$mapDxccs[$dxcc] = '-'; // Not worked
|
||||
} elseif (isset($totalConfirmedDxccs[$dxcc])) {
|
||||
$mapDxccs[$dxcc] = 'C'; // Confirmed
|
||||
@@ -277,20 +266,8 @@ class DXCC extends CI_Model {
|
||||
}
|
||||
}
|
||||
|
||||
private function cf_type($postdata,$qsl,$lotw,$eqsl,$qrz,$clublog) {
|
||||
$string='';
|
||||
if ((($qsl ?? 0)>0) && (($postdata['qsl'] ?? '') != '')) { $string.='Q'; }
|
||||
if ((($lotw ?? 0)>0) && (($postdata['lotw'] ?? '') != '')) { $string.='L'; }
|
||||
if ((($eqsl ?? 0)>0) && (($postdata['eqsl'] ?? '') != '')) { $string.='E'; }
|
||||
if ((($qrz ?? 0)>0) && (($postdata['qrz'] ?? '') != '')) { $string.='Z'; }
|
||||
if ((($clublog ?? 0)>0) && (($postdata['clublog'] ?? '') != '')) { $string.='C'; }
|
||||
if ($string == '') { $string='C'; }
|
||||
return $string;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets all DXCC data with confirmation status in efficient query using MAX aggregation
|
||||
* Returns both regular bands and satellite data
|
||||
*/
|
||||
function getDxccData($location_list, $postdata) {
|
||||
$bindings = [];
|
||||
@@ -392,118 +369,8 @@ class DXCC extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getDxccBandConfirmed($location_list, $postdata) {
|
||||
function fetchDxcc($postdata, $location_list) {
|
||||
$bindings=[];
|
||||
$sql = "select adif as dxcc, name, lotw, qsl, eqsl, qrz, clublog from dxcc_entities
|
||||
join (
|
||||
select col_dxcc,
|
||||
sum(case when thcv.col_lotw_qsl_rcvd ='Y' then 1 else 0 end) as lotw,
|
||||
sum(case when thcv.col_qsl_rcvd = 'Y' then 1 else 0 end) as qsl,
|
||||
sum(case when thcv.col_eqsl_qsl_rcvd = 'Y' then 1 else 0 end) as eqsl,
|
||||
sum(case when thcv.COL_QRZCOM_QSO_DOWNLOAD_STATUS= 'Y' then 1 else 0 end) as qrz,
|
||||
sum(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 col_dxcc > 0";
|
||||
|
||||
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);
|
||||
|
||||
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_dxcc
|
||||
) x on dxcc_entities.adif = x.col_dxcc";
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and dxcc_entities.end is null";
|
||||
}
|
||||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getDxccBandWorked($location_list, $band, $postdata) {
|
||||
$bindings=[];
|
||||
$sql = "select adif as dxcc, name from dxcc_entities
|
||||
join (
|
||||
select col_dxcc 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_dxcc > 0";
|
||||
$sql .= $this->genfunctions->addBandToQuery($band,$bindings);
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='SAT'";
|
||||
if ($postdata['sat'] != 'All') {
|
||||
$sql .= " and col_sat_name = ?";
|
||||
$bindings[]=$postdata['sat'];
|
||||
}
|
||||
} else {
|
||||
$sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)";
|
||||
}
|
||||
|
||||
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->addOrbitToQuery($postdata,$bindings);
|
||||
|
||||
$sql .= " group by col_dxcc
|
||||
) x on dxcc_entities.adif = x.col_dxcc";;
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and dxcc_entities.end is null";
|
||||
}
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function fetchDxcc($postdata) {
|
||||
$bindings=[];
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$sql = "select adif, prefix, name, date(end) Enddate, date(start) Startdate, lat, `long`
|
||||
from dxcc_entities";
|
||||
@@ -565,146 +432,6 @@ class DXCC extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getDxccWorked($location_list, $postdata) {
|
||||
$bindings=[];
|
||||
$sql = "SELECT adif as dxcc FROM dxcc_entities
|
||||
join (
|
||||
select col_dxcc
|
||||
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_dxcc > 0";
|
||||
$sql .= $this->genfunctions->addBandToQuery($postdata['band'],$bindings);
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode = 'SAT'";
|
||||
if ($postdata['sat'] != 'All') {
|
||||
$sql .= " and col_sat_name = ?";
|
||||
$bindings[]=$postdata['sat'];
|
||||
}
|
||||
$sql .= $this->addOrbitToQuery($postdata,$bindings);
|
||||
} else {
|
||||
$sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)";
|
||||
}
|
||||
|
||||
|
||||
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 not exists (select 1 from ".$this->config->item('table_name')." where station_id in (". $location_list .") and col_dxcc = thcv.col_dxcc and col_dxcc > 0";
|
||||
$sql .= $this->genfunctions->addBandToQuery($postdata['band'],$bindings);
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode = 'SAT'";
|
||||
if ($postdata['sat'] != 'All') {
|
||||
$sql .= " and col_sat_name = ?";
|
||||
$bindings[]=$postdata['sat'];
|
||||
}
|
||||
$sql .= $this->addOrbitToQuery($postdata,$bindings);
|
||||
} else {
|
||||
$sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)";
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = ? or col_submode = ?)";
|
||||
$bindings[]=$postdata['mode'];
|
||||
$bindings[]=$postdata['mode'];
|
||||
}
|
||||
|
||||
$sql .= $this->genfunctions->addQslToQuery($postdata);
|
||||
$sql .= ')';
|
||||
$sql .= " group by col_dxcc
|
||||
) ll on dxcc_entities.adif = ll.col_dxcc
|
||||
where 1=1";
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and dxcc_entities.end is null";
|
||||
}
|
||||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getDxccConfirmed($location_list, $postdata) {
|
||||
$bindings=[];
|
||||
$sql = "SELECT adif as dxcc, lotw, qsl, eqsl, qrz, clublog FROM dxcc_entities
|
||||
join (
|
||||
select col_dxcc, sum(case when thcv.col_lotw_qsl_rcvd ='Y' then 1 else 0 end) as lotw,sum(case when thcv.col_qsl_rcvd = 'Y' then 1 else 0 end) as qsl,sum(case when thcv.col_eqsl_qsl_rcvd = 'Y' then 1 else 0 end) as eqsl,sum(case when thcv.COL_QRZCOM_QSO_DOWNLOAD_STATUS= 'Y' then 1 else 0 end) as qrz,sum(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 col_dxcc > 0";
|
||||
|
||||
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($postdata['band'],$bindings);
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode = 'SAT'";
|
||||
if ($postdata['sat'] != 'All') {
|
||||
$sql .= " and col_sat_name = ?";
|
||||
$bindings[]=$postdata['sat'];
|
||||
}
|
||||
} else {
|
||||
$sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)";
|
||||
}
|
||||
|
||||
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 .= " group by col_dxcc
|
||||
) ll on dxcc_entities.adif = ll.col_dxcc
|
||||
where 1=1";
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and dxcc_entities.end is null";
|
||||
}
|
||||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
// Made function instead of repeating this several times
|
||||
function addContinentsToQuery($postdata) {
|
||||
$sql = '';
|
||||
@@ -738,100 +465,6 @@ class DXCC extends CI_Model {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function gets worked and confirmed summary on each band on the active stationprofile
|
||||
* Now uses data from get_dxcc_array instead of separate queries - much more efficient!
|
||||
*/
|
||||
function get_dxcc_summary($bands, $postdata) {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
// Get all DXCC entities
|
||||
$this->load->model('dxcc');
|
||||
$dxccEntities = $this->dxcc->list_current();
|
||||
|
||||
$result = $this->get_dxcc_array($dxccEntities, $bands, $postdata);
|
||||
|
||||
if ($result && isset($result['summary'])) {
|
||||
return $result['summary'];
|
||||
}
|
||||
|
||||
// Fallback to empty structure if something went wrong
|
||||
$dxccSummary = [];
|
||||
foreach ($bands as $band) {
|
||||
$dxccSummary['worked'][$band] = '-';
|
||||
$dxccSummary['confirmed'][$band] = '-';
|
||||
}
|
||||
$dxccSummary['worked']['Total'] = '-';
|
||||
$dxccSummary['confirmed']['Total'] = '-';
|
||||
|
||||
return $dxccSummary;
|
||||
}
|
||||
|
||||
function getSummaryByBand($band, $postdata, $location_list) {
|
||||
$bindings=[];
|
||||
$sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv";
|
||||
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
|
||||
$sql .= " join dxcc_entities d on thcv.col_dxcc = d.adif";
|
||||
|
||||
$sql .= " where station_id in (" . $location_list . ") and col_dxcc > 0";
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and thcv.col_prop_mode ='" . $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('dxcc');
|
||||
|
||||
$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['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';
|
||||
}
|
||||
|
||||
if ($postdata['mode'] != 'All') {
|
||||
$sql .= " and (col_mode = ? or col_submode = ?)";
|
||||
$bindings[]=$postdata['mode'];
|
||||
$bindings[]=$postdata['mode'];
|
||||
}
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and d.end is null";
|
||||
}
|
||||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
$sql .= $this->addOrbitToQuery($postdata,$bindings);
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
// Adds orbit type to query
|
||||
function addOrbitToQuery($postdata,&$binding) {
|
||||
$sql = '';
|
||||
@@ -843,68 +476,6 @@ class DXCC extends CI_Model {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function getSummaryByBandConfirmed($band, $postdata, $location_list) {
|
||||
$bindings=[];
|
||||
$sql = "SELECT count(distinct thcv.col_dxcc) as count, sum(case when thcv.col_lotw_qsl_rcvd ='Y' then 1 else 0 end) as lotw,sum(case when thcv.col_qsl_rcvd = 'Y' then 1 else 0 end) as qsl,sum(case when thcv.col_eqsl_qsl_rcvd = 'Y' then 1 else 0 end) as eqsl,sum(case when thcv.COL_QRZCOM_QSO_DOWNLOAD_STATUS= 'Y' then 1 else 0 end) as qrz,sum(case when thcv.COL_CLUBLOG_QSO_DOWNLOAD_STATUS = 'Y' then 1 else 0 end) as clublog FROM " . $this->config->item('table_name') . " thcv";
|
||||
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
|
||||
$sql .= " join dxcc_entities d on thcv.col_dxcc = d.adif";
|
||||
|
||||
$sql .= " where station_id in (" . $location_list . ") and col_dxcc > 0";
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and thcv.col_prop_mode = ?";
|
||||
$bindings[]=$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('dxcc');
|
||||
|
||||
$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['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';
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and d.end is null";
|
||||
}
|
||||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions below are all used in the calltester controller
|
||||
*/
|
||||
@@ -1226,10 +797,8 @@ class DXCC extends CI_Model {
|
||||
|
||||
// query the table, removing a character from the right until a match
|
||||
for ($i = $len; $i > 0; $i--) {
|
||||
//printf("searching for %s\n", substr($call, 0, $i));
|
||||
if (array_key_exists(substr($call, 0, $i), $dxcc_array)) {
|
||||
$row = $dxcc_array[substr($call, 0, $i)];
|
||||
// $row = $dxcc_result->row_array();
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
<label class="col-md-2 control-label" for="band2"><?= __("Band"); ?></label>
|
||||
<div class="col-md-3">
|
||||
<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 (w/o SAT)"); ?></option>
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("Every band"); ?></option>
|
||||
<?php foreach($worked_bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
@@ -309,7 +309,9 @@
|
||||
$addsat='<td>' . $band . '</td>';
|
||||
}
|
||||
}
|
||||
echo '<td><b>' . __("Total") . '</b></td>';
|
||||
if ($posted_band != 'SAT') {
|
||||
echo '<td><b>' . __("Total (ex SAT)") . '</b></td>';
|
||||
}
|
||||
if (count($bands) > 1) {
|
||||
echo '<td class="spacingcell"></td>';
|
||||
}
|
||||
@@ -322,6 +324,9 @@
|
||||
<tr><td>' . __("Total worked") . '</td>';
|
||||
$addsat='';
|
||||
foreach ($dxcc_summary['worked'] as $band => $dxcc) { // Fills the table with the data
|
||||
if ($posted_band == 'SAT' && $band == 'Total') {
|
||||
continue;
|
||||
}
|
||||
if ($band != 'SAT') {
|
||||
echo '<td style="text-align: center">';
|
||||
if ($band == 'Total') {
|
||||
@@ -347,6 +352,9 @@
|
||||
<td>' . __("Total confirmed") . '</td>';
|
||||
$addsat='';
|
||||
foreach ($dxcc_summary['confirmed'] as $band => $dxcc) { // Fills the table with the data
|
||||
if ($posted_band == 'SAT' && $band == 'Total') {
|
||||
continue;
|
||||
}
|
||||
if ($band != 'SAT') {
|
||||
echo '<td style="text-align: center">';
|
||||
if ($band == 'Total') {
|
||||
|
||||
Reference in New Issue
Block a user