mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge pull request #3006 from AndreasK79/cq_award_tweaks
Cq award tweaks
This commit is contained in:
@@ -666,37 +666,43 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
$data['posted_band'] = $postdata['band'];
|
||||
|
||||
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;
|
||||
@@ -1600,8 +1606,16 @@ class Awards extends CI_Controller {
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$this->load->model('cq');
|
||||
$this->load->model('bands');
|
||||
|
||||
$bands[] = $this->input->post('band');
|
||||
$data['worked_bands'] = $this->bands->get_worked_bands('cq');
|
||||
|
||||
if ($this->input->post('band') == 'All') {
|
||||
$bands = $data['worked_bands'];
|
||||
}
|
||||
else {
|
||||
$bands[] = $this->input->post('band');
|
||||
}
|
||||
|
||||
$postdata['qsl'] = $this->input->post('qsl') == 0 ? NULL: 1;
|
||||
$postdata['lotw'] = $this->input->post('lotw') == 0 ? NULL: 1;
|
||||
@@ -1613,36 +1627,15 @@ class Awards extends CI_Controller {
|
||||
$postdata['notworked'] = $this->input->post('notworked') == 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'));
|
||||
$postdata['datefrom'] = $this->security->xss_clean($this->input->post('dateFrom'));
|
||||
$postdata['dateto'] = $this->security->xss_clean($this->input->post('dateTo'));
|
||||
|
||||
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);
|
||||
$zones = $this->cq->get_cq_array($bands, $postdata, $location_list, true);
|
||||
} else {
|
||||
$location_list = null;
|
||||
$cq_array = null;
|
||||
}
|
||||
|
||||
$zones = array();
|
||||
|
||||
foreach ($cq_array as $cq => $value) {
|
||||
foreach ($value as $key) {
|
||||
if($key != "") {
|
||||
if (strpos($key, '>W<') !== false) {
|
||||
$zones[] = 'W';
|
||||
break;
|
||||
}
|
||||
if (strpos($key, '>C<') !== false) {
|
||||
$zones[] = 'C';
|
||||
break;
|
||||
}
|
||||
if (strpos($key, '-') !== false) {
|
||||
$zones[] = '-';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$zones = array();
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
@@ -6,7 +6,7 @@ class CQ extends CI_Model{
|
||||
$this->load->library('Genfunctions');
|
||||
}
|
||||
|
||||
function get_cq_array($bands, $postdata, $location_list) {
|
||||
function get_cq_array($bands, $postdata, $location_list, $map = false) {
|
||||
$cqZ = array(); // Used for keeping track of which states that are not worked
|
||||
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
@@ -15,123 +15,224 @@ class CQ extends CI_Model{
|
||||
|
||||
$qsl = $this->genfunctions->gen_qsl_from_postdata($postdata);
|
||||
|
||||
// Initialize all bands to dash
|
||||
foreach ($bands as $band) {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
$bandCq[$i][$band] = '-'; // Sets all to dash to indicate no result
|
||||
}
|
||||
}
|
||||
|
||||
if ($postdata['worked'] != NULL) {
|
||||
$cqBand = $this->getCQWorked($location_list, $band, $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
$bandCq[$line->col_cqz][$band] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W</a></div>';
|
||||
$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] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $cq->col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>' . $confirmationLetters . '</a></div>';
|
||||
// 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] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $cq->col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W</a></div>';
|
||||
}
|
||||
|
||||
// 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]++;
|
||||
}
|
||||
}
|
||||
|
||||
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] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $cq->col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>' . $confirmationLetters . '</a></div>';
|
||||
// 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] = '<div class="bg-danger awardsBgWarning"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $cq->col_cqz) . '","' . $cq->col_band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W</a></div>';
|
||||
}
|
||||
|
||||
// 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]++;
|
||||
}
|
||||
}
|
||||
|
||||
// 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']++;
|
||||
}
|
||||
}
|
||||
if ($postdata['confirmed'] != NULL) {
|
||||
$cqBand = $this->getCQConfirmed($location_list, $band, $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
$bandCq[$line->col_cqz][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>C</a></div>';
|
||||
$cqZ[$line->col_cqz]['count']++;
|
||||
}
|
||||
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 worked zones in the list, since we do not want to display them
|
||||
if ($postdata['worked'] == NULL) {
|
||||
$cqBand = $this->getCQWorked($location_list, $postdata['band'], $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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// We want to remove the confirmed zones in the list, since we do not want to display them
|
||||
if ($postdata['confirmed'] == NULL) {
|
||||
$cqBand = $this->getCQConfirmed($location_list, $postdata['band'], $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
unset($bandCq[$line->col_cqz]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($postdata['notworked'] == NULL) {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
if ($cqZ[$i]['count'] == 0) {
|
||||
unset($bandCq[$i]);
|
||||
};
|
||||
// If this is for the map, return simplified format
|
||||
if ($map) {
|
||||
$mapZones = [];
|
||||
if ($bands[0] == 'SAT') {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
if ($cqZ[$i]['count'] == 0) {
|
||||
$mapZones[$i-1] = '-'; // Not worked
|
||||
} elseif (isset($confirmedZones['SAT'][$i])) {
|
||||
$mapZones[$i-1] = 'C'; // Confirmed
|
||||
} else {
|
||||
$mapZones[$i-1] = 'W'; // Worked but not confirmed
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
if (isset($totalConfirmedZones[$i])) {
|
||||
$mapZones[$i-1] = 'C'; // Confirmed
|
||||
} else if (isset($totalWorkedZones[$i])) {
|
||||
$mapZones[$i-1] = 'W'; // Worked but not confirmed
|
||||
} else {
|
||||
$mapZones[$i-1] = '-'; // Not worked
|
||||
}
|
||||
}
|
||||
}
|
||||
return $mapZones;
|
||||
}
|
||||
|
||||
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') {
|
||||
@@ -150,59 +251,25 @@ 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 gets worked and confirmed summary on each band on the active stationprofile
|
||||
*/
|
||||
function get_cq_summary($bands, $postdata, $location_list) {
|
||||
foreach ($bands as $band) {
|
||||
$worked = $this->getSummaryByBand($band, $postdata, $location_list);
|
||||
$confirmed = $this->getSummaryByBandConfirmed($band, $postdata, $location_list);
|
||||
$cqSummary['worked'][$band] = $worked[0]->count;
|
||||
$cqSummary['confirmed'][$band] = $confirmed[0]->count;
|
||||
}
|
||||
|
||||
$workedTotal = $this->getSummaryByBand($postdata['band'], $postdata, $location_list);
|
||||
$confirmedTotal = $this->getSummaryByBandConfirmed($postdata['band'], $postdata, $location_list);
|
||||
|
||||
$cqSummary['worked']['Total'] = $workedTotal[0]->count;
|
||||
$cqSummary['confirmed']['Total'] = $confirmedTotal[0]->count;
|
||||
|
||||
return $cqSummary;
|
||||
}
|
||||
|
||||
function getSummaryByBand($band, $postdata, $location_list) {
|
||||
function getCqZoneDataSat($location_list, $postdata) {
|
||||
$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;
|
||||
}
|
||||
$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 = ?)";
|
||||
@@ -220,52 +287,9 @@ class CQ extends CI_Model{
|
||||
$bindings[]=$postdata['dateto'] . ' 23:59:59';
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
$sql .= " and col_prop_mode = 'SAT'";
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getSummaryByBandConfirmed($band, $postdata, $location_list){
|
||||
$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);
|
||||
$sql .= " GROUP BY thcv.col_cqz";
|
||||
|
||||
$query = $this->db->query($sql,$bindings);
|
||||
|
||||
|
||||
@@ -113,14 +113,18 @@
|
||||
<input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw', TRUE) || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="lotw"><?= __("LoTW"); ?></label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="eqsl" value="1" id="eqsl" <?php if ($this->input->post('eqsl', TRUE)) echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="eqsl"><?= __("eQSL"); ?></label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="qrz" value="1" id="qrz" <?php if ($this->input->post('qrz', TRUE)) echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="qrz"><?= __("QRZ.com"); ?></label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="clublog" value="1" id="clublog" <?php if ($this->input->post('clublog', TRUE)) echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="clublog"><?= __("Clublog"); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -185,6 +189,13 @@
|
||||
<?php
|
||||
$i = 1;
|
||||
if ($cq_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 "
|
||||
<table style='width:100%' class='table tablecq table-sm table-bordered table-hover table-striped table-condensed text-center'>
|
||||
<thead>
|
||||
@@ -213,24 +224,58 @@
|
||||
<thead>
|
||||
<tr><td></td>";
|
||||
|
||||
foreach($bands as $band) {
|
||||
echo '<td>' . $band . '</td>';
|
||||
}
|
||||
echo "<td>" . __("Total") . "</td></tr>
|
||||
</thead>
|
||||
$addsat='';
|
||||
foreach($bands as $band) {
|
||||
if ($band != 'SAT') {
|
||||
echo '<td>' . $band . '</td>';
|
||||
} else {
|
||||
$addsat='<td>' . $band . '</td>';
|
||||
}
|
||||
}
|
||||
if ($posted_band != 'SAT') {
|
||||
echo '<td><b>' . __("Total (ex SAT)") . '</b></td>';
|
||||
}
|
||||
if (count($bands) > 1) {
|
||||
echo '<td class="spacingcell"></td>';
|
||||
}
|
||||
echo $addsat;
|
||||
echo "</thead>
|
||||
<tbody>
|
||||
|
||||
<tr><td>" . __("Total worked") . "</td>";
|
||||
|
||||
foreach ($cq_summary['worked'] as $dxcc) { // Fills the table with the data
|
||||
echo '<td style="text-align: center">' . $dxcc . '</td>';
|
||||
$sat_value = '';
|
||||
foreach ($cq_summary['worked'] as $cqz => $value) {
|
||||
if ($posted_band == 'SAT' && $cqz == 'Total') {
|
||||
continue;
|
||||
}
|
||||
if ($cqz == 'SAT') {
|
||||
$sat_value = '<td style="text-align: center"' . ($cqz === 'Total' ? " class='fw-bold'" : '') . '>' . $value . '</td>';
|
||||
} else {
|
||||
echo '<td style="text-align: center"' . ($cqz === 'Total' ? " class='fw-bold'" : '') . '>' . $value . '</td>';
|
||||
}
|
||||
}
|
||||
if (count($bands) > 1) {
|
||||
echo '<td class="spacingcell"></td>';
|
||||
}
|
||||
echo $sat_value;
|
||||
|
||||
echo "</tr><tr>
|
||||
<td>" . __("Total confirmed") . "</td>";
|
||||
foreach ($cq_summary['confirmed'] as $dxcc) { // Fills the table with the data
|
||||
echo '<td style="text-align: center">' . $dxcc . '</td>';
|
||||
$sat_value = '';
|
||||
foreach ($cq_summary['confirmed'] as $cqz => $value) {
|
||||
if ($posted_band == 'SAT' && $cqz == 'Total') {
|
||||
continue;
|
||||
}
|
||||
if ($cqz == 'SAT') {
|
||||
$sat_value = '<td style="text-align: center"' . ($cqz === 'Total' ? " class='fw-bold'" : '') . '>' . $value . '</td>';
|
||||
} else {
|
||||
echo '<td style="text-align: center"' . ($cqz === 'Total' ? " class='fw-bold'" : '') . '>' . $value . '</td>';
|
||||
}
|
||||
}
|
||||
if (count($bands) > 1) {
|
||||
echo '<td class="spacingcell"></td>';
|
||||
}
|
||||
echo $sat_value;
|
||||
|
||||
echo '</tr>
|
||||
</table>
|
||||
|
||||
@@ -118,7 +118,8 @@ function load_cq_map2(data) {
|
||||
|
||||
legend.onAdd = function(map) {
|
||||
var div = L.DomUtil.create("div", "legend");
|
||||
div.innerHTML += "<h4>" + lang_general_word_colors + "</h4>";
|
||||
var band = $('#band2').val();
|
||||
div.innerHTML += "<h4>Band: " + band + "</h4>";
|
||||
div.innerHTML += "<i style='background: "+confirmedColor+"'></i><span>" + lang_general_word_confirmed + " (" + confirmed + ")</span><br>";
|
||||
div.innerHTML += "<i style='background: "+workedColor+"'></i><span>" + lang_general_word_worked_not_confirmed + " (" + workednotconfirmed + ")</span><br>";
|
||||
div.innerHTML += "<i style='background: "+unworkedColor+"'></i><span>" + lang_general_word_not_worked + " (" + notworked + ")</span><br>";
|
||||
|
||||
Reference in New Issue
Block a user