From adbc7f68ce5fcf16953955b4b562059973f2fc7c Mon Sep 17 00:00:00 2001 From: AndreasK79 Date: Sat, 25 Apr 2020 23:11:13 +0200 Subject: [PATCH] Added datepicker for LoTW report download. Fixes #465. --- application/controllers/Lotw.php | 21 +++++++++++++------ application/views/interface_assets/footer.php | 12 +++++++++++ application/views/lotw/import.php | 12 +++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index c85a65f2..a05f87c3 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -111,8 +111,8 @@ class Lotw extends CI_Controller { // Get credentials for LoTW $query = $this->user_model->get_by_id($this->session->userdata('user_id')); - $q = $query->row(); - $data['user_lotw_name'] = $q->user_lotw_name; + $q = $query->row(); + $data['user_lotw_name'] = $q->user_lotw_name; $data['user_lotw_password'] = $q->user_lotw_password; // Get URL for downloading LoTW @@ -127,8 +127,17 @@ class Lotw extends CI_Controller { $this->session->set_flashdata('warning', 'You have not defined your ARRL LoTW credentials!'); redirect('lotw/import'); } - // Query the logbook to determine when the last LoTW confirmation was - $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date())); + $customDate = $this->input->post('from'); + + if ($customDate != NULL) { + $customDate = DateTime::createFromFormat('d/m/Y', $customDate); + $customDate = $customDate->format('Y-m-d'); + $lotw_last_qsl_date = date($customDate); + } + else { + // Query the logbook to determine when the last LoTW confirmation was + $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date())); + } // Build URL for LoTW report file $lotw_url .= "?"; @@ -139,8 +148,8 @@ class Lotw extends CI_Controller { //TODO: Option to specifiy whether we download location data from LoTW or not //$lotw_url .= "&qso_qsldetail=\"yes\"; - $lotw_url .= "&qso_qslsince="; - $lotw_url .= "$lotw_last_qsl_date"; + $lotw_url .= "&qso_qslsince="; + $lotw_url .= "$lotw_last_qsl_date"; // Only pull back entries that belong to this callsign $lotw_call = $this->session->userdata('user_callsign'); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index b1cd656f..cf5294ba 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1128,5 +1128,17 @@ $(document).ready(function(){ + uri->segment(2) == "import") { ?> + + + + + diff --git a/application/views/lotw/import.php b/application/views/lotw/import.php index f8e11fc3..7d949ee3 100644 --- a/application/views/lotw/import.php +++ b/application/views/lotw/import.php @@ -27,9 +27,17 @@ +

From date:

+
+
+ +
+
+
+
+
- -

Cloudlog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Cloudlog downloads will have all confirmations since your last LoTW confirmation, up until now.

+

Cloudlog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Cloudlog downloads will have all confirmations since chosen date, or since your last LoTW confirmation (fetched from your log), up until now.

Important You must have QSOs in the logbook before this option works, it will not populate your log from empty based on LoTW QSOs yet.