From d7a23d23a43fecd5d17c65d0d3f64fcd765ef000 Mon Sep 17 00:00:00 2001 From: phl0 Date: Sun, 3 Apr 2022 10:28:36 +0200 Subject: [PATCH] Pull image from qrz.com and display in QSO log window --- application/controllers/Logbook.php | 19 ++++++++++++++++++- application/language/english/qso_lang.php | 1 + application/libraries/Qrz.php | 1 + application/views/qso/index.php | 9 +++++++++ assets/css/general.css | 21 ++++++++++++++++++++- assets/js/sections/qso.js | 8 ++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 59a6a86e..f10b301b 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -126,11 +126,14 @@ class Logbook extends CI_Controller { "bearing" => "", "workedBefore" => false, "lotw_member" => $lotw_member, + "image" => "", ]; $return['dxcc'] = $this->dxcheck($callsign); $return['partial'] = $this->partial($callsign); + $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); + // Do we have local data for the Callsign? if($this->logbook_model->call_name($callsign) != null) { @@ -148,6 +151,15 @@ class Logbook extends CI_Controller { $return['callsign_state'] = $this->logbook_model->call_state($callsign); $return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); + if (isset($callbook)) { + if ($callbook['image'] == "") { + $return['image'] = "n/a"; + } else { + $return['image'] = $callbook['image']; + } + } else { + $return['image'] = "n/a"; + } if ($return['callsign_qra'] != "") { $return['latlng'] = $this->qralatlng($return['callsign_qra']); @@ -157,7 +169,7 @@ class Logbook extends CI_Controller { return; } - $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); + //$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); if (isset($callbook)) { @@ -167,6 +179,11 @@ class Logbook extends CI_Controller { $return['callsign_iota'] = $callbook['iota']; $return['callsign_state'] = $callbook['state']; $return['callsign_us_county'] = $callbook['us_county']; + if ($callbook['image'] == "") { + $return['image'] = "n/a"; + } else { + $return['image'] = $callbook['image']; + } if(isset($callbook['qslmgr'])) { $return['qsl_manager'] = $callbook['qslmgr']; diff --git a/application/language/english/qso_lang.php b/application/language/english/qso_lang.php index 944f0d2a..cede1158 100644 --- a/application/language/english/qso_lang.php +++ b/application/language/english/qso_lang.php @@ -6,6 +6,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $lang['qso_title_qso_map'] = 'QSO Map'; $lang['qso_title_suggestions'] = 'Suggestions'; $lang['qso_title_pervious_contacts'] = 'Previous Contacts'; +$lang['qso_title_image'] = 'Image'; // Input Help Text on the /QSO Display $lang['qso_transmit_power_helptext'] = 'Give power value in Watts. Include only numbers in the input.'; diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index d1a26f30..1e0289d4 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -88,6 +88,7 @@ class Qrz { $data['long'] = (string)$xml->Callsign->lon; $data['iota'] = (string)$xml->Callsign->iota; $data['qslmgr'] = (string)$xml->Callsign->qslmgr; + $data['image'] = (string)$xml->Callsign->image; if ($xml->Callsign->country == "United States") { $data['state'] = (string)$xml->Callsign->state; diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 096def04..951a3cf4 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -521,6 +521,15 @@
+ +

lang->line('qso_title_pervious_contacts'); ?>

diff --git a/assets/css/general.css b/assets/css/general.css index f5f2854a..30b84b29 100644 --- a/assets/css/general.css +++ b/assets/css/general.css @@ -145,6 +145,25 @@ TD.lotw{ margin-bottom: 0px; } +.callsign-image .card-title { + margin-bottom: 0px; +} + +.callsign-image { + margin-bottom: 10px; + margin-left: auto; + margin-right: auto; +} + +.callsign-image-content { + display: block; + max-height: 300px; +} + +.callsign-image-pic { + max-height: 250px; +} + .qso-map .card-title { margin-bottom: 0px; } @@ -255,4 +274,4 @@ color: #ffffff; .modal-body { max-height: calc(100vh - 200px); overflow-y: auto; -} \ No newline at end of file +} diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 8f19929a..3fbae45f 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -279,6 +279,8 @@ function reset_fields() { $('#callsign_info').removeClass("badge-secondary"); $('#callsign_info').removeClass("badge-success"); $('#callsign_info').removeClass("badge-danger"); + $('#callsign-image').attr('style', 'display: none;'); + $('#callsign-image-content').text(""); $('#qsl_via').val(""); $('#callsign_info').text(""); $('#input_usa_state').val(""); @@ -441,6 +443,12 @@ $("#callsign").focusout(function() { $('#qth').val(result.callsign_qth); } + /* Find link to qrz.com picture */ + if (result.image != "n/a") { + $('#callsign-image-content').html(''); + $('#callsign-image').attr('style', 'display: true;'); + } + /* * Update state with returned value */