From e149d34ba18040c1b09620374ff77ba1143a91d2 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 18 Nov 2020 11:50:15 +0100 Subject: [PATCH] [QRZ Logbook] option for realtime logging added --- application/config/migration.php | 2 +- .../056_add_qrz_upload_realtime_option.php | 20 +++++++++++++++++ application/models/Logbook_model.php | 22 +++++++++++-------- application/models/Stations.php | 2 ++ application/views/station_profile/create.php | 17 ++++++++++---- application/views/station_profile/edit.php | 11 +++++++++- 6 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 application/migrations/056_add_qrz_upload_realtime_option.php diff --git a/application/config/migration.php b/application/config/migration.php index a9dbaec0..95bc2923 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 55; +$config['migration_version'] = 56; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/056_add_qrz_upload_realtime_option.php b/application/migrations/056_add_qrz_upload_realtime_option.php new file mode 100644 index 00000000..dd510fa4 --- /dev/null +++ b/application/migrations/056_add_qrz_upload_realtime_option.php @@ -0,0 +1,20 @@ +dbforge->add_column('station_profile', $fields); + } + + public function down() + { + $this->dbforge->drop_column('station_profile', 'qrzrealtime'); + } +} \ No newline at end of file diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index b5bd539b..f2f13802 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -336,15 +336,19 @@ class Logbook_model extends CI_Model { $data['COL_RX_PWR'] = str_replace("W", "", $data['COL_RX_PWR']); } + $result = $this->exists_qrz_api_key($data['station_id']); + // Push qso to qrz if apikey is set - if ($apikey = $this->exists_qrz_api_key($data['station_id'])) { - $adif = $this->create_adif_from_data($data); - $result = $this->push_qso_to_qrz($apikey, $adif); - IF ($result['status'] == 'OK') { - $data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y'; - $data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now")); + if ($result) { + if ($result->qrzrealtime == 1) { + $adif = $this->create_adif_from_data($data); + $result = $this->push_qso_to_qrz($result->qrzapikey, $adif); + IF ($result['status'] == 'OK') { + $data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y'; + $data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now")); + } } - } + } // Add QSO to database $this->db->insert($this->config->item('table_name'), $data); @@ -354,7 +358,7 @@ class Logbook_model extends CI_Model { * Function checks if a QRZ API Key exists in the table with the given station id */ function exists_qrz_api_key($station_id) { - $sql = 'select qrzapikey from station_profile + $sql = 'select qrzapikey, qrzrealtime from station_profile where station_id = ' . $station_id; $query = $this->db->query($sql); @@ -362,7 +366,7 @@ class Logbook_model extends CI_Model { $result = $query->row(); if ($result) { - return $result->qrzapikey; + return $result; } else { return false; diff --git a/application/models/Stations.php b/application/models/Stations.php index 47534858..d7945260 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -53,6 +53,7 @@ class Stations extends CI_Model { 'state' => xss_clean($this->input->post('station_state', true)), 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), + 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), ); // Insert Records @@ -77,6 +78,7 @@ class Stations extends CI_Model { 'state' => xss_clean($this->input->post('station_state', true)), 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), + 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), ); $this->db->where('station_id', xss_clean($this->input->post('station_id', true))); diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index 0f05e4a4..d3652fab 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -200,10 +200,19 @@ eQSL QTH Nickname. -
- - - Find your API key on QRZ.com's settings page +
+
+ + + Find your API key on QRZ.com's settings page +
+
+ + +
diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index 5be02219..2be3a8e3 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -222,11 +222,20 @@ eQSL QTH Nickname.
-
+
+
qrzapikey; } ?>"> Find your API key on QRZ.com's settings page
+
+ + +
+