From bcfe97957333054ec12167948956383fa6bf68b8 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 1 Nov 2020 12:36:02 +0100 Subject: [PATCH] [QSL Card image] jQuery upload, dynamically adding/deleting to table and carousel. --- application/controllers/Qsl.php | 23 ++-- application/models/Qsl_model.php | 2 + application/views/interface_assets/footer.php | 100 +++++++++++++++++- application/views/view_log/qso.php | 23 ++-- 4 files changed, 124 insertions(+), 24 deletions(-) diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php index a79f7067b..7a590d15f 100644 --- a/application/controllers/Qsl.php +++ b/application/controllers/Qsl.php @@ -67,13 +67,8 @@ class Qsl extends CI_Controller { $result['back'] = $this->uploadQslCardBack($qsoid); } - // Set Page Title - $data['page_title'] = "QSL Upload"; - - // Load Views - $this->load->view('interface_assets/header', $data); - $this->load->view('qslcard/upload_done', $result); - $this->load->view('interface_assets/footer'); + header("Content-type: application/json"); + echo json_encode(['status' => $result]); } function uploadQslCardFront($qsoid) { @@ -100,9 +95,12 @@ class Qsl extends CI_Controller { // Now we need to insert info into database about file $filename = $data['file_name']; - $this->Qsl_model->saveQsl($qsoid, $filename); + $insertid = $this->Qsl_model->saveQsl($qsoid, $filename); - return 'Success'; + $result['status'] = 'Success'; + $result['insertid'] = $insertid; + $result['filename'] = $filename; + return $result; } } @@ -130,9 +128,12 @@ class Qsl extends CI_Controller { // Now we need to insert info into database about file $filename = $data['file_name']; - $this->Qsl_model->saveQsl($qsoid, $filename); + $insertid = $this->Qsl_model->saveQsl($qsoid, $filename); - return 'Success'; + $result['status'] = 'Success'; + $result['insertid'] = $insertid; + $result['filename'] = $filename; + return $result; } } diff --git a/application/models/Qsl_model.php b/application/models/Qsl_model.php index 4071ffd7d..cb7640c94 100644 --- a/application/models/Qsl_model.php +++ b/application/models/Qsl_model.php @@ -38,6 +38,8 @@ class Qsl_model extends CI_Model { ); $this->db->insert('qsl_images', $data); + + return $this->db->insert_id(); } function deleteQsl($id) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index d716f535c..4e7764a3d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1449,7 +1449,6 @@ $(document).ready(function(){ L.marker([lat,long], {icon: redIcon}).addTo(mymap) .bindPopup(callsign); - mymap.on('click', onMapClick); }, }); @@ -2317,7 +2316,18 @@ function deleteQsl(id) { data: {'id': id }, success: function(data) { - $("#" + id).parent("tr:first").remove(); // removes mode from table + $("#" + id).parent("tr:first").remove(); // removes qsl from table + + // remove qsl from carousel + $(".carousel-indicators li:last-child").remove(); + $(".carouselimageid_"+id).remove(); + $('#carouselExampleIndicators').find('.carousel-item').first().addClass('active'); + + // remove table and hide tab if all qsls are deleted + if ($('.qsltable tr').length == 1) { + $('.qsltable').remove(); + $('.qslcardtab').attr('hidden',''); + } } }); } @@ -2325,5 +2335,91 @@ function deleteQsl(id) { }); } + + diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index cafeceb9d..2440de91d 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -8,18 +8,19 @@ config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { - if (count($qslimages) > 0) { - echo ''; + echo '
  • + QSL Card +
  • '; echo ''; - - } + ?> @@ -309,14 +310,14 @@ foreach ($qslimages as $qsl) { echo ''; echo '' . $qsl->filename . ''; - echo ''; + echo ''; echo ''; } echo ''; } ?> -
    +
    @@ -331,7 +332,7 @@ - +
    @@ -357,7 +358,7 @@ id; if ($i == 1) { echo ' active'; }