From def0ed9f4b690058d2cdb1c5bd31c9727c4918a1 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Fri, 11 Jun 2021 16:05:49 +0100 Subject: [PATCH] [Logbook] Adds QSL Card Requested to the dropdown for each qso --- application/controllers/Qso.php | 21 +++++++++++++++++++ application/models/Logbook_model.php | 13 ++++++++++++ application/views/interface_assets/footer.php | 21 +++++++++++++++++++ .../views/view_log/partial/log_ajax.php | 1 + 4 files changed, 56 insertions(+) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 886287f5..0bcd6b22 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -216,6 +216,27 @@ class QSO extends CI_Controller { } } + function qsl_requested_ajax() { + $id = str_replace('"', "", $this->input->post("id")); + $method = str_replace('"', "", $this->input->post("method")); + + $this->load->model('logbook_model'); + $this->load->model('user_model'); + + header('Content-Type: application/json'); + + if(!$this->user_model->authorize(2)) { + echo json_encode(array('message' => 'Error')); + + } + else { + // Update Logbook to Mark Paper Card Received + $this->logbook_model->paperqsl_requested($id, $method); + + echo json_encode(array('message' => 'OK')); + } + } + /* Delete QSO */ function delete($id) { $this->load->model('logbook_model'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 733dc39a..12d5b2b1 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -755,6 +755,19 @@ class Logbook_model extends CI_Model { $this->db->update($this->config->item('table_name'), $data); } + // Set Paper to requested + function paperqsl_requested($qso_id, $method) { + + $data = array( + 'COL_QSLSDATE' => date('Y-m-d'), + 'COL_QSL_SENT' => 'R' + ); + + $this->db->where('COL_PRIMARY_KEY', $qso_id); + + $this->db->update($this->config->item('table_name'), $data); + } + function get_qsos_for_printing() { $CI =& get_instance(); $CI->load->model('Stations'); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 292b836e..81d4b96a 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1312,6 +1312,27 @@ $(document).ready(function(){ }); } + // Function: qsl_requested + // Marks QSL card requested against the QSO. + function qsl_requested(id, method) { + var baseURL= ""; + $.ajax({ + url: baseURL + 'index.php/qso/qsl_requested_ajax', + type: 'post', + data: {'id': id, + 'method': method + }, + success: function(data) { + if (data.message == 'OK') { + $("#qso_" + id).find("td:eq(8)").find("span:eq(0)").attr('class', 'qsl-yellow'); // Paints arrow green + } + else { + $(".bootstrap-dialog-message").append('
×You are not allowed to update QSL status!
'); + } + } + }); + } + function qso_delete(id, call) { BootstrapDialog.confirm({ title: 'DANGER', diff --git a/application/views/view_log/partial/log_ajax.php b/application/views/view_log/partial/log_ajax.php index 49b937ec..4ebb61e8 100644 --- a/application/views/view_log/partial/log_ajax.php +++ b/application/views/view_log/partial/log_ajax.php @@ -245,6 +245,7 @@ COL_QSL_RCVD !='Y') { ?> lang->line('general_mark_qsl_rx_bureau'); ?> lang->line('general_mark_qsl_rx_direct'); ?> + Mark QSL Card Requested