simplify form custom map search

pull/2810/head
abarrau 2023-12-13 07:10:10 +01:00
rodzic d4e5a6ab88
commit 8fd7712455
4 zmienionych plików z 48 dodań i 37 usunięć

Wyświetl plik

@ -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 //

Wyświetl plik

@ -749,10 +749,19 @@ function showActivatorsMap(call, count, grids) {
<?php } else { ?>
var grid = "No";
<?php } ?>
var customdata = {'dataPost':{'date_from':'<?php echo $date_from; ?>', 'date_to':'<?php echo $date_to; ?>',
'band':'<?php echo $this->input->post('band'); ?>', 'mode':'<?php echo $this->input->post('mode'); ?>',
'prop_mode':'<?php echo $this->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
}
})
});
</script>

Wyświetl plik

@ -12,12 +12,12 @@
<div class="row">
<div class="mb-3 col-md-3">
<label for="from"><?php echo lang('gen_from_date') . ": " ?></label>
<input name="from" id="from" type="date" class="form-control w-auto">
<input name="from" id="from" type="date" class="form-control w-auto" value="<?php echo $date_from; ?>">
</div>
<div class="mb-3 col-md-3">
<label for="to"><?php echo lang('gen_to_date') . ": " ?></label>
<input name="to" id="to" type="date" class="form-control w-auto">
<input name="to" id="to" type="date" class="form-control w-auto" value="<?php echo $date_to; ?>">
</div>
</div>
@ -81,13 +81,19 @@
</div>
</div>
<input class="btn btn-primary" type="submit" value="Load Map">
<br><br>
<div class="row">
<div class="mb-1 col-md-1">
<input class="btn btn-primary btn_submit_map_custom" type="button" value="Load Map">
</div>
<div class="mb-4 col-md-4">
<div class="alert alert-danger warningOnSubmit" style="display:none;"><span><i class="fas fa-times-circle"></i></span> <span class="warningOnSubmit_txt ms-1">Error</span></div>
</div>
</div>
</form>
</div>
<!-- Map -->
<div id="custommap" class="map-leaflet" style="width: 100%; height: calc(100vh - 380px); max-height: 900px;"></div>
<div id="custommap" class="map-leaflet mt-2" style="width: 100%; height: calc(100vh - 390px); max-height: 900px;"></div>
<div class="alert alert-success" role="alert">Showing QSOs for Custom Date for Active Logbook <?php echo $logbook_name ?></div>

Wyświetl plik

@ -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={}) {