From a25132d5cb7a0292d2d1e3d292fa85399afb985f Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 30 Jan 2025 21:07:58 +0100 Subject: [PATCH] Made download a JS call --- application/controllers/Clublog.php | 5 +++-- application/views/clublog/export.php | 4 ++-- assets/js/sections/clublog.js | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php index 54745b8a3..26320ae88 100644 --- a/application/controllers/Clublog.php +++ b/application/controllers/Clublog.php @@ -144,7 +144,7 @@ class Clublog extends CI_Controller $this->load->model('clublog_model'); - $customDate = $this->input->post('from'); + $customDate = $this->input->post('date'); if ($customDate != NULL) { $clublog_last_date = date($customDate); } else { @@ -161,7 +161,8 @@ class Clublog extends CI_Controller $r = __("No user has configured Clublog."); } - echo $r; + header('Content-type: application/json'); + echo json_encode($r); } } diff --git a/application/views/clublog/export.php b/application/views/clublog/export.php index 18297f8ec..edb736516 100644 --- a/application/views/clublog/export.php +++ b/application/views/clublog/export.php @@ -71,11 +71,11 @@
- +

- + diff --git a/assets/js/sections/clublog.js b/assets/js/sections/clublog.js index 3bee18b64..7ffcfc129 100644 --- a/assets/js/sections/clublog.js +++ b/assets/js/sections/clublog.js @@ -28,7 +28,7 @@ function ExportClublog(station_id) { } if (data.errormessages.length > 0) { - $("#clublog_export").append( + $("#export").append( '
\n' + '
\n' + '
\n' + @@ -47,3 +47,26 @@ function ExportClublog(station_id) { } }); } + + +function importlog() { + if ($(".alert").length > 0) { + $(".alert").remove(); + } + if ($(".errormessages").length > 0) { + $(".errormessages").remove(); + } + $(".ld-ext-right-import").addClass('running'); + $(".ld-ext-right-import").prop('disabled', true); + + $.ajax({ + url: base_url + 'index.php/clublog/importlog', + type: 'post', + data: {'date': $(".importdate").val()}, + success: function (data) { + $(".ld-ext-right-import").removeClass('running'); + $(".ld-ext-right-import").prop('disabled', false); + $("#import").append(''); + } + }); +}