From 0717fa74ff990bac4de84840eb572612c1758e1e Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 25 Sep 2021 18:08:31 +0200 Subject: [PATCH] [Advanced search] When saving a query, we add this to the dropdown. --- application/controllers/Search.php | 15 ++++----------- application/views/interface_assets/footer.php | 1 + 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/application/controllers/Search.php b/application/controllers/Search.php index 2bf9946b..7aa2ef79 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -54,9 +54,7 @@ class Search extends CI_Controller { if(isset($_POST['search'])) { $result = $this->fetchQueryResult($_POST['search'], false); echo json_encode($result->result_array()); - } else { - echo "Noooooooob"; - } + } } function get_stored_queries() { @@ -69,18 +67,13 @@ class Search extends CI_Controller { if(isset($_POST['search'])) { $data['results'] = $this->fetchQueryResult($_POST['search'], false); $this->load->view('search/search_result_ajax', $data); - } else { - echo "Noooooooob"; } } function export_to_adif() { if(isset($_POST['search'])) { $data['qsos'] = $this->fetchQueryResult($_POST['search'], false); - $this->load->view('adif/data/exportall', $data); - } else { - echo "Noooooooob"; } } @@ -112,9 +105,9 @@ class Search extends CI_Controller { ); $this->db->insert('queries', $data); - - } else { - echo "Noooooooob"; + $last_id = $this->db->insert_id(); + header('Content-Type: application/json'); + echo json_encode(array('id' => $last_id, 'description' => xss_clean($_POST['description']))); } } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index ee5a1e68..c7ca1b12 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -154,6 +154,7 @@ $('#btn-save').on('click', function() { $.post( "", { search: JSON.stringify(resultquery, null, 2), description: $(".getqueryname").val() }) .done(function( data ) { alert('Query saved!'); + $('#querydropdown').append( new Option(data.description, data.id) ); // We add the saved query to the dropdown }); } },