mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-25 03:31:13 +00:00
@@ -33,6 +33,31 @@ class Distancerecords extends CI_Controller {
|
||||
case 'M d, y': $usethisformat = 'MMM D, YY';break;
|
||||
}
|
||||
|
||||
if ($this->session->userdata('user_measurement_base') == NULL) {
|
||||
$measurement_base = $this->config->item('measurement_base');
|
||||
} else {
|
||||
$measurement_base = $this->session->userdata('user_measurement_base');
|
||||
}
|
||||
|
||||
switch ($measurement_base) {
|
||||
case 'M':
|
||||
$unit = "mi";
|
||||
$factor = 0.621371;
|
||||
break;
|
||||
case 'K':
|
||||
$unit = "km";
|
||||
$factor = 1;
|
||||
break;
|
||||
case 'N':
|
||||
$unit = "nmi";
|
||||
$factor = 0.539957;
|
||||
break;
|
||||
default:
|
||||
$unit = "km";
|
||||
$factor = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
$data['scripts'] = [
|
||||
'assets/js/sections/distancerecords.js',
|
||||
];
|
||||
@@ -41,6 +66,8 @@ class Distancerecords extends CI_Controller {
|
||||
$data['custom_date_format'] = $custom_date_format;
|
||||
$data['page_title'] = __("Satellite Distance Records");
|
||||
$data['distances'] = $this->distancerecords_model->get_records();
|
||||
$data['factor'] = $factor;
|
||||
$data['unit'] = $unit;
|
||||
|
||||
$footerData['usethisformat'] = $usethisformat;
|
||||
|
||||
|
||||
@@ -20,18 +20,21 @@ class Distancerecords_model extends CI_Model {
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
$sql = 'SELECT t1.sat, t1.distance, t2.COL_TIME_ON AS time, t2.COL_CALL AS callsign, t2.COL_GRIDSQUARE AS grid, t2.COL_MODE AS mode, t2.COL_PRIMARY_KEY AS primarykey
|
||||
$sql = 'SELECT t1.sat, t1.distance, t2.COL_TIME_ON AS time, t2.COL_CALL AS callsign, t2.COL_GRIDSQUARE AS grid, t2.COL_MODE AS mode, t2.COL_PRIMARY_KEY AS primarykey, t2.station_gridsquare AS mygrid
|
||||
FROM (
|
||||
SELECT MAX(col_distance) AS distance, COL_SAT_NAME AS sat
|
||||
FROM '.$this->config->item('table_name').'
|
||||
WHERE station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
AND COALESCE(COL_SAT_NAME, "") <> ""
|
||||
AND COL_DISTANCE IS NOT NULL
|
||||
AND COL_GRIDSQUARE IS NOT NULL
|
||||
GROUP BY col_sat_name
|
||||
) t1
|
||||
LEFT JOIN (
|
||||
SELECT *, ROW_NUMBER() OVER (PARTITION BY COL_SAT_NAME, COL_DISTANCE ORDER BY COL_TIME_ON asc) AS rn
|
||||
SELECT COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_GRIDSQUARE, COL_MODE, COL_SAT_NAME, COL_DISTANCE, station_gridsquare, ROW_NUMBER() OVER (PARTITION BY COL_SAT_NAME, COL_DISTANCE ORDER BY COL_TIME_ON asc) AS rn
|
||||
FROM '.$this->config->item('table_name').'
|
||||
WHERE station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
LEFT JOIN station_profile ON station_profile.station_id = '.$this->config->item('table_name').'.station_id
|
||||
WHERE '.$this->config->item('table_name').'.station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
) t2
|
||||
ON t1.sat = t2.COL_SAT_NAME
|
||||
AND t1.distance = t2.COL_DISTANCE
|
||||
@@ -55,6 +58,8 @@ class Distancerecords_model extends CI_Model {
|
||||
FROM '.$this->config->item('table_name').'
|
||||
WHERE station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
AND COALESCE(COL_SAT_NAME, "") <> ""
|
||||
AND COL_DISTANCE IS NOT NULL
|
||||
AND COL_GRIDSQUARE IS NOT NULL
|
||||
GROUP BY col_sat_name
|
||||
ORDER BY distance DESC;';
|
||||
$query = $this->db->query($sql);
|
||||
@@ -64,9 +69,10 @@ class Distancerecords_model extends CI_Model {
|
||||
// With that query for oldest QSO per sat and distance
|
||||
foreach ($query->result() as $row) {
|
||||
$bindings=[];
|
||||
$subsql = 'SELECT COL_SAT_NAME AS sat, COL_TIME_ON as time, COL_CALL as callsign, COL_GRIDSQUARE as grid, COL_MODE AS mode, COL_PRIMARY_KEY as primarykey
|
||||
$subsql = 'SELECT COL_SAT_NAME AS sat, COL_TIME_ON as time, COL_CALL as callsign, COL_GRIDSQUARE as grid, station_profile.station_gridsquare AS mygrid, COL_MODE AS mode, COL_PRIMARY_KEY as primarykey
|
||||
FROM '.$this->config->item('table_name').'
|
||||
WHERE station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
LEFT JOIN station_profile ON station_profile.station_id = '.$this->config->item('table_name').'.station_id
|
||||
WHERE '.$this->config->item('table_name').'.station_id IN ('.implode(', ', $logbooks_locations_array).')
|
||||
AND COL_SAT_NAME = ?
|
||||
AND COL_DISTANCE = ?
|
||||
ORDER BY COL_TIME_ON ASC LIMIT 1;';
|
||||
@@ -74,7 +80,7 @@ class Distancerecords_model extends CI_Model {
|
||||
$bindings[]=$row->distance;
|
||||
$subquery = $this->db->query($subsql, $bindings);
|
||||
$subrow = $subquery->row();
|
||||
array_push($result, (object) ["sat" => $row->sat, "distance" => $row->distance, "time" => $subrow->time, "primarykey" => $subrow->primarykey, "callsign" => $subrow->callsign, "mode" => $subrow->mode, "grid" => $subrow->grid]);
|
||||
array_push($result, (object) ["sat" => $row->sat, "distance" => $row->distance, "time" => $subrow->time, "primarykey" => $subrow->primarykey, "callsign" => $subrow->callsign, "mode" => $subrow->mode, "grid" => $subrow->grid, "mygrid" => $subrow->mygrid]);
|
||||
}
|
||||
return($result);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
<tr>
|
||||
<th style="text-align: center"><?= __("Number") ?></th>
|
||||
<th style="text-align: center"><?= __("Satellite") ?></th>
|
||||
<th style="text-align: center"><?= __("Distance") ?></th>
|
||||
<th style="text-align: center" class="distance-column-sort"><?= __("Distance") ?></th>
|
||||
<th style="text-align: center"><?= __("Date") ?></th>
|
||||
<th style="text-align: center"><?= __("Time") ?></th>
|
||||
<th style="text-align: center"><?= __("Callsign") ?></th>
|
||||
<th style="text-align: center"><?= __("Mode") ?></th>
|
||||
<th style="text-align: center"><?= __("Gridsquare") ?></th>
|
||||
<th style="text-align: center"><?= __("My Gridsquare") ?></th>
|
||||
<th style="text-align: center"><?= __("DX Gridsquare") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -31,11 +32,12 @@
|
||||
<tr>
|
||||
<td style="text-align: center"><?php echo $i; ?></td>
|
||||
<td style="text-align: center"><a href="javascript:displayDistanceQsos('<?php echo $row->sat; ?>')"><?php echo $row->sat; ?></a></td>
|
||||
<td style="text-align: right"><?php printf("%.01f", floatval($row->distance)); ?></td>
|
||||
<td style="text-align: right"><?php printf("%.01f", (floatval($row->distance) * $factor)); echo ' '.$unit; ?></td>
|
||||
<td style="text-align: center"><?php $timestamp = strtotime($row->time ?? ''); echo date($custom_date_format, $timestamp); ?></td>
|
||||
<td style="text-align: center"><?php $timestamp = strtotime($row->time ?? ''); echo date('H:i', $timestamp); ?></td>
|
||||
<td style="text-align: center"><a href="javascript:displayQso(<?php echo $row->primarykey; ?>)"><?php echo $row->callsign; ?></a></td>
|
||||
<td style="text-align: center"><?php echo $row->mode; ?></td>
|
||||
<td style="text-align: center"><?php echo $row->mygrid; ?></td>
|
||||
<td style="text-align: center"><?php echo $row->grid; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -2629,11 +2629,32 @@ function viewEqsl(picture, callsign) {
|
||||
dt.search('').draw();
|
||||
}
|
||||
};
|
||||
$.fn.dataTable.ext.type.order['distance-pre'] = function(data) {
|
||||
var num = parseFloat(data);
|
||||
return isNaN(num) ? 0 : num;
|
||||
};
|
||||
$('#distrectable').on('order.dt search.dt', function() {
|
||||
var disttable = $('#distrectable').DataTable();
|
||||
let i = 1;
|
||||
disttable
|
||||
.cells(null, 0, { search: 'applied', order: 'applied' })
|
||||
.every(function (cell) {
|
||||
this.data(i++);
|
||||
});
|
||||
});
|
||||
$('#distrectable').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: true,
|
||||
"columnDefs": [ 2, 'num' ],
|
||||
"columnDefs": [
|
||||
{
|
||||
2: 'num'
|
||||
},
|
||||
{
|
||||
"targets": $(".distance-column-sort").index(),
|
||||
"type": "distance",
|
||||
}
|
||||
],
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
|
||||
Reference in New Issue
Block a user