From 047636b674c3b1bed358cc3437efc27ea47ae34b Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Tue, 25 Aug 2020 15:53:20 +0100 Subject: [PATCH] Basics for ADIF TQ8 headers added based on database info --- application/controllers/Lotw.php | 8 +++--- application/models/Dxcc.php | 14 ++++++++++ application/models/LotwCert.php | 3 +-- .../lotw_views/adif_views/adif_export.php | 26 +++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 application/views/lotw_views/adif_views/adif_export.php diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index d7a09643..24da35e3 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -153,14 +153,16 @@ class Lotw extends CI_Controller { if ($station_profiles->num_rows() >= 1) { foreach ($station_profiles->result() as $station_profile) { - print_r($station_profile); // Get Certificate Data $this->load->model('LotwCert'); + $data['station_profile'] = $station_profile; + $data['lotw_cert_info'] = $this->LotwCert->lotw_cert_details($station_profile->station_callsign); - $lotw_cert_info = $this->LotwCert->lotw_cert_details($station_profile->station_callsign, $this->session->userdata('user_id')); + $this->load->model('Dxcc'); + $data['station_profile_dxcc'] = $this->Dxcc->lookup_country($data['lotw_cert_info']->cert_dxcc); - print_r($lotw_cert_info); + $this->load->view('lotw_views/adif_views/adif_export', $data); } } else { echo "No Station Profiles"; diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 6cfd44cc..a7fd7744 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -463,5 +463,19 @@ class DXCC extends CI_Model { } return $sql; } + + function lookup_country($country) + { + $query = $this->db->query(' + SELECT * + FROM dxcc_entities + WHERE name = "'.$country.'" + ORDER BY LENGTH( prefix ) DESC + LIMIT 1 + '); + + return $query->row(); + } + } ?> diff --git a/application/models/LotwCert.php b/application/models/LotwCert.php index 15dfb478..d28f9b30 100644 --- a/application/models/LotwCert.php +++ b/application/models/LotwCert.php @@ -25,8 +25,7 @@ class LotwCert extends CI_Model { return $query; } - function lotw_cert_details($callsign, $user_id) { - $this->db->where('user_id', $user_id); + function lotw_cert_details($callsign) { $this->db->where('callsign', $callsign); $query = $this->db->get('lotw_certs'); diff --git a/application/views/lotw_views/adif_views/adif_export.php b/application/views/lotw_views/adif_views/adif_export.php new file mode 100644 index 00000000..efc3edff --- /dev/null +++ b/application/views/lotw_views/adif_views/adif_export.php @@ -0,0 +1,26 @@ + +TQSL V2.5.4 Lib: V2.5 Config: V11.12 AllowDupes: false + +tCERT +1 +cert_key); ?>>cert_key; ?> + + +tSTATION +1 +1 +callsign); ?>>callsign; ?> + +adif); ?>>adif; ?> + +station_gridsquare); ?>>station_gridsquare; ?> + +station_itu)) { ?>station_itu); ?>>station_itu; ?> + +station_cq)) { ?>station_cq); ?>>station_cq; ?> + +station_iota)) { ?>station_iota); ?>>station_iota; ?> + + \ No newline at end of file