mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Add page with distance records per SAT
This commit is contained in:
31
application/controllers/Distancerecords.php
Normal file
31
application/controllers/Distancerecords.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Distancerecords extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->load->model('distancerecords_model');
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = __("Distance Records");
|
||||
$data['distances'] = $this->distancerecords_model->get_records();
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('distancerecords/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
public function distancerecords() {
|
||||
}
|
||||
|
||||
}
|
||||
28
application/models/Distancerecords_model.php
Normal file
28
application/models/Distancerecords_model.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
class Distancerecords_model extends CI_Model {
|
||||
|
||||
function get_records() {
|
||||
ini_set('memory_limit', '-1');
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
$sql = 'SELECT t1.sat, t1.distance, t2.COL_TIME_ON time, t2.COL_CALL callsign, t2.COL_GRIDSQUARE grid FROM
|
||||
(
|
||||
SELECT MAX(col_distance) distance, COL_SAT_NAME sat
|
||||
FROM '.$this->config->item('table_name').'
|
||||
WHERE station_id in ('.implode(', ', $logbooks_locations_array).')
|
||||
AND COALESCE(COL_SAT_NAME, "") <> ""
|
||||
GROUP BY col_sat_name
|
||||
) t1
|
||||
LEFT JOIN TABLE_HRD_CONTACTS_V01 t2 ON t1.sat = t2.COL_SAT_NAME AND t1.distance = t2.COL_DISTANCE ORDER BY t1.distance DESC;
|
||||
';
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
53
application/views/distancerecords/index.php
Normal file
53
application/views/distancerecords/index.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<div class="container">
|
||||
<br>
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
<p><?php echo __("This page lists distance records per satellite based on gridsquares."); ?>
|
||||
<?php
|
||||
if ($distances) {
|
||||
if($this->session->userdata('user_date_format')) {
|
||||
// If Logged in and session exists
|
||||
$custom_date_format = $this->session->userdata('user_date_format');
|
||||
} else {
|
||||
// Get Default date format from /config/wavelog.php
|
||||
$custom_date_format = $this->config->item('qso_date_format');
|
||||
}
|
||||
?>
|
||||
|
||||
<table style="width: 100%" id="distrectable" class="distrectable table table-sm table-striped table-hover">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<th style="text-align: center"><?= __("Satellite") ?></th>
|
||||
<th style="text-align: center"><?= __("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"><?= __("Gridsquare") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
if ($distances->num_rows() > 0) {
|
||||
foreach ($distances->result() as $row) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: center"><?php echo $row->sat; ?></td>
|
||||
<td style="text-align: center"><?php printf("%.01f", floatval($row->distance)); ?> km</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"><?php echo $row->callsign; ?></td>
|
||||
<td style="text-align: center"><?php echo $row->grid; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {
|
||||
echo '<div class="alert alert-danger" role="alert">' . __("Nothing found!") . '</div>';
|
||||
}?>
|
||||
</div>
|
||||
@@ -143,6 +143,8 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
<li><a class="dropdown-item" href="<?php echo site_url('distances'); ?>" title="Distances"><i class="fas fa-chart-area"></i> <?= __("Distances Worked"); ?></a></li>
|
||||
<div class="dropdown-divider"></div>
|
||||
<li><a class="dropdown-item" href="<?php echo site_url('distancerecords'); ?>" title="Distance records"><i class="fas fa-chart-area"></i> <?= __("Distance Records"); ?></a></li>
|
||||
<div class="dropdown-divider"></div>
|
||||
<li><a class="dropdown-item" href="<?php echo site_url('dayswithqso'); ?>" title="Days with QSOs"><i class="fas fa-chart-area"></i> <?= __("Days with QSOs"); ?></a></li>
|
||||
<div class="dropdown-divider"></div>
|
||||
<li><a class="dropdown-item" href="<?php echo site_url('timeline'); ?>" title="Timeline"><i class="fas fa-chart-area"></i> <?= __("Timeline"); ?></a></li>
|
||||
|
||||
Reference in New Issue
Block a user