Show worked / confirmed grids of active station logbook in hams.at list

This commit is contained in:
phl0
2025-09-25 15:57:36 +02:00
parent ee5f4d77a6
commit c5c531b11a
3 changed files with 41 additions and 7 deletions

View File

@@ -126,11 +126,17 @@ class Hamsat extends CI_Controller {
}
$decoded_json->data[$i]->mode_class = $modeclass;
for($j = 0; $j < count($decoded_json->data[$i]->grids); $j++) {
$worked = $this->logbook_model->check_if_grid_worked_in_logbook(substr($decoded_json->data[$i]->grids[$j], 0, 4), null, "SAT");
if ($worked->num_rows() != 0) {
$worked = $this->logbook_model->check_sat_grid(substr($decoded_json->data[$i]->grids[$j], 0, 4), true);
switch ($worked) {
case 2:
$decoded_json->data[$i]->grids_wkd[$j] = 2;
break;
case 1:
$decoded_json->data[$i]->grids_wkd[$j] = 1;
} else {
break;
default:
$decoded_json->data[$i]->grids_wkd[$j] = 0;
break;
}
}

View File

@@ -2685,6 +2685,28 @@ class Logbook_model extends CI_Model {
return $query->num_rows();
}
function check_sat_grid($grid) {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$sql = "SELECT COALESCE(NULLIF(COL_LOTW_QSL_RCVD, ''), 'N') AS lotw,
COALESCE(NULLIF(COL_QSL_RCVD, ''), 'N') as qsl, COUNT(COL_PRIMARY_KEY) AS count
FROM ".$this->config->item('table_name')."
WHERE COL_PROP_MODE = 'SAT'
AND ( SUBSTRING(COL_GRIDSQUARE, 1, 4) = ? OR COL_VUCC_GRIDS LIKE ? )
AND station_id in ('".implode("','", $logbooks_locations_array)."')
GROUP BY COL_LOTW_QSL_RCVD, COL_QSL_RCVD;";
$query = $this->db->query($sql, array($grid, "%".$grid."%"));
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
if ($row->count > 0 && ($row->lotw == 'Y' || $row->qsl == 'Y')) {
return 2;
}
}
return 1;
} else {
return 0;
}
}
function check_if_grid_worked_in_logbook($grid, $StationLocationsArray = null, $band = null, $cnfm = null) {

View File

@@ -152,10 +152,16 @@ function loadActivationsTable(rows, show_workable_only) {
grids = [];
for (var j=0; j < activation.grids_wkd.length; j++) {
if (!grids.some(str => str.includes(activation.grids[j].substring(0, 4)))) {
if (activation.grids_wkd[j] == 1) {
grids.push("<a href=\"javascript:displayContacts('"+activation.grids[j].substring(0, 4)+"','SAT','All','All','All','VUCC','');\"><span data-bs-toggle=\"tooltip\" title=\"Worked\" class=\"badge bg-success\">"+activation.grids[j].substring(0, 4)+"</span></a>")
} else {
grids.push("<span data-bs-toggle=\"tooltip\" title=\"Not Worked\" class=\"badge bg-danger\">"+activation.grids[j].substring(0, 4)+"</span>")
switch (activation.grids_wkd[j]) {
case 1:
grids.push("<a href=\"javascript:displayContacts('"+activation.grids[j].substring(0, 4)+"','SAT','All','All','All','VUCC','');\"><span data-bs-toggle=\"tooltip\" title=\"Worked\" class=\"badge bg-warning\">"+activation.grids[j].substring(0, 4)+"</span></a>")
break;
case 2:
grids.push("<a href=\"javascript:displayContacts('"+activation.grids[j].substring(0, 4)+"','SAT','All','All','All','VUCC','');\"><span data-bs-toggle=\"tooltip\" title=\"Confirmed\" class=\"badge bg-success\">"+activation.grids[j].substring(0, 4)+"</span></a>")
break;
default:
grids.push("<span data-bs-toggle=\"tooltip\" title=\"Not Worked\" class=\"badge bg-danger\">"+activation.grids[j].substring(0, 4)+"</span>")
break;
}
}
}