From 958c55069926849d81ee24d873fa3176ed83a903 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 2 Sep 2024 15:47:40 +0200 Subject: [PATCH] Function to show distance records per SAT --- application/controllers/Distancerecords.php | 17 +++++ application/models/Logbook_model.php | 12 ++++ application/views/distancerecords/details.php | 3 + application/views/distancerecords/index.php | 2 +- assets/js/sections/distancerecords.js | 62 +++++++++++++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 application/views/distancerecords/details.php create mode 100644 assets/js/sections/distancerecords.js diff --git a/application/controllers/Distancerecords.php b/application/controllers/Distancerecords.php index de845955f..170d8f59b 100644 --- a/application/controllers/Distancerecords.php +++ b/application/controllers/Distancerecords.php @@ -33,6 +33,10 @@ class Distancerecords extends CI_Controller { case 'M d, y': $usethisformat = 'MMM D, YY';break; } + $data['scripts'] = [ + 'assets/js/sections/distancerecords.js', + ]; + // Render Page $data['custom_date_format'] = $custom_date_format; $data['page_title'] = __("Satellite Distance Records"); @@ -45,4 +49,17 @@ class Distancerecords extends CI_Controller { $this->load->view('interface_assets/footer', $footerData); } + public function sat_records_ajax() { + $this->load->model('logbook_model'); + + $sat = str_replace('"', "", $this->security->xss_clean($this->input->post("Sat"))); + $searchmode = $this->input->post('searchmode') == null ? '' : $this->security->xss_clean($this->input->post('searchmode')); + $data['results'] = $this->logbook_model->sat_distances($sat); + + $data['page_title'] = __("Log View")." - " . __("Satellite Distance Records"); + $data['filter'] = $sat; + + $this->load->view('distancerecords/details', $data); + } + } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 894a0aeac..8f92059a4 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -419,6 +419,18 @@ class Logbook_model extends CI_Model { return($row); } } + public function sat_distances($sat){ + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->where('COL_SAT_NAME', $sat); + $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); + $this->db->order_by("COL_DISTANCE", "desc"); + $this->db->limit(500); + + return $this->db->get($this->config->item('table_name')); + } + /* * Used to fetch QSOs from the logbook in the awards */ diff --git a/application/views/distancerecords/details.php b/application/views/distancerecords/details.php new file mode 100644 index 000000000..6325c287c --- /dev/null +++ b/application/views/distancerecords/details.php @@ -0,0 +1,3 @@ +
+ +load->view('view_log/partial/log_ajax'); ?> diff --git a/application/views/distancerecords/index.php b/application/views/distancerecords/index.php index 866abaf2b..4df552d0a 100644 --- a/application/views/distancerecords/index.php +++ b/application/views/distancerecords/index.php @@ -30,7 +30,7 @@ - sat; ?> + sat; ?> distance)); ?> time ?? ''); echo date($custom_date_format, $timestamp); ?> time ?? ''); echo date('H:i', $timestamp); ?> diff --git a/assets/js/sections/distancerecords.js b/assets/js/sections/distancerecords.js new file mode 100644 index 000000000..f45dbdd7c --- /dev/null +++ b/assets/js/sections/distancerecords.js @@ -0,0 +1,62 @@ +var modalloading=false; +function displayDistanceQsos(sat) { + if (!(modalloading)) { + var ajax_data = ({ + 'Sat': sat, + }) + modalloading=true; + $.ajax({ + url: base_url + 'index.php/distancerecords/sat_records_ajax', + type: 'post', + data: ajax_data, + success: function (html) { + var dialog = new BootstrapDialog({ + title: lang_general_word_qso_data, + cssClass: 'qso-dialog', + size: BootstrapDialog.SIZE_WIDE, + nl2br: false, + message: html, + onshown: function(dialog) { + modalloading=false; + $('[data-bs-toggle="tooltip"]').tooltip(); + $('.contacttable').DataTable({ + "pageLength": 25, + responsive: false, + ordering: false, + "scrollY": "550px", + "scrollCollapse": true, + "paging": false, + "scrollX": true, + "language": { + url: getDataTablesLanguageUrl(), + }, + dom: 'Bfrtip', + buttons: [ + 'csv' + ] + }); + // change color of csv-button if dark mode is chosen + if (isDarkModeTheme()) { + $(".buttons-csv").css("color", "white"); + } + $('.table-responsive .dropdown-toggle').off('mouseenter').on('mouseenter', function () { + showQsoActionsMenu($(this).closest('.dropdown')); + }); + }, + buttons: [{ + label: lang_admin_close, + action: function(dialogItself) { + dialogItself.close(); + } + }] + }); + dialog.realize(); + $("#gridsquare_map").append(dialog.getModal()); + dialog.open(); +}, + error: function(e) { + modalloading=false; + } + }); + } +}