Implement GEO/MEO/LEO logic for callstats

This commit is contained in:
phl0
2025-01-20 10:29:02 +01:00
parent 5157ffbd18
commit c95edbb185
4 changed files with 80 additions and 72 deletions

View File

@@ -36,7 +36,7 @@ class Callstats extends CI_Controller
if ($this->input->post('propagation') != NULL) { // Propagation is not set when page first loads.
$propagation = $this->input->post('propagation',true);
} else {
$propagation = 'All';
$propagation = '';
}
if ($this->input->post('mincount') != NULL) { // mincount is not set when page first loads.
@@ -45,10 +45,10 @@ class Callstats extends CI_Controller
$mincount = 2;
}
if ($this->input->post('leogeo') != NULL) { // orbit is not set when page first loads.
$orbit = $this->input->post('leogeo',true);
if ($this->input->post('orbit') != NULL) { // orbit is not set when page first loads.
$orbit = $this->input->post('orbit',true);
} else {
$orbit = 'both';
$orbit = 'All';
}
@@ -61,6 +61,7 @@ class Callstats extends CI_Controller
$data['sats'] = $this->bands->get_worked_sats();
$data['worked_bands'] = $this->bands->get_worked_bands();
$data['worked_modes'] = $this->Callstats_model->get_worked_modes();
$data['orbits'] = $this->bands->get_worked_orbits();
$data['mincount'] = $mincount;
$data['maxactivatedgrids'] = $this->Callstats_model->get_max_qsos();
$data['orbit'] = $orbit;
@@ -97,7 +98,7 @@ class Callstats extends CI_Controller
// Render Page
$data['page_title'] = __("Log View");
$data['filter'] = $searchphrase.__(" and band ").$band . __(" and mode ").$mode . __(" and satellite ").$sat . __(" and orbit ").$orbit . __(" and propagation ").$propagation;
$data['filter'] = $searchphrase.__(" and band ").$band;
if ($band == 'SAT') {
if ($sat != 'All' && $sat != null) {
$data['filter'] .= __(" and sat ").$sat;

View File

@@ -10,7 +10,7 @@ class Callstats_model extends CI_Model {
$this->logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
}
function get_activators($band, $mode, $propagation, $mincount, $leogeo, $sat) {
function get_activators($band, $mode, $propagation, $mincount, $orbit, $sat) {
if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) {
$mincount = 2;
@@ -27,39 +27,37 @@ class Callstats_model extends CI_Model {
`col_call` as `call`,
COUNT(*) as `count`
from " . $this->config->item('table_name') . "
left join satellite on ".$this->config->item('table_name').".COL_SAT_NAME = satellite.name
where station_id in (" . $location_list . ")";
if ($band != 'All') {
$binding[] = $band;
if ($band == 'SAT') {
switch ($leogeo) {
case 'both':
$sql .= " and col_prop_mode = ?";
break;
case 'leo':
$sql .= " and col_prop_mode = ?";
$sql .= " and col_sat_name != 'QO-100'";
break;
case 'geo':
$sql .= " and col_prop_mode = ?";
$sql .= " and col_sat_name = 'QO-100'";
break;
default:
$sql .= " and col_prop_mode = ?";
break;
}
if ($sat != 'All') {
$sql .= " and col_prop_mode = ? ";
$binding[] = $band;
if ($sat != 'All' && $sat != '') {
$sql .= " and col_sat_name = ?";
$binding[] = $sat;
}
} else {
$sql .= " and col_prop_mode != 'SAT'";
$sql .= " and COL_BAND = ?";
if ($propagation == 'None') {
$sql .= " and (trim(col_prop_mode) = '' or col_prop_mode is null)";
} elseif ($propagation == 'NoSAT') {
$sql .= " and col_prop_mode != 'SAT'";
} elseif ($propagation != '') {
$sql .= " and col_prop_mode = ?";
$binding[] = $propagation;
}
$sql .= " and col_band = ?";
$binding[] = $band;
}
} else {
if ($propagation == 'None') {
$sql .= " and (trim(col_prop_mode) = '' or col_prop_mode is null)";
} elseif ($propagation == 'NoSAT') {
$sql .= " and col_prop_mode != 'SAT'";
} elseif ($propagation != '') {
$sql .= " and col_prop_mode = ?";
$binding[] = $propagation;
}
}
if (($propagation ?? 'All') != 'All') {
$this->db->where("COL_PROP_MODE = ?");
$binding[] = $propagation;
}
if ($mode != 'All') {
@@ -68,6 +66,11 @@ class Callstats_model extends CI_Model {
$binding[] = $mode;
}
if ($orbit != 'All') {
$sql .= " AND satellite.orbit = ?";
$binding[] = $orbit;
}
$sql .= "
group by `col_call`
having `count` >= ?
@@ -158,11 +161,11 @@ class Callstats_model extends CI_Model {
}
}
if ($orbit != 'both') {
if ($orbit != 'All') {
$this->db->where('orbit', $orbit);
}
if ($propagation != 'All') {
if ($propagation != '') {
if ($propagation == 'None') {
$this->db->where('COL_PROP_MODE', '');
} else if ($propagation == 'NoSAT') {

View File

@@ -3,18 +3,20 @@
<form class="form" action="<?php echo site_url('callstats'); ?>" method="post" enctype="multipart/form-data">
<!-- Select Basic -->
<div class="mb-3 row">
<label class="col-md-1 control-label w-auto" for="band"><?= __("Band"); ?></label>
<div class="col-md-3 w-auto">
<select id="band" name="band" class="form-select form-select-sm">
<option value="All" <?php if ($bandselect == "All") echo ' selected'; ?>><?= __("All"); ?></option>
<?php foreach ($worked_bands as $band) {
echo '<option value="' . $band . '"';
if ($bandselect == $band) echo ' selected';
echo '>' . $band . '</option>' . "\n";
} ?>
</select>
</div>
<div class="mb-3 row">
<label class="col-md-1 control-label w-auto" for="band"><?= __("Band"); ?></label>
<div class="col-md-3 w-auto">
<select id="band" name="band" class="form-select form-select-sm">
<option value="All" <?php if ($bandselect == "All") echo ' selected'; ?>><?= __("All"); ?></option>
<?php
foreach ($worked_bands as $band) {
echo '<option value="' . $band . '"';
if ($bandselect == $band) echo ' selected';
echo '>' . $band . '</option>' . "\n";
}
?>
</select>
</div>
<label id="satlabel" class="col-md-1 control-label w-auto" for="sat" style="display: none;"><?= __("Satellite"); ?></label>
<div id="satselect" class="col-sm-2 w-auto" style="display: none;">
@@ -23,21 +25,26 @@
<?php
foreach ($sats as $sat) {
echo '<option value="' . $sat . '"';
if ($satselect == $sat) echo ' selected';
echo '>' . $sat . '</option>' . "\n";
if ($satselect == $sat) echo ' selected';
echo '>' . $sat . '</option>' . "\n";
}
?>
</select>
</div>
<label id="leogeolabel" class="col-md-1 control-label w-auto" for="leogeo" style="display: none;">LEO/GEO</label>
<div id="leogeoselect" class="col-md-3 w-auto" style="display: none;">
<select id="leogeo" name="leogeo" class="form-select form-select-sm">
<option value="both" <?php if ($orbit == 'both') echo ' selected'; ?>><?= _pgettext("Orbiter LEO or GEO", "Both"); ?></option>
<option value="leo" <?php if ($orbit == 'leo') echo ' selected'; ?>>LEO</option>
<option value="geo" <?php if ($orbit == 'geo') echo ' selected'; ?>>GEO</option>
</select>
</div>
<label id="orbitlabel" class="col-md-1 control-label w-auto" for="orbit" style="display: none;"><?= __("Orbit"); ?></label>
<div id="orbitselect" class="col-md-3 w-auto" style="display: none;">
<select id="orbit" name="orbit" class="form-select form-select-sm">
<option value="All"><?= __("All") ?></option>
<?php
foreach ($orbits as $orbitval) {
echo '<option value="' . $orbitval . '"';
if ($orbit == $orbitval) echo ' selected';
echo '>' . strtoupper($orbitval) . '</option>' . "\n";
}
?>
</select>
</div>
<label class="col-md-1 control-label w-auto" for="mode"><?= __("Mode"); ?></label>
<div class="col-sm-2 w-auto">
@@ -57,7 +64,7 @@
<label class="col-md-1 controll-label w-auto" for="propagation"><?= __("Propagation"); ?></label>
<div class="col-sm-4 w-auto">
<select class="form-select form-select-sm w-auto" id="propagation" >
<select class="form-select form-select-sm w-auto" name="propagation" id="propagation">
<option value="" <?php if ($propagationselect == '') echo ' selected'; ?>><?= __("All"); ?></option>
<option value="None" <?php if ($propagationselect == 'None') echo ' selected'; ?>><?= __("None/Empty"); ?></option>
<option value="NoSAT" <?php if ($propagationselect == 'NoSAT') echo ' selected'; ?>><?= __("All except SAT") ?></option>
@@ -133,9 +140,6 @@ function write_activators($activators_array, $band, $mode, $sat, $orbit, $propag
if ($band == '') {
$band = 'All';
}
if ($orbit == '') {
$orbit = 'both';
}
$i = 1;
echo '<table style="width:100%" class="table table-sm callstatstable table-bordered table-hover table-striped table-condensed text-center">
<thead>

View File

@@ -17,27 +17,27 @@ $(document).ready(function () {
let bandselect = $('#band');
showHideLeoGeo(bandselect);
showHideOrbit(bandselect);
bandselect.change(function () {
showHideLeoGeo(bandselect);
showHideOrbit(bandselect);
});
});
function showHideLeoGeo(bandselect) {
function showHideOrbit(bandselect) {
if (bandselect.val() == "SAT") {
$("#leogeoselect").show();
$("#leogeolabel").show();
$("#orbitselect").show();
$("#orbitlabel").show();
$("#satlabel").show();
$("#satselect").show();
} else {
$("#leogeoselect select").val("All");
$("#leogeolabel select").val("both");
$("#orbitselect select").val("All");
$("#orbitlabel select").val("All");
$("#satlabel select").val("All");
$("#satselect select").val("All");
$("#leogeoselect").hide();
$("#leogeolabel").hide();
$("#orbitselect").hide();
$("#orbitlabel").hide();
$("#satlabel").hide();
$("#satselect").hide();
}
@@ -45,13 +45,13 @@ function showHideLeoGeo(bandselect) {
function displayCallstatsContacts(call, band, mode, sat, orbit, propagation) {
var data = {
Searchphrase: call,
Band: band,
Searchphrase: call,
Band: band,
Mode: mode,
Propagation: propagation,
Sat: sat,
Sat: sat,
Orbit: orbit
};
};
$.ajax({
url: base_url + "index.php/callstats/qso_details_callstats",