Skip to content

Commit 0a67573

Browse files
authored
Merge pull request wavelog#276 from AndreasK79/exportmap_lastqso
2 parents 0f72d38 + 949290d commit 0a67573

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

application/controllers/Visitor.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,16 @@ public function search() {
409409

410410
public function exportmap() {
411411
$slug = $this->security->xss_clean($this->uri->segment(3));
412+
$lastqso = $this->security->xss_clean($this->uri->segment(4));
413+
414+
if ($lastqso === "lastqso") {
415+
$this->load->model('visitor_model');
416+
$result = $this->visitor_model->getlastqsodate($slug)->row();
417+
header('Content-Type: application/json');
418+
echo json_encode($result);
419+
return;
420+
}
421+
412422
$data['slug'] = $slug;
413423

414424
$data['page_title'] = "Export Map";
@@ -418,7 +428,7 @@ public function exportmap() {
418428
}
419429

420430
public function mapqsos() {
421-
$this->load->model('logbook_model');
431+
$this->load->model('visitor_model');
422432

423433
$this->load->library('qra');
424434

@@ -441,7 +451,7 @@ public function mapqsos() {
441451
show_404('Unknown Public Page.');
442452
}
443453

444-
$qsos = $this->logbook_model->get_qsos($qsocount, null, $logbooks_locations_array, $band);
454+
$qsos = $this->visitor_model->get_qsos($qsocount, $logbooks_locations_array, $band);
445455
$userid = $this->stationsetup_model->public_slug_exists_userid($slug);
446456
$user_default_confirmation = $this->get_user_default_confirmation($userid);
447457

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
class Visitor_model extends CI_Model {
4+
5+
function get_qsos($num, $StationLocationsArray, $band = '') {
6+
$this->db->select($this->config->item('table_name').'.*, station_profile.*');
7+
$this->db->from($this->config->item('table_name'));
8+
9+
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
10+
11+
if ($band != '') {
12+
if ($band == 'SAT') {
13+
$this->db->where($this->config->item('table_name').'.col_prop_mode', 'SAT');
14+
} else {
15+
$this->db->where($this->config->item('table_name').'.col_prop_mode !="SAT"');
16+
$this->db->where($this->config->item('table_name').'.col_band', $band);
17+
}
18+
}
19+
20+
$this->db->where_in($this->config->item('table_name').'.station_id', $StationLocationsArray);
21+
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
22+
23+
$this->db->limit($num);
24+
25+
return $this->db->get();
26+
}
27+
28+
function getlastqsodate ($slug) {
29+
$this->load->model('stationsetup_model');
30+
$logbook_id = $this->stationsetup_model->public_slug_exists_logbook_id($slug);
31+
$userid = $this->stationsetup_model->public_slug_exists_userid($slug);
32+
$band = $this->user_options_model->get_options('ExportMapOptions',array('option_name'=>'band','option_key'=>$slug), $userid)->row()->option_value ?? '';
33+
34+
$sql = "select max(col_time_on) lastqso from " . $this->config->item('table_name') .
35+
" join station_profile on station_profile.station_id = " . $this->config->item('table_name') . ".station_id where 1 = 1";
36+
37+
if ($band != '') {
38+
if ($band == 'SAT') {
39+
$sql .= " and " . $this->config->item('table_name') . ".col_prop_mode = 'SAT'";
40+
} else {
41+
$sql .= " and " . $this->config->item('table_name') . ".col_prop_mode != 'SAT'";
42+
$sql .= " and " . $this->config->item('table_name') . ".col_band = '". $band . "'";
43+
}
44+
}
45+
46+
return $this->db->query($sql);
47+
}
48+
}

0 commit comments

Comments
 (0)