From fd24d64fccaa0e328a02f55fc6adb94a87a7543b Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 29 Jul 2025 19:05:05 +0200 Subject: [PATCH] Added functionality for rejecting an OQRS --- application/controllers/Oqrs.php | 6 +++++ application/models/Oqrs_model.php | 22 ++++++++++++++++ assets/js/sections/oqrs.js | 42 ++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/application/controllers/Oqrs.php b/application/controllers/Oqrs.php index e0b91ec29..f9cdcf1a3 100644 --- a/application/controllers/Oqrs.php +++ b/application/controllers/Oqrs.php @@ -202,6 +202,12 @@ class Oqrs extends CI_Controller { $this->oqrs_model->delete_oqrs_line($id); } + public function reject_oqrs_line() { + $id = $this->input->post('id', TRUE); + $this->load->model('oqrs_model'); + $this->oqrs_model->reject_oqrs_line($id); + } + public function search_log() { $this->load->model('oqrs_model'); $callsign = $this->input->post('callsign', TRUE); diff --git a/application/models/Oqrs_model.php b/application/models/Oqrs_model.php index 3f0858cc5..be425dd39 100644 --- a/application/models/Oqrs_model.php +++ b/application/models/Oqrs_model.php @@ -214,6 +214,28 @@ class Oqrs_model extends CI_Model { return true; } + function reject_oqrs_line($id) { + $sql = 'update ' . $this->config->item('table_name') . ' set COL_QSL_SENT = "N", COL_QSLSDATE = "", COL_QSL_SENT_VIA = "" + where COL_PRIMARY_KEY = (select oqrs.qsoid from oqrs join station_profile on station_profile.station_id = oqrs.station_id where oqrs.id = ? and station_profile.user_id = ?)'; + $binding = [$id, $this->session->userdata('user_id')]; + + $this->db->query($sql, $binding); + + $binding = []; + + $binding = [$id, $this->session->userdata('user_id')]; + + $sql = 'UPDATE oqrs + JOIN station_profile ON station_profile.station_id = oqrs.station_id + SET oqrs.status = 4 + WHERE oqrs.id = ? + AND station_profile.user_id = ?'; + + $query = $this->db->query($sql, $binding); + + return true; + } + // Status: // 0 = open request // 1 = not in log request diff --git a/assets/js/sections/oqrs.js b/assets/js/sections/oqrs.js index dc1714e38..759feaf92 100644 --- a/assets/js/sections/oqrs.js +++ b/assets/js/sections/oqrs.js @@ -457,6 +457,8 @@ function echo_status(status) { case '0': return 'Open request'; break; case '1': return 'Not in log request'; break; case '2': return 'Request done'; break; + case '3': return 'Request pending'; break; + case '4': return 'Request rejected'; break; default: return ''; } } @@ -556,6 +558,44 @@ $(document).ready(function () { }); }); + $('#rejectOqrs').click(function (event) { + var elements = $('.oqrstable tbody input:checked'); + var nElements = elements.length; + if (nElements == 0) { + return; + } + + $('#rejectOqrs').prop("disabled", true); + + var table = $('.oqrstable').DataTable(); + + BootstrapDialog.confirm({ + title: 'WARNING', + message: 'Warning! Are you sure you want to reject the marked OQRS request(s)?' , + type: BootstrapDialog.TYPE_WARNING, + closable: true, + draggable: true, + btnOKClass: 'btn-warning', + callback: function(result) { + if(result) { + elements.each(function() { + let id = $(this).first().closest('tr').attr('id')?.replace(/\D/g, ''); + $.ajax({ + url: base_url + 'index.php/oqrs/reject_oqrs_line', + type: 'post', + data: {'id': id + }, + success: function(data) { + $('#searchForm').submit(); + } + }); + }) + $('#rejectOqrs').prop("disabled", false); + } + } + }); + }); + $('#markOqrs').click(function (event) { var elements = $('.oqrstable tbody input:checked'); var nElements = elements.length; @@ -587,9 +627,9 @@ $(document).ready(function () { $('#searchForm').submit(); } }); - $('#markOqrs').prop("disabled", false); }) } + $('#markOqrs').prop("disabled", false); } }); });