Added list to award

This commit is contained in:
Andreas Kristiansen
2024-04-21 09:02:18 +02:00
parent 6e6a2d7075
commit 67de9fcb5a
5 changed files with 151 additions and 11 deletions

View File

@@ -1538,7 +1538,6 @@ class Awards extends CI_Controller {
$qrz = $this->security->xss_clean($this->input->post('qrz'));
$sat = $this->security->xss_clean($this->input->post('sat'));
$orbit = $this->security->xss_clean($this->input->post('orbit'));
$this->load->model('gridmap_model');
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
@@ -1557,4 +1556,36 @@ class Awards extends CI_Controller {
echo json_encode($wab_array);
}
public function wab_list() {
$band = $this->security->xss_clean($this->input->post('band'));
$mode = $this->security->xss_clean($this->input->post('mode'));
$qsl = $this->security->xss_clean($this->input->post('qsl'));
$lotw = $this->security->xss_clean($this->input->post('lotw'));
$eqsl = $this->security->xss_clean($this->input->post('eqsl'));
$qrz = $this->security->xss_clean($this->input->post('qrz'));
$sat = $this->security->xss_clean($this->input->post('sat'));
$orbit = $this->security->xss_clean($this->input->post('orbit'));
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->load->model('wab');
if ($logbooks_locations_array) {
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$wab_array = $this->wab->get_wab_list($band, $location_list, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
} else {
$location_list = null;
$wab_array = null;
}
$data['wab_array'] = $wab_array;
$data['postdata']['band'] = $band;
$data['postdata']['mode'] = $mode;
$data['postdata']['sat'] = $sat;
$data['postdata']['orbit'] = $orbit;
$this->load->view('awards/wab/list', $data);
}
}

View File

@@ -40,6 +40,42 @@ class Wab extends CI_Model {
return $wabarray;
}
function get_wab_list($band, $location_list, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit) {
$worked = array();
$confirmed = array();
$worked = $this->getWabWorked($location_list, $band, $mode, $sat, $orbit);
$confirmed = $this->getWabConfirmed($location_list, $band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit);
$wabarray = array();
$workedGridArray = array();
foreach ($worked as $w) {
array_push($workedGridArray, $w->col_sig_info);
$wabarray += array(
$w->col_sig_info => 'W'
);
}
$confirmedGridArray = array();
foreach ($confirmed as $c) {
array_push($confirmedGridArray, $c->col_sig_info);
if(array_key_exists($c->col_sig_info, $wabarray)){
$wabarray[$c->col_sig_info] = 'C';
} else {
$wabarray += array(
$c->col_sig_info => 'C'
);
}
}
ksort($wabarray);
return $wabarray;
}
/*
* Function returns all worked, but not confirmed states
* $postdata contains data from the form, in this case Lotw or QSL are used

View File

@@ -88,7 +88,7 @@
<label class="form-check-label" for="eqsl">eQSL</label>
</div>
<div class="form-check-inline">
<?php echo '<input class="form-check-input" type="checkbox" name="qrz" id="qrz"';
<?php echo '<input class="form-check-input" type="checkbox" name="qrz" id="qrz"';
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) {
echo ' checked' ;
}
@@ -97,7 +97,8 @@
</div>
</div>
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="plotmap()"><?php echo lang('gridsquares_button_plot'); ?><div class="ld ld-ring ld-spin"></div></button>
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="plotmap()">Map<div class="ld ld-ring ld-spin"></div></button>
<button id="list" type="button" name="list" class="btn btn-primary me-1 ld-ext-right ld-ext-right-list" onclick="showlist()">List<div class="ld ld-ring ld-spin"></div></button>
</form>
</div>
<div id="mapcontainer">

View File

@@ -0,0 +1,19 @@
<div class="container">
<table style="width:100%" class="wabtable table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th class="select-filter" scope="col">WAB Square</th>
<th class="select-filter" scope="col">Confirmed</th>
</tr>
</thead>
<tbody>
<?php foreach ($wab_array as $wab => $key) { ?>
<tr>
<td style="text-align: center; vertical-align: middle;" ><?php echo '<a href=\'javascript:displayContacts("'. $wab .'","'. $postdata['band'] . '","' . $postdata['sat'] . '","' . $postdata['orbit'] . '","' . $postdata['mode'] . '","WAB")\'>'. $wab; ?></td>
<td style="text-align: center; vertical-align: middle;" ><?php echo $key == 'W' ? 'Yes' : 'No'; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>

View File

@@ -24,7 +24,64 @@ var wab_squares = $.ajax({
}
})
function showlist() {
$(".ld-ext-right-list").addClass('running');
$(".ld-ext-right-list").prop('disabled', true);
$('#list').prop("disabled", true);
$.ajax({
url: site_url + '/awards/wab_list',
type: 'post',
data: {
band: $("#band").val(),
mode: $("#mode").val(),
qsl: $("#qsl").is(":checked"),
lotw: $("#lotw").is(":checked"),
eqsl: $("#eqsl").is(":checked"),
qrz: $("#qrz").is(":checked"),
sat: $("#sats").val(),
orbit: $("#orbits").val(),
},
success: function (data) {
wablist(data);
},
error: function (data) {
},
})
}
function wablist(data) {
$('#wablist').remove();
var container = L.DomUtil.get('wabmap');
if(container != null){
container._leaflet_id = null;
container.remove();
}
$("#mapcontainer").append('<div id="wablist"></div>');
$("#wablist").append(data);
$(".ld-ext-right-list").removeClass('running');
$(".ld-ext-right-list").prop('disabled', false);
$('#list').prop("disabled", false);
$('.wabtable').DataTable({
"pageLength": 25,
responsive: false,
ordering: false,
"scrollY": "550px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
"language": {
url: getDataTablesLanguageUrl(),
},
dom: 'Bfrtip',
buttons: [
'csv'
]
});
}
function plotmap() {
$('#wablist').remove();
$(".ld-ext-right-plot").addClass('running');
$(".ld-ext-right-plot").prop('disabled', true);
$('#plot').prop("disabled", true);
@@ -55,8 +112,8 @@ function wabmap(data) {
if(container != null){
container._leaflet_id = null;
container.remove();
$("#mapcontainer").append('<div id="wabmap" style="width: 100%; height: 85vh;"></div>');
}
$("#mapcontainer").append('<div id="wabmap" style="width: 100%; height: 85vh;"></div>');
$(".ld-ext-right-plot").removeClass('running');
$(".ld-ext-right-plot").prop('disabled', false);
@@ -66,7 +123,7 @@ function wabmap(data) {
fullscreenControlOptions: {
position: 'topleft'
},
}).setView([51.5074, -0.1278], 9);
}).setView([51.5074, -1], 9);
var confirmedcount = 0;
var workedcount = 0;
@@ -114,7 +171,7 @@ function wabmap(data) {
onEachFeature: function(feature, layer) {
layer.on('click', function() {
// Code to execute when the area is clicked
displayContactsOnMap($("#wabmap"), feature.properties.name, 'All', 'All', 'All', 'All', 'WAB');
displayContactsOnMap($("#wabmap"), feature.properties.name, $('#band').val(), $('#sats').val(), $('#orbits').val(), $('#mode').val(), 'WAB');
});
}
}).addTo(map);
@@ -158,8 +215,4 @@ function wabmap(data) {
};
legend.addTo(map);
};
$(document).ready(function(){
plotmap();
})
};