From 15272f82dcf95a08ce1999db3ce961bce21f9e37 Mon Sep 17 00:00:00 2001
From: phl0 <github@florian-wolters.de>
Date: Mon, 19 Jun 2023 13:05:44 +0200
Subject: [PATCH] Get LoTW info for logbook and search

---
 application/controllers/Logbook.php  | 1 +
 application/models/Logbook_model.php | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
index 66ae7b81..65a4387d 100644
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -770,6 +770,7 @@ class Logbook extends CI_Controller {
 		$this->db->from($this->config->item('table_name'));
 		$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
 		$this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC');
+		$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
 		$this->db->group_start();
 		$this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id);
 		$this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id);
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index bb5c0a06..8f5d4409 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -314,7 +314,7 @@ class Logbook_model extends CI_Model {
 
 		$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
 		$this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC', 'left outer');
-    $this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
+		$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
 		switch ($type) {
 			case 'DXCC':
 				$this->db->where('COL_COUNTRY', $searchphrase);
@@ -1280,11 +1280,12 @@ class Logbook_model extends CI_Model {
       return array();
     }
 
-    $this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*');
+    $this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, lotw_users.callsign, lotw_users.lastupload');
     $this->db->from($this->config->item('table_name'));
 
     $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
     $this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
+    $this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
     $this->db->where_in('station_profile.station_id', $logbooks_locations_array);
     $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
     $this->db->order_by(''.$this->config->item('table_name').'.COL_PRIMARY_KEY', "desc");