From fe0a7577266b179b510ac8818f064a8fde4a5f67 Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 25 Aug 2020 22:03:54 +0200 Subject: [PATCH] Edit QSO is working with bootstrapdialog and ajax. --- application/controllers/Qso.php | 31 +- application/views/interface_assets/footer.php | 26 +- application/views/qso/edit_ajax.php | 519 ++++++++++++++++++ 3 files changed, 559 insertions(+), 17 deletions(-) create mode 100644 application/views/qso/edit_ajax.php diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 4b50ccc8..27f5370b 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -129,30 +129,31 @@ class QSO extends CI_Controller { $this->load->model('logbook_model'); $this->load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - $id = str_replace('"', "", $this->input->post("id")); - $query = $this->logbook_model->qso_info($id); $this->load->library('form_validation'); - $this->form_validation->set_rules('time_on', 'Start Date', 'required'); - $this->form_validation->set_rules('time_off', 'End Date', 'required'); - $this->form_validation->set_rules('callsign', 'Callsign', 'required'); + if(!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); + } + + $id = str_replace('"', "", $this->input->post("id")); + $query = $this->logbook_model->qso_info($id); $data['qso'] = $query->row(); $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['iota'] = $this->logbook_model->fetchIota(); - if ($this->form_validation->run() == FALSE) - { - $this->load->view('qso/edit', $data); - } - else - { - $this->logbook_model->edit(); - $this->session->set_flashdata('notice', 'Record Updated'); - $this->load->view('qso/edit_done'); + $this->load->view('qso/edit_ajax', $data); + } + + function qso_save_ajax() { + $this->load->model('logbook_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $this->logbook_model->edit(); } function qsl_rcvd($id, $method) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 22515671..a619718c 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1448,6 +1448,7 @@ $(document).ready(function(){ BootstrapDialog.show({ title: 'QSO Data', size: BootstrapDialog.SIZE_WIDE, + cssClass: 'qso-dialog', nl2br: false, message: html, buttons: [{ @@ -1491,7 +1492,7 @@ $(document).ready(function(){ btnOKClass: 'btn-danger', callback: function(result) { if(result) { - //BootstrapDialog.closeAll() + $(".edit-dialog").modal('hide'); var baseURL= ""; $.ajax({ url: baseURL + 'index.php/qso/delete_ajax', @@ -1499,7 +1500,8 @@ $(document).ready(function(){ data: {'id': id }, success: function(data) { - $(".bootstrap-dialog-message").append('
×The contact with ' + call + ' has been deleted!
'); + $(".alert").remove(); + $(".bootstrap-dialog-message").prepend('
×The contact with ' + call + ' has been deleted!
'); $("#qso_" + id).remove(); // removes qso from table in dialog } }); @@ -1518,6 +1520,7 @@ $(document).ready(function(){ success: function(html) { BootstrapDialog.show({ title: 'QSO Data', + cssClass: 'edit-dialog', size: BootstrapDialog.SIZE_WIDE, nl2br: false, message: html, @@ -1525,6 +1528,25 @@ $(document).ready(function(){ } }); } + + function qso_save() { + var baseURL= ""; + var myform = document.getElementById("qsoform"); + var fd = new FormData(myform); + $.ajax({ + url: baseURL + 'index.php/qso/qso_save_ajax', + data: fd, + cache: false, + processData: false, + contentType: false, + type: 'POST', + success: function (dataofconfirm) { + $(".edit-dialog").modal('hide'); + $(".qso-dialog").modal('hide'); + location.reload(); + } + }); + } diff --git a/application/views/qso/edit_ajax.php b/application/views/qso/edit_ajax.php new file mode 100644 index 00000000..dd776d10 --- /dev/null +++ b/application/views/qso/edit_ajax.php @@ -0,0 +1,519 @@ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+ + +
+ +
+ + + + + +
+ + Delete QSO +
+
+
+ +
+
+
+
+ + + + +