From 5886ce2dc8db0a98c7a3af56421e62e659071b0b Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 07:40:12 +0100 Subject: [PATCH 01/10] new function for return json data for map --- application/models/Logbook_model.php | 58 ++++++++++++++++++++++++++++ application/models/Stations.php | 6 +-- assets/js/leaflet/leafembed.js | 3 +- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index ffde37ff..7c74fd67 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4479,6 +4479,64 @@ function lotw_last_qsl_date($user_id) { } return false; } + + // [JSON PLOT] return array for plot qso for map // + public function get_plot_array_for_map($qsos_result) { + $this->load->library('qra'); + + $json["markers"] = array(); + $plot = array('lat'=>0, 'lng'=>0, 'html'=>'', 'label'=>'', 'confirmed'=>'N'); + + foreach ($qsos_result as $row) { + $plot['label'] = $row->COL_CALL; + + $plot['html'] = "Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
"; + $plot['html'] .= ($row->COL_SAT_NAME != null) ? ("SAT: ".$row->COL_SAT_NAME."
") : ("Band: ".$row->COL_BAND."
"); + $plot['html'] .= "Mode: ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)."
"; + + // check if qso is confirmed // + if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { + $plot['confirmed'] = "Y"; + } + // check lat / lng (depend info source) // + if ($row->COL_GRIDSQUARE != null) { + $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); + + } elseif ($row->COL_VUCC_GRIDS != null) { + $grids = explode(",", $row->COL_VUCC_GRIDS); + if (count($grids) == 2) { + $grid1 = $this->qra->qra2latlong(trim($grids[0])); + $grid2 = $this->qra->qra2latlong(trim($grids[1])); + + $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); + $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); + + $stn_loc = $this->qra->get_midpoint($coords); + } + if (count($grids) == 4) { + $grid1 = $this->qra->qra2latlong(trim($grids[0])); + $grid2 = $this->qra->qra2latlong(trim($grids[1])); + $grid3 = $this->qra->qra2latlong(trim($grids[2])); + $grid4 = $this->qra->qra2latlong(trim($grids[3])); + + $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); + $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); + $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); + $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); + + $stn_loc = $this->qra->get_midpoint($coords); + } + } else { + if (isset($row->lat) && isset($row->long)) { + $stn_loc = array($row->lat, $row->long); + } + } + list($plot['lat'], $plot['lng']) = $stn_loc; + // add plot // + $json["markers"][] = $plot; + } + return $json; + } } function validateADIFDate($date, $format = 'Ymd') diff --git a/application/models/Stations.php b/application/models/Stations.php index 46ae25e3..c26b433d 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -513,14 +513,14 @@ class Stations extends CI_Model { return false; } - // [MAP Custom] get json structure (for map) about info's station // - public function get_station_json_for_map() { + // [MAP Custom] get array for json structure (for map) about info's station // + public function get_station_array_for_map() { $_jsonresult = array(); list($station_lat, $station_lng) = array(0,0); $station_active = $this->profile($this->find_active())->row(); if (!empty($station_active)) { list($station_lat, $station_lng) = $this->qra->qra2latlong($station_active->station_gridsquare); } if (($station_lat!=0)&&($station_lng!=0)) { $_jsonresult = array('lat'=>$station_lat,'lng'=>$station_lng,'html'=>$station_active->station_gridsquare,'label'=>$station_active->station_profile_name,'icon'=>'stationIcon'); } - return (count($_jsonresult)>0)?("\"station\":".json_encode($_jsonresult)):''; + return (count($_jsonresult)>0)?(array('station'=>$_jsonresult)):array(); } } diff --git a/assets/js/leaflet/leafembed.js b/assets/js/leaflet/leafembed.js index cc8a216f..e76678ba 100644 --- a/assets/js/leaflet/leafembed.js +++ b/assets/js/leaflet/leafembed.js @@ -59,8 +59,9 @@ function initmap(ShowGrid='No', MapTag='map', options={}) { function askForPlots(_url_qso, options={}) { removeMarkers(); + if (typeof options.dataPost !== "undefined") { _dataPost = options.dataPost; } else { _dataPost = {}; } $.ajax({ - url: _url_qso, type: 'GET', dataType: 'json', + url: _url_qso, type: 'POST', dataType: 'json', data: _dataPost, error: function() { console.log('[ERROR] ajax askForPlots() function return error.'); }, success: function(plotjson) { if ((typeof plotjson['markers'] !== "undefined")&&(plotjson['markers'].length>0)) { From 81f9013e6284b6c18d2f9ad7c8cc6ff9ae75aaa0 Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 08:18:42 +0100 Subject: [PATCH 02/10] new function and remove old function --- application/controllers/Dashboard.php | 98 -------- application/controllers/Logbook.php | 103 -------- application/controllers/Map.php | 219 ++---------------- application/views/interface_assets/footer.php | 19 +- 4 files changed, 36 insertions(+), 403 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index c627c431..5d994e27 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -140,103 +140,5 @@ class Dashboard extends CI_Controller { $this->load->view('components/radio_display_table', $data); } - function map() { - $this->load->model('logbook_model'); - - $this->load->library('qra'); - - $qsos = $this->logbook_model->get_last_qsos('18'); - - echo "{\"markers\": ["; - $count = 1; - foreach ($qsos->result() as $row) { - // check if qso is confirmed // - if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; } - //print_r($row); - if($row->COL_GRIDSQUARE != null) { - $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - }elseif($row->COL_VUCC_GRIDS != null) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - if (count($grids) == 2) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - if (count($grids) == 4) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - $grid3 = $this->qra->qra2latlong(trim($grids[2])); - $grid4 = $this->qra->qra2latlong(trim($grids[3])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); - $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - } else { - if($count != 1) { - echo ","; - } - - if(isset($row->lat) && isset($row->long)) { - $lat = $row->lat; - $lng = $row->long; - } - echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - $count++; - } - - } - echo "]"; - - // [MAP Custom] ADD Station // - $this->load->model('Stations'); - $station_json = $this->Stations->get_station_json_for_map(); - echo (!empty($station_json))?', '.$station_json:''; - - echo "}"; - - } - } diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index d1ec8f38..1497c38b 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -594,109 +594,6 @@ class Logbook extends CI_Controller { } } - - /* Used to generate maps for displaying on /logbook/ */ - function qso_map() { - header('Content-Type: application/json; charset=utf-8'); - $this->load->model('logbook_model'); - - $this->load->library('qra'); - - $data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4)); - - echo "{\"markers\": ["; - $count = 1; - foreach ($data['qsos']->result() as $row) { - // check if qso is confirmed // - if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; } - - if($row->COL_GRIDSQUARE != null) { - $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - }elseif($row->COL_VUCC_GRIDS != null) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - if (count($grids) == 2) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - if (count($grids) == 4) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - $grid3 = $this->qra->qra2latlong(trim($grids[2])); - $grid4 = $this->qra->qra2latlong(trim($grids[3])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); - $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - - } else { - if($count != 1) { - echo ","; - } - - $result = $this->logbook_model->dxcc_lookup($row->COL_CALL, $row->COL_TIME_ON); - - if(isset($result)) { - $lat = $result['lat']; - $lng = $result['long']; - } - echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - $count++; - } - - } - echo "]"; - - // [MAP Custom] ADD Station // - $this->load->model('Stations'); - $station_json = $this->Stations->get_station_json_for_map(); - echo (!empty($station_json))?', '.$station_json:''; - - echo "}"; - } - function view($id) { $this->load->model('user_model'); if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } diff --git a/application/controllers/Map.php b/application/controllers/Map.php index a7b5757e..adb37a01 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -98,202 +98,33 @@ class Map extends CI_Controller { $this->load->view('interface_assets/footer',$footer_data); } - - function map_data_custom() { - $start_date = $this->uri->segment(3); - $end_date = $this->uri->segment(4); - $band = $this->uri->segment(5); - $mode = $this->uri->segment(6); - $propagation = $this->uri->segment(7); + // Generic fonction for return Json for MAP // + function map_plot_json() { + $this->load->model('Stations'); $this->load->model('logbook_model'); - - $this->load->library('qra'); - - $qsos = $this->logbook_model->map_custom_qsos(rawurldecode($start_date), rawurldecode($end_date), $band, rawurldecode($mode), rawurldecode($propagation)); + + // set informations // + if ($this->input->post('isCustom') == true) { + $date_from = $this->input->post('date_from'); + $date_to = $this->input->post('date_to'); + $band = $this->input->post('band'); + $mode = $this->input->post('mode'); + $prop_mode = $this->input->post('prop_mode'); + $qsos = $this->logbook_model->map_custom_qsos($date_from, $date_to, $band, $mode, $prop_mode); + } else if ($this->input->post('isFull') == true) { + $qsos = $this->logbook_model->get_qsos(100000,0); // limited at 100000 (perhaps is too big for list of plot on map ?) // + } else { + $nb_qso = (intval($this->input->post('nb_qso'))>0)?$this->input->post('nb_qso'):25; + $offset = (intval($this->input->post('offset'))>0)?$this->input->post('offset'):0; + $qsos = $this->logbook_model->get_qsos($nb_qso, $offset); + } + // [PLOT] ADD plot // + $plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result()); + // [MAP Custom] ADD Station // + $station_array = $this->Stations->get_station_array_for_map(); + header('Content-Type: application/json; charset=utf-8'); - echo "{\"markers\": ["; - $count = 1; - if ($qsos) { - foreach ($qsos->result() as $row) { - // check if qso is confirmed // - if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; } - - //print_r($row); - if($row->COL_GRIDSQUARE != null) { - $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - }elseif($row->COL_VUCC_GRIDS != null) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - if (count($grids) == 2) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - if (count($grids) == 4) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - $grid3 = $this->qra->qra2latlong(trim($grids[2])); - $grid4 = $this->qra->qra2latlong(trim($grids[3])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); - $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - } else { - if($count != 1) { - echo ","; - } - - if(isset($row->lat) && isset($row->long)) { - $lat = $row->lat; - $lng = $row->long; - } - - echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - $count++; - } - } - - } - echo "]"; - - // [MAP Custom] ADD Station // - $this->load->model('Stations'); - $station_json = $this->Stations->get_station_json_for_map(); - echo (!empty($station_json))?', '.$station_json:''; - - echo "}"; - + echo json_encode(array_merge($plot_array, $station_array)); } - function map_data() { - $this->load->model('logbook_model'); - - $this->load->library('qra'); - - //echo date('Y-m-d') - $raw = strtotime('Monday last week'); - - $mon = date('Y-m-d', $raw); - $sun = date('Y-m-d', strtotime('Monday next week')); - - $qsos = $this->logbook_model->map_all_qsos_for_active_station_profile(); - - echo "{\"markers\": ["; - $count = 1; - foreach ($qsos->result() as $row) { - // check if qso is confirmed // - if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; } - - //print_r($row); - if($row->COL_GRIDSQUARE != null) { - $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - } elseif($row->COL_VUCC_GRIDS != null) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - if (count($grids) == 2) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - if (count($grids) == 4) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - $grid3 = $this->qra->qra2latlong(trim($grids[2])); - $grid4 = $this->qra->qra2latlong(trim($grids[3])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); - $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - - } - - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - } - - $count++; - } else { - $query = $this->db->query(' - SELECT * - FROM dxcc_entities - WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) ) - ORDER BY LENGTH( prefix ) DESC - LIMIT 1 - '); - - foreach ($query->result() as $dxcc) { - if($count != 1) { - echo ","; - } - echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}"; - $count++; - } - } - - } - echo "]"; - - // [MAP Custom] ADD Station // - $this->load->model('Stations'); - $station_json = $this->Stations->get_station_json_for_map(); - echo (!empty($station_json))?', '.$station_json:''; - - echo "}"; - - } } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index bf931685..edeb3823 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -740,7 +740,7 @@ function showActivatorsMap(call, count, grids) { var q_lng = -32.695312; - var qso_loc = '//input->post('band')); ?>/input->post('mode')); ?>/input->post('prop_mode')); ?>'; + var qso_loc = ''; var q_zoom = 3; $(document).ready(function(){ @@ -749,7 +749,10 @@ function showActivatorsMap(call, count, grids) { var grid = "No"; - initmap(grid, 'custommap'); + var customdata = {'dataPost':{'date_from':'', 'date_to':'', + 'band':'input->post('band'); ?>', 'mode':'input->post('mode'); ?>', + 'prop_mode':'input->post('prop_mode'); ?>', 'isCustom':true }} + initmap(grid, 'custommap', customdata); }); @@ -771,7 +774,7 @@ function showActivatorsMap(call, count, grids) { var q_lng = -32.695312; - var qso_loc = ''; + var qso_loc = ''; var q_zoom = 2; $(document).ready(function(){ @@ -780,7 +783,7 @@ function showActivatorsMap(call, count, grids) { var grid = "No"; - initmap(grid); + initmap(grid,'map',{'dataPost':{'isFull':true}}); }); @@ -803,7 +806,7 @@ function showActivatorsMap(call, count, grids) { var q_lng = -32.695312; - var qso_loc = ''; + var qso_loc = ''; var q_zoom = 3; $(document).ready(function(){ @@ -812,7 +815,7 @@ function showActivatorsMap(call, count, grids) { var grid = "No"; - initmap(grid); + initmap(grid,'map',{'dataPost':{'nb_qso':'18'}}); }); @@ -1002,7 +1005,7 @@ $(document).on('keypress',function(e) { var q_lng = -32.695312; - var qso_loc = 'uri->segment(3)); ?>'; + var qso_loc = ''; var q_zoom = 3; config->item('map_gridsquares') != FALSE) { ?> @@ -1010,7 +1013,7 @@ $(document).on('keypress',function(e) { var grid = "No"; - initmap(grid); + initmap(grid,'map',{'dataPost':{'nb_qso':'25','offset':'uri->segment(3); ?>'}}); From 4fda258b1458adcf9a6ac60b0c33db53c463250f Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 08:19:07 +0100 Subject: [PATCH 03/10] fix highlight line on map (again) --- application/views/map/qsos.php | 2 +- application/views/visitor/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/views/map/qsos.php b/application/views/map/qsos.php index 4086c7ab..85790de6 100644 --- a/application/views/map/qsos.php +++ b/application/views/map/qsos.php @@ -10,6 +10,6 @@ -
+
\ No newline at end of file diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 06d24322..f8974ac5 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -48,7 +48,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { -
+
From 12efffeb41d45541a7e86a7c39b878aef67fa2cf Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 14:10:09 +0100 Subject: [PATCH 04/10] no limit for full station list --- application/controllers/Map.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index adb37a01..07e612db 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -112,7 +112,8 @@ class Map extends CI_Controller { $prop_mode = $this->input->post('prop_mode'); $qsos = $this->logbook_model->map_custom_qsos($date_from, $date_to, $band, $mode, $prop_mode); } else if ($this->input->post('isFull') == true) { - $qsos = $this->logbook_model->get_qsos(100000,0); // limited at 100000 (perhaps is too big for list of plot on map ?) // + $station_id = $this->Stations->find_active(); + $qsos = $this->logbook_model->get_qsos(null,null,array($station_id)); // no limit for full // } else { $nb_qso = (intval($this->input->post('nb_qso'))>0)?$this->input->post('nb_qso'):25; $offset = (intval($this->input->post('offset'))>0)?$this->input->post('offset'):0; From fae3c8a86e4b33a8ed8396c8631e82f0e6903f1d Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 14:54:13 +0100 Subject: [PATCH 05/10] secure post value --- application/controllers/Map.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 07e612db..28427f1d 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -105,18 +105,18 @@ class Map extends CI_Controller { // set informations // if ($this->input->post('isCustom') == true) { - $date_from = $this->input->post('date_from'); - $date_to = $this->input->post('date_to'); - $band = $this->input->post('band'); - $mode = $this->input->post('mode'); - $prop_mode = $this->input->post('prop_mode'); + $date_from = xss_clean($this->input->post('date_from')); + $date_to = xss_clean($this->input->post('date_to')); + $band = xss_clean($this->input->post('band')); + $mode = xss_clean($this->input->post('mode')); + $prop_mode = xss_clean($this->input->post('prop_mode')); $qsos = $this->logbook_model->map_custom_qsos($date_from, $date_to, $band, $mode, $prop_mode); } else if ($this->input->post('isFull') == true) { $station_id = $this->Stations->find_active(); $qsos = $this->logbook_model->get_qsos(null,null,array($station_id)); // no limit for full // } else { - $nb_qso = (intval($this->input->post('nb_qso'))>0)?$this->input->post('nb_qso'):25; - $offset = (intval($this->input->post('offset'))>0)?$this->input->post('offset'):0; + $nb_qso = (intval($this->input->post('nb_qso'))>0)?xss_clean($this->input->post('nb_qso')):18; + $offset = (intval($this->input->post('offset'))>0)?xss_clean($this->input->post('offset')):null; $qsos = $this->logbook_model->get_qsos($nb_qso, $offset); } // [PLOT] ADD plot // From d4e5a6ab88d3f52f3246fcc06da1029cb5cc550f Mon Sep 17 00:00:00 2001 From: abarrau Date: Tue, 12 Dec 2023 14:58:55 +0100 Subject: [PATCH 06/10] simplify visitor map function --- application/controllers/Map.php | 2 +- application/controllers/Visitor.php | 92 ++-------------------------- application/models/Logbook_model.php | 8 ++- 3 files changed, 12 insertions(+), 90 deletions(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 28427f1d..7218938b 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -99,7 +99,7 @@ class Map extends CI_Controller { } // Generic fonction for return Json for MAP // - function map_plot_json() { + public function map_plot_json() { $this->load->model('Stations'); $this->load->model('logbook_model'); diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 8895280b..92fe41d3 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -161,92 +161,12 @@ class Visitor extends CI_Controller { show_404('Unknown Public Page.'); } - $qsos = $this->logbook_model->get_last_qsos('18', $logbooks_locations_array); - header('Content-Type: application/json; charset=utf-8'); - echo "{\"markers\": ["; - $count = 1; - foreach ($qsos->result() as $row) { - //print_r($row); - $begindate=date('d/m/y', strtotime($row->COL_TIME_ON)); - if($row->COL_GRIDSQUARE != null) { - $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE); - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date: ".$begindate."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date: ".$begindate."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\"}"; - } - - $count++; - } elseif($row->COL_VUCC_GRIDS != null) { - - $grids = explode(",", $row->COL_VUCC_GRIDS); - if (count($grids) == 2) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - if (count($grids) == 4) { - $grid1 = $this->qra->qra2latlong(trim($grids[0])); - $grid2 = $this->qra->qra2latlong(trim($grids[1])); - $grid3 = $this->qra->qra2latlong(trim($grids[2])); - $grid4 = $this->qra->qra2latlong(trim($grids[3])); - - $coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]); - $coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]); - $coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]); - $coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]); - - $stn_loc = $this->qra->get_midpoint($coords); - } - - if($count != 1) { - echo ","; - } - - if($row->COL_SAT_NAME != null) { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date: ".$begindate."
SAT: ".$row->COL_SAT_NAME."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\"}"; - } else { - echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date: ".$begindate."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\"}"; - } - - $count++; - - } else { - if($count != 1) { - echo ","; - } - - if(isset($row->lat) && isset($row->long)) { - $lat = $row->lat; - $lng = $row->long; - } - - echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date: ".$begindate."
Band: ".$row->COL_BAND."
Mode: "; - echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; - echo "\",\"label\":\"".$row->COL_CALL."\"}"; - $count++; - } - - } - echo "]"; - echo "}"; - + $qsos = $this->logbook_model->get_qsos('18', null, $logbooks_locations_array); + // [PLOT] ADD plot // + $plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result()); + + header('Content-Type: application/json; charset=utf-8'); + echo json_encode($plot_array); } public function satellites() diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 7c74fd67..9dfca72b 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4481,7 +4481,7 @@ function lotw_last_qsl_date($user_id) { } // [JSON PLOT] return array for plot qso for map // - public function get_plot_array_for_map($qsos_result) { + public function get_plot_array_for_map($qsos_result, $isVisitor=false) { $this->load->library('qra'); $json["markers"] = array(); @@ -4495,8 +4495,10 @@ function lotw_last_qsl_date($user_id) { $plot['html'] .= "Mode: ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)."
"; // check if qso is confirmed // - if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { - $plot['confirmed'] = "Y"; + if (!$isVisitor) { + if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { + $plot['confirmed'] = "Y"; + } } // check lat / lng (depend info source) // if ($row->COL_GRIDSQUARE != null) { From 8fd7712455da10c561970fbc9802b985eb38ae4a Mon Sep 17 00:00:00 2001 From: abarrau Date: Wed, 13 Dec 2023 07:10:10 +0100 Subject: [PATCH 07/10] simplify form custom map search --- application/controllers/Map.php | 17 ++------- application/views/interface_assets/footer.php | 17 ++++++--- application/views/map/custom_date.php | 16 ++++++--- assets/js/leaflet/leafembed.js | 35 +++++++++++-------- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 7218938b..717648e3 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -79,23 +79,12 @@ class Map extends CI_Controller { $data['logbook_name'] = $logbook_name; $data['page_title'] = "Map QSOs"; - if ($this->input->post('from')) { - $from = $this->input->post('from'); - $footer_data['date_from'] = $from; - } else { - $footer_data['date_from'] = date('Y-m-d H:i:00'); - } - if ($this->input->post('to')) { - $to = $this->input->post('to'); - $footer_data['date_to'] = $to; - } else { - $temp_to = new DateTime('tomorrow'); - $footer_data['date_to'] = $temp_to->format('Y-m-d H:i:00'); - } + $data['date_from'] = date('Y-m-d'); + $data['date_to'] = date('Y-m-d', strtotime($data['date_from'].' +1days')); $this->load->view('interface_assets/header', $data); $this->load->view('map/custom_date'); - $this->load->view('interface_assets/footer',$footer_data); + $this->load->view('interface_assets/footer'); } // Generic fonction for return Json for MAP // diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index edeb3823..62078e78 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -749,10 +749,19 @@ function showActivatorsMap(call, count, grids) { var grid = "No"; - var customdata = {'dataPost':{'date_from':'', 'date_to':'', - 'band':'input->post('band'); ?>', 'mode':'input->post('mode'); ?>', - 'prop_mode':'input->post('prop_mode'); ?>', 'isCustom':true }} - initmap(grid, 'custommap', customdata); + initmap(grid, 'custommap', {'initmap_only':true}); + // Form "submit" // + $('.custom-map-QSOs .btn_submit_map_custom').off('click').on('click',function() { + if ($('.custom-map-QSOs input[name="from"]').val().replaceAll('-','') <= $('.custom-map-QSOs input[name="to"]').val().replaceAll('-','')) { + var customdata = {'dataPost':{'date_from': $('.custom-map-QSOs input[name="from"]').val(), 'date_to': $('.custom-map-QSOs input[name="to"]').val(), + 'band': $('.custom-map-QSOs select[name="band"]').val(), 'mode': $('.custom-map-QSOs select[name="mode"]').val(), + 'prop_mode': $('.custom-map-QSOs select[name="prop_mode"]').val(), 'isCustom':true }, 'map_id':'#custommap'}; + initplot(qso_loc, customdata); + } else { + // TODO + } + }) + }); diff --git a/application/views/map/custom_date.php b/application/views/map/custom_date.php index ead97d0f..a5556b3b 100644 --- a/application/views/map/custom_date.php +++ b/application/views/map/custom_date.php @@ -12,12 +12,12 @@
- +
- +
@@ -81,13 +81,19 @@
- -

+
+
+ +
+
+ +
+
-
+
\ No newline at end of file diff --git a/assets/js/leaflet/leafembed.js b/assets/js/leaflet/leafembed.js index e76678ba..ff6c908f 100644 --- a/assets/js/leaflet/leafembed.js +++ b/assets/js/leaflet/leafembed.js @@ -9,6 +9,7 @@ var redIconImg = L.icon({ iconUrl: icon_dot_url, iconSize: [10, 10] }); // old / var osmUrl = $('#leafembed').attr("tileUrl"); +// function to initialise map (can called alone, without plot) // function initmap(ShowGrid='No', MapTag='map', options={}) { // set up the map map = new L.Map(MapTag); @@ -38,23 +39,29 @@ function initmap(ShowGrid='No', MapTag='map', options={}) { var layerControl = new L.Control.Layers(null, { 'Gridsquares': maidenhead = L.maidenhead() }).addTo(map); if(ShowGrid == "Yes") { maidenhead.addTo(map); } + if ((typeof options.initmap_only=="undefined") || (options.initmap_only!=true)) { initplot(_url_qso, options); } +} + +// function to initialise plot on map - Don't forget the "map_id" arg on options, if call alone // +function initplot(_url_qso, options={}) { //console.log(_url_qso); // get map custon infos // - var _visitor = (typeof visitor==="undefined")?false:visitor; - if (_visitor) { - askForPlots(_url_qso, options); - } else { - $.ajax({ - url: base_url+'index.php/user_options/get_map_custom', type: 'GET', dataType: 'json', - error: function() { askForPlots(_url_qso, options); console.log('[ERROR] ajax get_map_custom() function return error.'); }, - success: function(json_mapinfo) { - if (typeof json_mapinfo.qso !== "undefined") { iconsList = json_mapinfo; } - if(json_mapinfo.gridsquare_show == "1") { maidenhead.addTo(map); } - askForPlots(_url_qso, options); - } - }); + if (_url_qso != '') { + var _visitor = (typeof visitor==="undefined")?false:visitor; + if (_visitor) { + askForPlots(_url_qso, options); + } else { + $.ajax({ + url: base_url+'index.php/user_options/get_map_custom', type: 'GET', dataType: 'json', + error: function() { askForPlots(_url_qso, options); console.log('[ERROR] ajax get_map_custom() function return error.'); }, + success: function(json_mapinfo) { + if (typeof json_mapinfo.qso !== "undefined") { iconsList = json_mapinfo; } + if(json_mapinfo.gridsquare_show == "1") { maidenhead.addTo(map); } + askForPlots(_url_qso, options); + } + }); + } } - } function askForPlots(_url_qso, options={}) { From 0143e79fa61fe367a607ade188169d3acb1437bf Mon Sep 17 00:00:00 2001 From: abarrau Date: Wed, 13 Dec 2023 22:54:04 +0100 Subject: [PATCH 08/10] on map custom, date to can't be big than date from --- application/controllers/Map.php | 3 +-- application/models/Logbook_model.php | 2 +- application/views/interface_assets/footer.php | 23 ++++++++++++------- application/views/map/custom_date.php | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 717648e3..5fffb50d 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -79,8 +79,7 @@ class Map extends CI_Controller { $data['logbook_name'] = $logbook_name; $data['page_title'] = "Map QSOs"; - $data['date_from'] = date('Y-m-d'); - $data['date_to'] = date('Y-m-d', strtotime($data['date_from'].' +1days')); + $data['date_from'] = $data['date_to'] = date('Y-m-d'); $this->load->view('interface_assets/header', $data); $this->load->view('map/custom_date'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 9dfca72b..765bf4cd 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2113,7 +2113,7 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = } $this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left'); - $this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'"); + $this->db->where("COL_TIME_ON BETWEEN '".$start." 00:00:00' AND '".$end." 23:59:59'"); $this->db->where_in("station_id", $logbooks_locations_array); if($band != "All" && $band != "SAT") { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index ba981d84..0b76acfd 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -750,16 +750,23 @@ function showActivatorsMap(call, count, grids) { var grid = "No"; initmap(grid, 'custommap', {'initmap_only':true}); + // Check and change date if to < from // + $('.custom-map-QSOs input[name="to"]').off('change').on('change', function() { + if ($('.custom-map-QSOs input[name="to"]').val().replaceAll('-','') < $('.custom-map-QSOs input[name="from"]').val().replaceAll('-','')) { + $('.custom-map-QSOs input[name="from"]').val($('.custom-map-QSOs input[name="to"]').val()); + } + }); + $('.custom-map-QSOs input[name="from"]').off('change').on('change', function() { + if ($('.custom-map-QSOs input[name="from"]').val().replaceAll('-','') > $('.custom-map-QSOs input[name="to"]').val().replaceAll('-','')) { + $('.custom-map-QSOs input[name="to"]').val($('.custom-map-QSOs input[name="from"]').val()); + } + }); // Form "submit" // $('.custom-map-QSOs .btn_submit_map_custom').off('click').on('click',function() { - if ($('.custom-map-QSOs input[name="from"]').val().replaceAll('-','') <= $('.custom-map-QSOs input[name="to"]').val().replaceAll('-','')) { - var customdata = {'dataPost':{'date_from': $('.custom-map-QSOs input[name="from"]').val(), 'date_to': $('.custom-map-QSOs input[name="to"]').val(), - 'band': $('.custom-map-QSOs select[name="band"]').val(), 'mode': $('.custom-map-QSOs select[name="mode"]').val(), - 'prop_mode': $('.custom-map-QSOs select[name="prop_mode"]').val(), 'isCustom':true }, 'map_id':'#custommap'}; - initplot(qso_loc, customdata); - } else { - // TODO - } + var customdata = {'dataPost':{'date_from': $('.custom-map-QSOs input[name="from"]').val(), 'date_to': $('.custom-map-QSOs input[name="to"]').val(), + 'band': $('.custom-map-QSOs select[name="band"]').val(), 'mode': $('.custom-map-QSOs select[name="mode"]').val(), + 'prop_mode': $('.custom-map-QSOs select[name="prop_mode"]').val(), 'isCustom':true }, 'map_id':'#custommap'}; + initplot(qso_loc, customdata); }) diff --git a/application/views/map/custom_date.php b/application/views/map/custom_date.php index a5556b3b..ecc255df 100644 --- a/application/views/map/custom_date.php +++ b/application/views/map/custom_date.php @@ -17,7 +17,7 @@
- +
From 30fd69d805e5645b0ba4ed3dd22d3656161c1c8b Mon Sep 17 00:00:00 2001 From: abarrau Date: Thu, 21 Dec 2023 08:37:29 +0100 Subject: [PATCH 09/10] fix for confirm QSL --- application/models/Logbook_model.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 3e3415b7..2e09c4ef 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4517,9 +4517,10 @@ function lotw_last_qsl_date($user_id) { $this->load->library('qra'); $json["markers"] = array(); - $plot = array('lat'=>0, 'lng'=>0, 'html'=>'', 'label'=>'', 'confirmed'=>'N'); - + foreach ($qsos_result as $row) { + $plot = array('lat'=>0, 'lng'=>0, 'html'=>'', 'label'=>'', 'confirmed'=>'N'); + $plot['label'] = $row->COL_CALL; $plot['html'] = "Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
"; From fb21c33a1a6890c7cb8b61285d097b01d64c59b3 Mon Sep 17 00:00:00 2001 From: abarrau Date: Wed, 27 Dec 2023 20:10:45 +0100 Subject: [PATCH 10/10] remove /map (not used) --- application/controllers/Map.php | 31 ++----------------- application/models/Logbook_model.php | 14 --------- application/views/interface_assets/footer.php | 31 ------------------- 3 files changed, 2 insertions(+), 74 deletions(-) diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 5fffb50d..456b23cb 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -3,32 +3,8 @@ class Map extends CI_Controller { - function index() - { - - // Calculate Lat/Lng from Locator to use on Maps - if($this->session->userdata('user_locator')) { - $this->load->library('qra'); - - $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); - $data['qra'] = "set"; - $data['qra_lat'] = $qra_position[0]; - $data['qra_lng'] = $qra_position[1]; - } else { - $data['qra'] = "none"; - } - - $this->load->model('Stations'); - $station_id = $this->Stations->find_active(); - $station_data = $this->Stations->profile_clean($station_id); - - // load the view - $data['station_profile'] = $station_data; - $data['page_title'] = "Map QSOs"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('map/qsos'); - $this->load->view('interface_assets/footer'); + function index() { + redirect('map/custom'); } function custom() @@ -99,9 +75,6 @@ class Map extends CI_Controller { $mode = xss_clean($this->input->post('mode')); $prop_mode = xss_clean($this->input->post('prop_mode')); $qsos = $this->logbook_model->map_custom_qsos($date_from, $date_to, $band, $mode, $prop_mode); - } else if ($this->input->post('isFull') == true) { - $station_id = $this->Stations->find_active(); - $qsos = $this->logbook_model->get_qsos(null,null,array($station_id)); // no limit for full // } else { $nb_qso = (intval($this->input->post('nb_qso'))>0)?xss_clean($this->input->post('nb_qso')):18; $offset = (intval($this->input->post('offset'))>0)?xss_clean($this->input->post('offset')):null; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2e09c4ef..c7b67846 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2223,20 +2223,6 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = } } - /* Return QSOs for the year for the active profile */ - function map_all_qsos_for_active_station_profile() { - $CI =& get_instance(); - $CI->load->model('stations'); - $station_id = $CI->stations->find_active(); - - $this->db->where("station_id", $station_id); - $this->db->order_by("COL_TIME_ON", "ASC"); - $query = $this->db->get($this->config->item('table_name')); - - return $query; - } - - /* Return QSOs made during the current Year */ function year_qsos($StationLocationsArray = null, $api_key = null) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index e8e27b91..6fd88b70 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -762,37 +762,6 @@ function showActivatorsMap(call, count, grids) { -uri->segment(1) == "map" && $this->uri->segment(2) == "") { ?> - - - - - uri->segment(1) == "" || $this->uri->segment(1) == "dashboard" ) { ?>