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 1/3] [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;
From 3a4eadac828cb09c56e0b877c893c8b7e0da7f80 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 11 Aug 2023 20:51:02 +0200
Subject: [PATCH 2/3] QSL Carousel - only show prev/next if more than one image
---
 application/controllers/Logbookadvanced.php   |  2 +-
 .../views/logbookadvanced/qslcarousel.php     | 42 +++++++++++++++++++
 application/views/qslcard/qslcarousel.php     | 22 ++++++----
 3 files changed, 56 insertions(+), 10 deletions(-)
 create mode 100644 application/views/logbookadvanced/qslcarousel.php
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index af66990b..f25fe68f 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -231,6 +231,6 @@ class Logbookadvanced extends CI_Controller {
 		$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);
+        $this->load->view('logbookadvanced/qslcarousel', $data);
 	}
 }
diff --git a/application/views/logbookadvanced/qslcarousel.php b/application/views/logbookadvanced/qslcarousel.php
new file mode 100644
index 00000000..3f26ed00
--- /dev/null
+++ b/application/views/logbookadvanced/qslcarousel.php
@@ -0,0 +1,42 @@
+
+ 1) { ?>
+
+    ';
+    }
+    ?>
+
+
+
+
+    id;
+        if ($i == 1) {
+            echo ' active';
+        }
+        echo '">';
+        echo '
 . '/assets/qslcard/' . $image->filename .')
';
+        echo '
';
+    }
+    ?>
+
 
+ 1) { ?>
+	
+		
+		Previous
+	
+	
+		
+		Next
+	
+
+
diff --git a/application/views/qslcard/qslcarousel.php b/application/views/qslcard/qslcarousel.php
index 78aad712..3f26ed00 100644
--- a/application/views/qslcard/qslcarousel.php
+++ b/application/views/qslcard/qslcarousel.php
@@ -1,4 +1,5 @@
 
\ No newline at end of file
+ 1) { ?>
+	
+		
+		Previous
+	
+	
+		
+		Next
+	
+
+
From e069c5954dd105a619012cf0e7fc400191197f48 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 11 Aug 2023 21:07:06 +0200
Subject: [PATCH 3/3] Added QSO information to the carousel
---
 .../views/logbookadvanced/qslcarousel.php     | 36 +++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/application/views/logbookadvanced/qslcarousel.php b/application/views/logbookadvanced/qslcarousel.php
index 3f26ed00..2f4e7fcb 100644
--- a/application/views/logbookadvanced/qslcarousel.php
+++ b/application/views/logbookadvanced/qslcarousel.php
@@ -23,8 +23,40 @@
         if ($i == 1) {
             echo ' active';
         }
-        echo '">';
-        echo '
';
+        echo '">';?>
+		
+		
+			
+				| Callsign | 
+				Date/Time | 
+				Mode | 
+				Band | 
+				Name | 
+				DXCC | 
+				State | 
+				CQ Zone | 
+				IOTA | 
+				Gridsquare | 
+			
+		
+		
+		';
+			echo ''.$image->COL_CALL.' | ';
+			echo ''.$image->COL_TIME_ON.' | ';
+			echo ''.$image->COL_MODE.' | ';
+			echo ''.$image->COL_BAND.' | ';
+			echo ''.$image->COL_NAME.' | ';
+			echo ''.$image->COL_COUNTRY.' | ';
+			echo ''.$image->COL_STATE.' | ';
+			echo ''.$image->COL_CQZ.' | ';
+			echo ''.$image->COL_IOTA.' | ';
+			echo ''.$image->COL_GRIDSQUARE.' | ';
+			echo '';
+		?>
+		
+
+        filename .'" alt="QSL picture #'. $i++.'">';
         echo '';
     }
     ?>