From d9072d344daab213bafac90a5bd2de398f31221e Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 6 Jul 2025 09:47:51 +0200 Subject: [PATCH] Added multi-select --- application/controllers/Qsl.php | 1 + application/models/Qsl_model.php | 14 +++++----- application/views/qslcard/confirmations.php | 13 +++++---- assets/js/sections/qsl.js | 29 +++++++++++++++++++++ 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php index 4c8617e1d..e0b27404d 100644 --- a/application/controllers/Qsl.php +++ b/application/controllers/Qsl.php @@ -42,6 +42,7 @@ class Qsl extends CI_Controller { $footerData = []; $footerData['scripts'] = [ + 'assets/js/bootstrap-multiselect.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/bootstrap-multiselect.js")), 'assets/js/sections/qsl.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/qsl.js")), ]; diff --git a/application/models/Qsl_model.php b/application/models/Qsl_model.php index 974d54e99..6d8cc2b9e 100644 --- a/application/models/Qsl_model.php +++ b/application/models/Qsl_model.php @@ -188,39 +188,39 @@ class Qsl_model extends CI_Model { } $location_list = "'".implode("','",$logbooks_locations_array)."'"; - $table = $this->config->item('table_name'); $sql_parts = array(); - if ($confirmationtype == 'qsl' || $confirmationtype == 'All') { + if (in_array('qsl', $confirmationtype)) { $sql_parts[] = " - SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_qslrdate AS rxdate, 'QSL Card' AS type, exists(select 1 from qsl_images where qsoid = $table.COL_PRIMARY_KEY) as qslcount + SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_qslrdate AS rxdate, 'QSL Card' AS type, + EXISTS (SELECT 1 FROM qsl_images WHERE qsoid = $table.COL_PRIMARY_KEY) AS qslcount FROM $table WHERE station_id IN ($location_list) AND col_qslrdate IS NOT NULL AND col_qslrdate != '' AND col_qsl_rcvd = 'Y' "; } - if ($confirmationtype == 'lotw' || $confirmationtype == 'All') { + if (in_array('lotw', $confirmationtype)) { $sql_parts[] = " SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_lotw_qslrdate AS rxdate, 'LoTW' AS type, 0 as qslcount FROM $table WHERE station_id IN ($location_list) AND col_lotw_qslrdate IS NOT NULL AND col_lotw_qslrdate != '' AND col_lotw_qsl_rcvd = 'Y' "; } - if ($confirmationtype == 'eqsl' || $confirmationtype == 'All') { + if (in_array('eqsl', $confirmationtype)) { $sql_parts[] = " SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_eqsl_qslrdate AS rxdate, 'eQSL' AS type, 0 as qslcount FROM $table WHERE station_id IN ($location_list) AND col_eqsl_qslrdate IS NOT NULL AND col_eqsl_qslrdate != '' AND col_eqsl_qsl_rcvd = 'Y' "; } - if ($confirmationtype == 'qrz' || $confirmationtype == 'All') { + if (in_array('qrz', $confirmationtype)) { $sql_parts[] = " SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_qrzcom_qso_download_date AS rxdate, 'QRZ.com' AS type, 0 as qslcount FROM $table WHERE station_id IN ($location_list) AND col_qrzcom_qso_download_date IS NOT NULL AND col_qrzcom_qso_download_date != '' AND col_qrzcom_qso_download_status = 'Y' "; } - if ($confirmationtype == 'clublog' || $confirmationtype == 'All') { + if (in_array('clublog', $confirmationtype)) { $sql_parts[] = " SELECT col_primary_key, col_call, col_time_on, col_mode, col_submode, col_band, col_sat_name, col_clublog_qso_download_date AS rxdate, 'Clublog' AS type, 0 as qslcount FROM $table diff --git a/application/views/qslcard/confirmations.php b/application/views/qslcard/confirmations.php index ef0246b11..1b2ed07fe 100644 --- a/application/views/qslcard/confirmations.php +++ b/application/views/qslcard/confirmations.php @@ -10,13 +10,12 @@
- + + + + +
diff --git a/assets/js/sections/qsl.js b/assets/js/sections/qsl.js index df72ed29a..59dadc365 100644 --- a/assets/js/sections/qsl.js +++ b/assets/js/sections/qsl.js @@ -11,6 +11,20 @@ function searchAdditionalQsos(filename) { } function getConfirmations() { + let selectedQslTypes = $('#confirmationtype').val(); + if (Array.isArray(selectedQslTypes) && selectedQslTypes.length === 0) { + BootstrapDialog.alert({ + title: 'INFO', + message: 'You need to select at least one QSL type to do a search!', + type: BootstrapDialog.TYPE_INFO, + closable: false, + draggable: false, + callback: function (result) { + } + }); + return false; + } + $('#confirmationbutton').prop("disabled", true).addClass("running"); $.ajax({ url: base_url + 'index.php/qsl/searchConfirmations', @@ -44,3 +58,18 @@ function getConfirmations() { } }); } + +$(document).ready(function () { + $('#confirmationtype').multiselect({ + // template is needed for bs5 support + enableFiltering: true, + enableCaseInsensitiveFiltering: true, + filterPlaceholder: lang_general_word_search, + templates: { + button: '', + }, + numberDisplayed: 1, + inheritClass: true, + includeSelectAllOption: true + }); +});