From 80b4e8f70f881a0aa741b6fe94562aaeeccda48b Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 11 Aug 2023 19:13:13 +0200 Subject: [PATCH] [Advanced Logbook] Added filter for QSL images, and slideshow button --- application/controllers/Logbookadvanced.php | 8 ++++ application/models/Logbookadvanced_model.php | 28 +++++++++++++ application/views/logbookadvanced/index.php | 9 ++++ assets/js/sections/logbookadvanced.js | 44 ++++++++++++++++++++ 4 files changed, 89 insertions(+) diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index d041ba26..af66990b 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -115,6 +115,7 @@ class Logbookadvanced extends CI_Controller { 'sota' => xss_clean($this->input->post('sota')), 'pota' => xss_clean($this->input->post('pota')), 'wwff' => xss_clean($this->input->post('wwff')), + 'qslimages' => xss_clean($this->input->post('qslimages')), ); $qsos = []; @@ -225,4 +226,11 @@ class Logbookadvanced extends CI_Controller { public function startAtLabel() { $this->load->view('logbookadvanced/startatform'); } + + public function qslSlideshow() { + $cleanids = $this->security->xss_clean($this->input->post('ids')); + $this->load->model('logbookadvanced_model'); + $data['qslimages'] = $this->logbookadvanced_model->getQslsForQsoIds($cleanids); + $this->load->view('qslcard/qslcarousel', $data); + } } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index d51d54d1..51af5d92 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -168,6 +168,18 @@ class Logbookadvanced_model extends CI_Model { $limit = $searchCriteria['qsoresults']; + $where2 = ''; + + if ($searchCriteria['qslimages'] !== '') { + if ($searchCriteria['qslimages'] == 'Y') { + $where2 .= ' and x.qslcount > "0"'; + } + if ($searchCriteria['qslimages'] == 'N') { + $where2 .= ' and x.qslcount is null'; + } + } + + $sql = " SELECT * FROM " . $this->config->item('table_name') . " qsos @@ -181,6 +193,7 @@ class Logbookadvanced_model extends CI_Model { ) x on qsos.COL_PRIMARY_KEY = x.qsoid WHERE station_profile.user_id = ? $where + $where2 ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc LIMIT $limit "; @@ -391,4 +404,19 @@ class Logbookadvanced_model extends CI_Model { return $modes; } + + function getQslsForQsoIds($ids) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + $this->db->select('*'); + $this->db->from($this->config->item('table_name')); + $this->db->join('qsl_images', 'qsl_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key'); + $this->db->where_in('qsoid', $ids); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->order_by("id", "desc"); + + return $this->db->get()->result(); + } } diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php index 13528f30..f0cc2024 100644 --- a/application/views/logbookadvanced/index.php +++ b/application/views/logbookadvanced/index.php @@ -247,6 +247,14 @@ +
+ + +
@@ -266,6 +274,7 @@ + diff --git a/assets/js/sections/logbookadvanced.js b/assets/js/sections/logbookadvanced.js index 3a6153fa..6b393de5 100644 --- a/assets/js/sections/logbookadvanced.js +++ b/assets/js/sections/logbookadvanced.js @@ -197,6 +197,7 @@ $(document).ready(function () { sota: this.sota.value, pota: this.pota.value, wwff: this.wwff.value, + qslimages: this.qslimages.value, }, dataType: 'json', success: function (data) { @@ -411,6 +412,49 @@ $(document).ready(function () { quickSearch('pota'); }); + $('#qslSlideshow').click(function (event) { + var elements = $('#qsoList tbody input:checked'); + var nElements = elements.length; + if (nElements == 0) { + return; + } + $('#qslSlideshow').prop("disabled", true); + var id_list=[]; + elements.each(function() { + let id = $(this).first().closest('tr').data('qsoID') + id_list.push(id); + }); + $.ajax({ + url: base_url + 'index.php/logbookadvanced/qslSlideshow', + type: 'post', + data: { + ids: id_list, + }, + success: function (html) { + BootstrapDialog.show({ + title: 'QSL Card', + size: BootstrapDialog.SIZE_WIDE, + cssClass: 'lookup-dialog', + nl2br: false, + message: html, + onshown: function(dialog) { + + }, + buttons: [{ + label: 'Close', + action: function (dialogItself) { + $('#qslSlideshow').prop("disabled", false); + dialogItself.close(); + } + }], + onhide: function(dialogRef){ + $('#qslSlideshow').prop("disabled", false); + }, + }); + } + }); + }); + function quickSearch(type) { var elements = $('#qsoList tbody input:checked'); var nElements = elements.length;