From 99fef495ce9f79eecbd76ca376da40c77aad65d7 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 21 Nov 2024 15:58:51 +0100 Subject: [PATCH] Fetch email from callbook / last QSOs --- application/controllers/Logbook.php | 1 + application/libraries/Hamqth.php | 1 + application/libraries/Qrz.php | 2 ++ application/models/Logbook_model.php | 20 ++++++++++++++++++++ assets/js/sections/qso.js | 5 +++++ 5 files changed, 29 insertions(+) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 6a786fe6b..1903fa630 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -144,6 +144,7 @@ class Logbook extends CI_Controller { $return['callsign_distance'] = $this->distance($return['callsign_qra'], $station_id); $return['callsign_qth'] = $this->nval($callbook['city'] ?? '', $this->logbook_model->call_qth($callsign)); $return['callsign_iota'] = $this->nval($callbook['iota'] ?? '', $this->logbook_model->call_iota($callsign)); + $return['callsign_email'] = $this->nval($callbook['email'] ?? '', $this->logbook_model->call_email($callsign)); $return['qsl_manager'] = $this->nval($callbook['qslmgr'] ?? '', $this->logbook_model->call_qslvia($callsign)); $return['callsign_state'] = $this->nval($callbook['state'] ?? '', $this->logbook_model->call_state($callsign)); $return['callsign_us_county'] = $this->nval($callbook['us_county'] ?? '', $this->logbook_model->call_us_county($callsign)); diff --git a/application/libraries/Hamqth.php b/application/libraries/Hamqth.php index c8d6c71ff..91a531b5d 100644 --- a/application/libraries/Hamqth.php +++ b/application/libraries/Hamqth.php @@ -81,6 +81,7 @@ class Hamqth { // we always want to return name and callsign $data['callsign'] = (string)$xml->search->callsign; $data['name'] = (string)$xml->search->nick; + $data['email'] = (string)$xml->search->email; // only return certain data of a callsign which does not contain a pre- or suffix (see https://github.com/wavelog/wavelog/issues/452) if ($reduced == false) { diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index cde947c0e..43a05855f 100644 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -96,6 +96,8 @@ class Qrz { $data['name'] = (string)$xml->Callsign->fname; } + $data['email'] = (string)$xml->Callsign->email; + // we always give back the name, no matter if reduced data or not $data['name'] = trim($data['name']); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 83638ee93..cd015549a 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1624,6 +1624,26 @@ class Logbook_model extends CI_Model { return $name; } + function call_email($callsign) { + if ($callsign !== $this->get_plaincall($callsign)) { + return null; + } + $this->db->select('COL_CALL, COL_EMAIL, COL_TIME_ON'); + $this->db->join('station_profile', 'station_profile.station_id = ' . $this->config->item('table_name') . '.station_id'); + $this->db->where('COL_CALL', $callsign); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit(1); + $query = $this->db->get($this->config->item('table_name')); + $email = ""; + if ($query->num_rows() > 0) { + $data = $query->row(); + $email = $data->COL_EMAIL; + } + + return $email; + } + function times_worked($callsign) { $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $this->db->select('count(1) as TWKED'); diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 7f79d4b42..945f9998a 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -764,6 +764,11 @@ $("#callsign").on("focusout", function () { $('#name').val(result.callsign_name); } + /* Find Operators E-mail */ + if ($('#email').val() == "") { + $('#email').val(result.callsign_email); + } + if ($('#continent').val() == "") { $('#continent').val(result.dxcc.cont); }