From fa48db4263f72a7a3ad0158db522f79d3de48fe5 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 7 Dec 2020 17:28:19 +0000 Subject: [PATCH] [Map][Custom] /map/custom you can select to dates to map QSOs --- application/controllers/Map.php | 99 +++++++++++++++++++ application/views/interface_assets/footer.php | 36 ++++++- application/views/map/custom_date.php | 42 ++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 application/views/map/custom_date.php diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 121f1576..451d88cc 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -31,6 +31,105 @@ class Map extends CI_Controller { $this->load->view('interface_assets/footer'); } + function custom() + { + + // 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"; + + + if ($this->input->post('from')) { + $from = $this->input->post('from'); + $from = DateTime::createFromFormat('m/d/Y g:i A', $from); + $from = $from->format('Y-m-d'); + $footer_data['date_from'] = $from; + } else { + $footer_data['date_from'] = date('Y-m-d'); + } + if ($this->input->post('to')) { + $to = DateTime::createFromFormat('m/d/Y g:i A', $this->input->post('to')); + $to = $to->modify('+1 day')->format('Y-m-d'); + $footer_data['date_to'] = $to; + } else { + $temp_to = new DateTime('tomorrow'); + $footer_data['date_to'] = $temp_to->format('Y-m-d'); + } + + + $this->load->view('interface_assets/header', $data); + $this->load->view('map/custom_date'); + $this->load->view('interface_assets/footer',$footer_data); + } + + + function map_data_custom() { + $start_date = $this->uri->segment(3); + $end_date = $this->uri->segment(4); + $this->load->model('logbook_model'); + + $this->load->library('qra'); + + $qsos = $this->logbook_model->map_week_qsos($start_date, $end_date); + + echo "{\"markers\": ["; + $count = 1; + foreach ($qsos->result() as $row) { + //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."\"}"; + } 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."\"}"; + } + + $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."\"}"; + $count++; + } + } + + } + echo "]"; + echo "}"; + + } + function map_data() { $this->load->model('logbook_model'); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 5b6bde7f..96d3653e 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -142,7 +142,41 @@ $('[data-fancybox]').fancybox({ -uri->segment(1) == "map") { ?> +uri->segment(1) == "map" && $this->uri->segment(2) == "custom") { ?> + + + + + + + + +uri->segment(1) == "map" && $this->uri->segment(2) == "") { ?>