mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
[Locations] Add last qso date
This commit is contained in:
@@ -17,12 +17,13 @@ class Stationsetup extends CI_Controller {
|
||||
|
||||
public function index() {
|
||||
$this->load->model('stations');
|
||||
$this->load->model('stationsetup_model');
|
||||
$this->load->model('Logbook_model');
|
||||
$this->load->model('logbooks_model');
|
||||
|
||||
$data['my_logbooks'] = $this->logbooks_model->show_all();
|
||||
|
||||
$data['stations'] = $this->stations->all_with_count();
|
||||
$data['stations'] = $this->stationsetup_model->get_all_locations();
|
||||
$data['current_active'] = $this->stations->find_active();
|
||||
$data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
|
||||
|
||||
@@ -290,9 +291,10 @@ class Stationsetup extends CI_Controller {
|
||||
|
||||
public function fetchLocations() {
|
||||
$this->load->model('stations');
|
||||
$this->load->model('stationsetup_model');
|
||||
$this->load->model('Logbook_model');
|
||||
|
||||
$result = $this->stations->all_with_count()->result();
|
||||
$result = $this->stationsetup_model->get_all_locations()->result();
|
||||
$current_active = $this->stations->find_active();
|
||||
$data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
|
||||
|
||||
@@ -313,11 +315,27 @@ class Stationsetup extends CI_Controller {
|
||||
$single->station_delete = $this->stationdelete2html($entry->station_id, $entry->station_profile_name, $entry->station_active);
|
||||
$single->station_favorite = $this->stationfavorite2html($entry->station_id, $quickswitch_enabled);
|
||||
$single->station_linked = $this->stationlinked2html($entry->linked);
|
||||
$single->station_lastqso = $this->stationformattedlastqsodate2html($entry->lastqsodate);
|
||||
array_push($hres,$single);
|
||||
}
|
||||
echo json_encode($hres);
|
||||
}
|
||||
|
||||
private function stationformattedlastqsodate2html($lastqsodate) {
|
||||
$CI =& get_instance();
|
||||
// Get Date format
|
||||
if($CI->session->userdata('user_date_format')) {
|
||||
// If Logged in and session exists
|
||||
$custom_date_format = $CI->session->userdata('user_date_format');
|
||||
} else {
|
||||
// Get Default date format from /config/wavelog.php
|
||||
$custom_date_format = $CI->config->item('qso_date_format');
|
||||
}
|
||||
if ($lastqsodate == null) return '';
|
||||
|
||||
return date($custom_date_format . " H:i", strtotime($lastqsodate ?? '1970-01-01 00:00:00'));
|
||||
}
|
||||
|
||||
private function stationlinked2html($linked) {
|
||||
if ($linked == 1) {
|
||||
return '<i class="fa fa-check text-success" aria-hidden="true"></i>';
|
||||
|
||||
@@ -5,18 +5,6 @@ class Stations extends CI_Model {
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
function all_with_count() {
|
||||
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total, exists(select 1 from station_logbooks_relationship where station_location_id = station_profile.station_id and station_logbook_id = '.($this->session->userdata('active_station_logbook') ?? 0).') as linked');
|
||||
$this->db->from('station_profile');
|
||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left');
|
||||
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
|
||||
$this->db->group_by('station_profile.station_id');
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$this->db->or_where('station_profile.user_id =', NULL);
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
// Returns ALL station profiles regardless of user logged in
|
||||
// This is also used by LoTW sync so must not be changed.
|
||||
function all() {
|
||||
@@ -49,7 +37,7 @@ class Stations extends CI_Model {
|
||||
foreach ($query->result() as $row) {
|
||||
array_push($a_station_ids, $row->station_id);
|
||||
}
|
||||
$station_ids=implode(', ', $a_station_ids);
|
||||
$station_ids=implode(', ', $a_station_ids);
|
||||
return $station_ids;
|
||||
} else {
|
||||
return '';
|
||||
@@ -114,12 +102,12 @@ class Stations extends CI_Model {
|
||||
$state = xss_clean($this->input->post('station_state', true));
|
||||
}
|
||||
|
||||
// Check if DXCC is USA, Alaska or Hawaii, RU, UR, and others with subareas.
|
||||
// Check if DXCC is USA, Alaska or Hawaii, RU, UR, and others with subareas.
|
||||
// If not true, we clear the County field due to complex adif specs
|
||||
switch ($this->input->post('dxcc')) {
|
||||
case 6:
|
||||
case 110:
|
||||
case 291:
|
||||
case 291:
|
||||
case 15:
|
||||
case 54:
|
||||
case 61:
|
||||
@@ -196,12 +184,12 @@ class Stations extends CI_Model {
|
||||
$state = xss_clean($this->input->post('station_state', true));
|
||||
}
|
||||
|
||||
// Check if DXCC is USA, Alaska or Hawaii, RU, UR, and others with subareas.
|
||||
// Check if DXCC is USA, Alaska or Hawaii, RU, UR, and others with subareas.
|
||||
// If not true, we clear the County field due to complex adif specs
|
||||
switch ($this->input->post('dxcc')) {
|
||||
case 6:
|
||||
case 110:
|
||||
case 291:
|
||||
case 291:
|
||||
case 15:
|
||||
case 54:
|
||||
case 61:
|
||||
@@ -297,7 +285,7 @@ class Stations extends CI_Model {
|
||||
}
|
||||
// Delete QSOs
|
||||
$this->db->query("DELETE FROM ".$this->config->item('table_name')." WHERE station_id = ?",$clean_id);
|
||||
|
||||
|
||||
// Also clean up static map images
|
||||
if (!$this->load->is_loaded('staticmap_model')) {
|
||||
$this->load->model('staticmap_model');
|
||||
|
||||
@@ -8,7 +8,7 @@ class Stationsetup_model extends CI_Model {
|
||||
|
||||
if ($session) {
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
}
|
||||
}
|
||||
$this->db->where('logbook_id', $clean_id);
|
||||
return $this->db->get('station_logbooks');
|
||||
}
|
||||
@@ -220,6 +220,18 @@ class Stationsetup_model extends CI_Model {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
function get_all_locations() {
|
||||
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end, count('.$this->config->item('table_name').'.station_id) as qso_total, (select max(col_time_on) from '.$this->config->item('table_name').' where station_id = station_profile.station_id) lastqsodate, exists(select 1 from station_logbooks_relationship where station_location_id = station_profile.station_id and station_logbook_id = '.($this->session->userdata('active_station_logbook') ?? 0).') as linked');
|
||||
$this->db->from('station_profile');
|
||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left');
|
||||
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
|
||||
$this->db->group_by('station_profile.station_id');
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$this->db->or_where('station_profile.user_id =', NULL);
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<th scope="col"><?= __("Station Callsign"); ?></th>
|
||||
<th scope="col"><?= __("Country"); ?></th>
|
||||
<th scope="col"><?= __("Gridsquare"); ?></th>
|
||||
<th scope="col"><?= __("Last QSO"); ?></th>
|
||||
<th></th>
|
||||
<th scope="col"><?= __("Linked"); ?></th>
|
||||
<th scope="col"><?= __("Edit"); ?></th>
|
||||
@@ -149,6 +150,7 @@
|
||||
<td><?php echo $row->station_callsign;?></td>
|
||||
<td><?php echo $row->station_country == '' ? __("Please select one") : $row->station_country; if ($row->dxcc_end != NULL) { echo ' <span class="badge bg-danger">'.__("Deleted DXCC").'</span>'; } ?></td>
|
||||
<td><?php echo $row->station_gridsquare;?></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<?php if($row->station_active != 1) { ?>
|
||||
<a href="<?php echo site_url('station/set_active/').$current_active."/".$row->station_id; ?>" class="btn btn-outline-secondary btn-sm" onclick="return confirm('<?= __("Are you sure you want to make the following station the active station: "); ?> <?php echo $row->station_profile_name; ?>');"><?= __("Set Active"); ?></a>
|
||||
|
||||
@@ -576,6 +576,7 @@ function loadLocationTable(rows) {
|
||||
data.push(locations.station_callsign);
|
||||
data.push(locations.station_country);
|
||||
data.push(locations.station_gridsquare);
|
||||
data.push(locations.station_lastqso);
|
||||
data.push(locations.station_badge);
|
||||
data.push(locations.station_linked);
|
||||
data.push(locations.station_edit);
|
||||
|
||||
Reference in New Issue
Block a user