From 8fd7712455da10c561970fbc9802b985eb38ae4a Mon Sep 17 00:00:00 2001 From: abarrau Date: Wed, 13 Dec 2023 07:10:10 +0100 Subject: [PATCH] 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={}) {