Add displayname to distance records table

This commit is contained in:
phl0
2024-12-02 17:12:13 +01:00
parent b86d2740b7
commit 12958e84ec
2 changed files with 6 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ 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, t2.station_gridsquare AS mygrid
$sql = 'SELECT t1.sat, displayname AS sat_displayname, 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').'
@@ -38,6 +38,7 @@ class Distancerecords_model extends CI_Model {
) t2
ON t1.sat = t2.COL_SAT_NAME
AND t1.distance = t2.COL_DISTANCE
LEFT JOIN satellite t3 ON t3.name = t2.COL_SAT_NAME
WHERE t2.rn = 1
ORDER BY t1.distance DESC;';
@@ -69,9 +70,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, station_profile.station_gridsquare AS mygrid, COL_MODE AS mode, COL_PRIMARY_KEY as primarykey
$subsql = 'SELECT COL_SAT_NAME AS sat, satellite.displayname AS sat_displayname, 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').'
LEFT JOIN station_profile ON station_profile.station_id = '.$this->config->item('table_name').'.station_id
LEFT JOIN satellite ON satellite.name = '.$this->config->item('table_name').'.COL_SAT_NAME
WHERE '.$this->config->item('table_name').'.station_id IN ('.implode(', ', $logbooks_locations_array).')
AND COL_SAT_NAME = ?
AND COL_DISTANCE = ?
@@ -80,7 +82,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, "mygrid" => $subrow->mygrid]);
array_push($result, (object) ["sat" => $row->sat, "sat_displayname" => $subrow->sat_displayname, "distance" => $row->distance, "time" => $subrow->time, "primarykey" => $subrow->primarykey, "callsign" => $subrow->callsign, "mode" => $subrow->mode, "grid" => $subrow->grid, "mygrid" => $subrow->mygrid]);
}
return($result);
}

View File

@@ -31,7 +31,7 @@
<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: center"><a href="javascript:displayDistanceQsos('<?php echo $row->sat; ?>')"><?php echo ($row->sat_displayname != null ? $row->sat_displayname." (".$row->sat.")" : $row->sat); ?></a></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>