Cloudlog/application/controllers/Logbook.php

1060 wiersze
36 KiB
PHP
Czysty Zwykły widok Historia

2012-11-14 01:44:23 +00:00
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2012-11-14 01:44:23 +00:00
class Logbook extends CI_Controller {
function __construct()
{
parent::__construct();
// Load language files
$this->lang->load(array(
'contesting',
'qslcard',
'lotw',
This PR adds some eye candy tooltips to QSLs icons as well as contest exchanges on various sections within cloudlog Squashed commit of the following: commit 89edbf3ddadd7d796ba5412388f66d14e3e9ac17 Author: phl0 <florian@florian-wolters.de> Date: Wed Jan 12 20:47:17 2022 +0100 Fix flicker issue on gridmaps page (by LA8AJA) commit 5b0c2672aadbf0451ec52ecc65745e880b44ef8f Author: phl0 <florian@florian-wolters.de> Date: Wed Jan 12 19:36:31 2022 +0100 Also show tooltips for contest name commit 88e091f65ace6bdbae3d605839665fdd457ea943 Author: phl0 <florian@florian-wolters.de> Date: Wed Jan 12 19:08:31 2022 +0100 Enable QSL tooltips also for QSO list in qslprint section commit 91b81a0b2ba531e867f82197fe1b201e24785dd2 Author: phl0 <florian@florian-wolters.de> Date: Tue Jan 11 17:46:38 2022 +0100 Prevent display of empty date values commit a66be2dab1d23b15fa41df0a2c9a0c41f455afff Author: phl0 <florian@florian-wolters.de> Date: Tue Jan 11 17:12:43 2022 +0100 Make tooltip work also for gridsquares section Tnx @AndreasK79 commit 92c13483b9c71d55fa3d863d426b300cf008dd31 Author: phl0 <florian@florian-wolters.de> Date: Tue Jan 11 15:37:21 2022 +0100 Implement tooltip hints also for other awards sections commit 625c0e73c5dd5823301d888be4d0b3419a76f1db Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 19:28:47 2022 +0100 Implement tooltip for awards section commit 0fe9061ecf3e4b8d9826dee62779e2493124d8a5 Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 16:57:35 2022 +0100 Fix bug with extra quotes if manager defined commit cb8e4d1e4343670a60bc93ac3e87d54d45d0a9fd Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 16:18:44 2022 +0100 Small bugix commit 5bca33b7a1dca1b89d0921a8e0890fc1aebccedd Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 15:42:31 2022 +0100 Add missing translations for electronic QSL commit 617f58a6217aa385225eab27bfe577ad55b7ff37 Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 00:40:32 2022 +0100 Enable tooltips also for search results commit 432a1b283a19196618d4c809545d01cef4f630d3 Author: phl0 <florian@florian-wolters.de> Date: Mon Jan 10 00:18:33 2022 +0100 Also QSL method/manager info commit b43e7a1419c75a199c0a28c9849f2b09e0c62288 Author: phl0 <florian@florian-wolters.de> Date: Sun Jan 9 23:28:54 2022 +0100 Show details for paper QSLs commit 1759d94d8af7299684265700cec51fe0591623dc Author: phl0 <florian@florian-wolters.de> Date: Fri Jan 7 17:51:17 2022 +0100 Add tooltip hints for QSL sent/rcvd dates
2022-01-12 19:51:24 +00:00
'eqsl',
'qso'
));
}
2019-02-26 21:08:12 +00:00
function index()
{
// Check if users logged in
$this->load->model('user_model');
if($this->user_model->validate_session() == 0) {
// user is not logged in
redirect('user/login');
}
$this->load->model('stations');
2019-02-26 21:08:12 +00:00
// If environment is set to development then show the debug toolbar
if(ENVIRONMENT == 'development') {
$this->output->enable_profiler(TRUE);
}
$this->load->model('logbook_model');
2019-02-26 21:08:12 +00:00
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/logbook/index/';
$config['total_rows'] = $this->logbook_model->total_qsos();
2019-02-26 21:08:12 +00:00
$config['per_page'] = '25';
$config['num_links'] = 6;
$config['full_tag_open'] = '';
$config['full_tag_close'] = '';
$config['cur_tag_open'] = '<strong class="active"><a href="">';
$config['cur_tag_close'] = '</a></strong>';
$this->pagination->initialize($config);
2019-02-26 21:08:12 +00:00
//load the model and get results
$data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3));
if(!$data['results']) {
$this->session->set_flashdata('notice', lang('error_no_logbook_found') . ' <a href="' . site_url('logbooks') . '" title="Station Logbooks">Station Logbooks</a>');
}
2019-02-26 21:08:12 +00:00
// Calculate Lat/Lng from Locator to use on Maps
if($this->session->userdata('user_locator')) {
$this->load->library('qra');
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
if (isset($qra_position[0]) and isset($qra_position[1])) {
$data['qra'] = "set";
$data['qra_lat'] = $qra_position[0];
$data['qra_lng'] = $qra_position[1];
} else {
$data['qra'] = "none";
}
2019-02-26 21:08:12 +00:00
} else {
$data['qra'] = "none";
}
// load the view
$data['page_title'] = "Logbook";
2019-05-14 15:46:16 +00:00
$this->load->view('interface_assets/header', $data);
2019-02-26 21:08:12 +00:00
$this->load->view('view_log/index');
2019-05-14 15:46:16 +00:00
$this->load->view('interface_assets/footer');
2019-02-26 21:08:12 +00:00
}
function jsonentity($adif) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$return['dxcc'] = $this->getentity($adif);
2020-04-13 17:23:19 +00:00
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
}
function json($callsign, $type, $band, $mode, $station_id = null)
2019-02-26 21:08:12 +00:00
{
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
// Convert - in Callsign to / Used for URL processing
$callsign = str_replace("-","/",$callsign);
2023-07-27 07:16:55 +00:00
// Check if callsign is an LoTW User
// Check Database for all other data
2019-02-26 21:08:12 +00:00
$this->load->model('logbook_model');
$lotw_days=$this->logbook_model->check_last_lotw($callsign);
if ($lotw_days != null) {
$lotw_member="active";
} else {
$lotw_member="not found";
}
2019-02-26 21:08:12 +00:00
$return = [
"callsign" => strtoupper($callsign),
2019-02-26 21:08:12 +00:00
"dxcc" => false,
"callsign_name" => "",
"callsign_qra" => "",
2023-06-15 14:03:24 +00:00
"callsign_distance" => 0,
2019-02-26 21:08:12 +00:00
"callsign_qth" => "",
"callsign_iota" => "",
"callsign_state" => "",
"callsign_us_county" => "",
"qsl_manager" => "",
2019-02-26 21:08:12 +00:00
"bearing" => "",
"workedBefore" => false,
"lotw_member" => $lotw_member,
"lotw_days" => $lotw_days,
"image" => "",
2019-02-26 21:08:12 +00:00
];
2019-06-13 23:14:39 +00:00
$return['dxcc'] = $this->dxcheck($callsign);
2019-02-26 21:08:12 +00:00
$return['partial'] = $this->partial($callsign);
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
// Do we have local data for the Callsign?
if($this->logbook_model->call_name($callsign) != null)
{
if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base');
} else {
$measurement_base = $this->session->userdata('user_measurement_base');
}
$return['callsign_name'] = $this->logbook_model->call_name($callsign);
$return['callsign_qra'] = $this->logbook_model->call_qra($callsign);
2023-06-15 14:03:24 +00:00
$return['callsign_distance'] = $this->distance($return['callsign_qra'], $station_id);
$return['callsign_qth'] = $this->logbook_model->call_qth($callsign);
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign);
$return['callsign_state'] = $this->logbook_model->call_state($callsign);
2022-04-16 20:07:13 +00:00
$return['callsign_us_county'] = $this->logbook_model->call_us_county($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
2022-07-03 09:39:05 +00:00
if ($this->session->userdata('user_show_profile_image')) {
if (isset($callbook)) {
if ($callbook['image'] == "") {
$return['image'] = "n/a";
} else {
$return['image'] = $callbook['image'];
}
} else {
$return['image'] = "n/a";
}
}
if ($return['callsign_qra'] != "") {
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
}
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
if (isset($callbook))
{
$return['callsign_name'] = $callbook['name'];
$return['callsign_qra'] = $callbook['gridsquare'];
2023-06-21 10:42:46 +00:00
$return['callsign_distance'] = $this->distance($callbook['gridsquare'], $station_id);
$return['callsign_qth'] = $callbook['city'];
$return['callsign_iota'] = $callbook['iota'];
$return['callsign_state'] = $callbook['state'];
$return['callsign_us_county'] = $callbook['us_county'];
2022-07-03 09:39:05 +00:00
if ($this->session->userdata('user_show_profile_image')) {
if ($callbook['image'] == "") {
$return['image'] = "n/a";
} else {
$return['image'] = $callbook['image'];
}
}
if(isset($callbook['qslmgr'])) {
$return['qsl_manager'] = $callbook['qslmgr'];
}
if ($return['callsign_qra'] != "") {
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
}
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
2019-06-13 23:14:39 +00:00
}
if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base');
} else {
$measurement_base = $this->session->userdata('user_measurement_base');
}
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
echo json_encode($return, JSON_PRETTY_PRINT);
return;
2019-02-26 21:08:12 +00:00
}
function worked_grid_before($gridsquare, $type, $band, $mode)
2019-02-26 21:08:12 +00:00
{
if (strlen($gridsquare) < 4)
return false;
2019-02-26 21:08:12 +00:00
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
2021-11-14 22:48:39 +00:00
if(!empty($logbooks_locations_array)) {
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode));
2021-11-14 22:48:39 +00:00
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');
2021-11-14 22:48:39 +00:00
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc");
$this->db->limit(1);
2021-11-14 22:48:39 +00:00
$query = $this->db->get($this->config->item('table_name'));
2021-11-14 22:48:39 +00:00
foreach ($query->result() as $workedBeforeRow)
{
return true;
}
2019-02-26 21:08:12 +00:00
}
return false;
}
/*
* Function: jsonlookupgrid
*
* Usage: Used to look up gridsquares when creating a QSO to check whether its needed or not
* the $type variable is only used for satellites, set this to SAT.
*
*/
function jsonlookupgrid($gridsquare, $type, $band, $mode) {
$return = [
"workedBefore" => false,
];
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode));
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');
}
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
{
$return['workedBefore'] = true;
}
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
function jsonlookupdxcc($country, $type, $band, $mode) {
$return = [
"workedBefore" => false,
];
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$CI->load->model('logbook_model');
2021-11-14 22:48:39 +00:00
if(!empty($logbooks_locations_array)) {
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode));
2021-11-14 22:48:39 +00:00
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');
2021-11-14 22:48:39 +00:00
}
2021-11-14 22:48:39 +00:00
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_COUNTRY', urldecode($country));
2021-11-14 22:48:39 +00:00
$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
{
$return['workedBefore'] = true;
}
2021-11-14 22:48:39 +00:00
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
2021-11-14 22:48:39 +00:00
return;
} else {
$return['workedBefore'] = false;
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
}
function jsonlookupcallsign($callsign, $type, $band, $mode) {
// Convert - in Callsign to / Used for URL processing
$callsign = str_replace("-","/",$callsign);
$return = [
"workedBefore" => false,
];
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$CI->load->model('logbook_model');
2021-11-14 22:48:39 +00:00
if(!empty($logbooks_locations_array)) {
if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $this->logbook_model->get_main_mode_from_mode($mode));
2021-11-14 22:48:39 +00:00
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');
2021-11-14 22:48:39 +00:00
}
2021-11-14 22:48:39 +00:00
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_CALL', strtoupper($callsign));
2021-11-14 22:48:39 +00:00
$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
{
$return['workedBefore'] = true;
}
2021-11-14 22:48:39 +00:00
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
return;
} else {
$return['workedBefore'] = false;
header('Content-Type: application/json');
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
}
2019-02-26 21:08:12 +00:00
/* Used to generate maps for displaying on /logbook/ */
function qso_map() {
header('Content-Type: application/json; charset=utf-8');
2019-02-26 21:08:12 +00:00
$this->load->model('logbook_model');
$this->load->library('qra');
$data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4));
echo "{\"markers\": [";
$count = 1;
foreach ($data['qsos']->result() as $row) {
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
2019-02-26 21:08:12 +00:00
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
2019-02-26 21:08:12 +00:00
}
$count++;
}elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
2019-02-26 21:08:12 +00:00
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
}
$count++;
2019-02-26 21:08:12 +00:00
} else {
if($count != 1) {
2019-02-26 21:08:12 +00:00
echo ",";
}
$result = $this->logbook_model->dxcc_lookup($row->COL_CALL, $row->COL_TIME_ON);
if(isset($result)) {
$lat = $result['lat'];
$lng = $result['long'];
}
echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
$count++;
2019-02-26 21:08:12 +00:00
}
}
echo "]";
echo "}";
}
2019-02-26 21:08:12 +00:00
function view($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
2019-02-26 21:08:12 +00:00
$this->load->library('qra');
$this->load->model('logbook_model');
$data['query'] = $this->logbook_model->get_qso($id);
if ($this->session->userdata('user_measurement_base') == NULL) {
$data['measurement_base'] = $this->config->item('measurement_base');
}
else {
$data['measurement_base'] = $this->session->userdata('user_measurement_base');
}
2020-10-28 22:20:03 +00:00
$this->load->model('Qsl_model');
$data['qslimages'] = $this->Qsl_model->getQslForQsoId($id);
$data['max_upload'] = ini_get('upload_max_filesize');
$this->load->view('interface_assets/mini_header', $data);
$this->load->view('view_log/qso');
$this->load->view('interface_assets/footer');
2019-02-26 21:08:12 +00:00
}
2019-02-26 21:08:12 +00:00
function partial($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$html = "";
2021-11-14 22:48:39 +00:00
if(!empty($logbooks_locations_array)) {
$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_FREQ, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
$this->db->from($this->config->item('table_name'));
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
$this->db->like($this->config->item('table_name').'.COL_CALL', $id);
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc");
$this->db->limit(5);
$query = $this->db->get();
2021-11-14 22:48:39 +00:00
}
2019-02-26 21:08:12 +00:00
2021-11-14 22:48:39 +00:00
if (!empty($logbooks_locations_array) && $query->num_rows() > 0)
2019-02-26 21:08:12 +00:00
{
$html .= "<div class=\"table-responsive\">";
$html .= "<table class=\"table\">";
2019-02-26 21:08:12 +00:00
$html .= "<tr>";
$html .= "<td>Date</td>";
$html .= "<td>Callsign</td>";
$html .= "<td>Mode</td>";
$html .= "<td>RST (S)</td>";
$html .= "<td>RST (R)</td>";
if ($this->session->userdata('user_column1')=='Frequency' || $this->session->userdata('user_column2')=='Frequency' || $this->session->userdata('user_column3')=='Frequency' || $this->session->userdata('user_column4')=='Frequency' || $this->session->userdata('user_column5')=='Frequency') {
$html .= "<td>Frequency</td>";
} else {
$html .= "<td>Band</td>";
}
2022-11-24 23:22:31 +00:00
switch($this->session->userdata('user_previous_qsl_type')) {
case 0:
$html .= "<td>".lang('gen_hamradio_qsl')."</td>";
2022-11-24 23:22:31 +00:00
break;
case 1:
$html .= "<td>".lang('lotw_short')."</td>";
2022-11-24 23:22:31 +00:00
break;
case 2:
$html .= "<td>".lang('eqsl_short')."</td>";
2022-11-24 23:22:31 +00:00
break;
default:
$html .= "<td>".lang('gen_hamradio_qsl')."</td>";
2022-11-24 23:22:31 +00:00
break;
}
$html .= "<td></td>";
2019-02-26 21:08:12 +00:00
$html .= "</tr>";
// Get Date format
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/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}
2019-02-26 21:08:12 +00:00
foreach ($query->result() as $row)
{
$timestamp = strtotime($row->COL_TIME_ON);
2019-02-26 21:08:12 +00:00
$html .= "<tr>";
$html .= "<td>".date($custom_date_format, $timestamp). date(' H:i',strtotime($row->COL_TIME_ON)) . "</td>";
2021-12-28 19:08:41 +00:00
$html .= "<td><a id='edit_qso' href='javascript:displayQso(" . $row->COL_PRIMARY_KEY . ");'>" . str_replace('0','&Oslash;',strtoupper($row->COL_CALL)) . "</a></td>";
if ($row->COL_SUBMODE==null)
$html .= "<td>".$row->COL_MODE."</td>";
else
$html .= "<td>".$row->COL_SUBMODE."</td>";
2019-02-26 21:08:12 +00:00
$html .= "<td>".$row->COL_RST_SENT."</td>";
$html .= "<td>".$row->COL_RST_RCVD."</td>";
if($row->COL_SAT_NAME != null) {
$html .= "<td>".$row->COL_SAT_NAME."</td>";
2019-02-26 21:08:12 +00:00
} else {
if ($this->session->userdata('user_column1')=='Frequency' || $this->session->userdata('user_column2')=='Frequency' || $this->session->userdata('user_column3')=='Frequency' || $this->session->userdata('user_column4')=='Frequency' || $this->session->userdata('user_column5')=='Frequency') {
$html .= "<td>".$this->frequency->hz_to_mhz($row->COL_FREQ)."</td>";
} else {
$html .= "<td>".$row->COL_BAND."</td>";
}
2019-02-26 21:08:12 +00:00
}
2022-11-24 23:22:31 +00:00
if ($this->session->userdata('user_previous_qsl_type') == 1) {
$html .= "<td class=\"lotw\">";
$html .= "<span class=\"qsl-";
switch ($row->COL_LOTW_QSL_SENT) {
case "Y":
$html .= "green";
break;
default:
$html .= "red";
}
$html .= "\">&#9650;</span>";
$html .= "<span class=\"qsl-";
switch ($row->COL_LOTW_QSL_RCVD) {
case "Y":
$html .= "green";
break;
default:
$html .= "red";
}
$html .= "\">&#9660;</span>";
$html .= "</td>";
} else if ($this->session->userdata('user_previous_qsl_type') == 2) {
$html .= "<td class=\"eqsl\">";
$html .= "<span class=\"qsl-";
switch ($row->COL_EQSL_QSL_SENT) {
case "Y":
$html .= "green";
break;
default:
$html .= "red";
}
$html .= "\">&#9650;</span>";
$html .= "<span class=\"qsl-";
switch ($row->COL_EQSL_QSL_RCVD) {
case "Y":
$html .= "green";
break;
default:
$html .= "red";
}
$html .= "\">&#9660;</span>";
$html .= "</td>";
} else {
$html .= "<td class=\"qsl\">";
$html .= "<span class=\"qsl-";
switch ($row->COL_QSL_SENT) {
case "Y":
$html .= "green";
break;
case "Q":
$html .= "yellow";
break;
case "R":
$html .= "yellow";
break;
case "I":
$html .= "grey";
break;
default:
$html .= "red";
}
$html .= "\">&#9650;</span>";
$html .= "<span class=\"qsl-";
switch ($row->COL_QSL_RCVD) {
case "Y":
$html .= "green";
break;
case "Q":
$html .= "yellow";
break;
case "R":
$html .= "yellow";
break;
case "I":
$html .= "grey";
break;
default:
$html .= "red";
}
$html .= "\">&#9660;</span>";
$html .= "</td>";
}
$html .= "<td><span class=\"badge badge-info\">".$row->station_callsign."</span></td>";
2019-02-26 21:08:12 +00:00
$html .= "</tr>";
}
$html .= "</table>";
$html .= "</div>";
2019-02-26 21:08:12 +00:00
return $html;
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$data= $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
if (empty($data['callsign']))
{
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
$data = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
}
2019-02-26 21:08:12 +00:00
}
// There's no hamli integration? Disabled for now.
/*else {
// Lookup using hamli
$this->load->library('hamli');
$data['callsign'] = $this->hamli->callsign($id);
}*/
$data['id'] = strtoupper($id);
return $this->load->view('search/result', $data, true);
}
}
function search_result($id="", $id2="") {
2019-02-26 21:08:12 +00:00
$this->load->model('user_model');
2019-02-26 21:08:12 +00:00
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$fixedid = $id;
if ($id2 != "") {
$fixedid = $id . '/' . $id2;
}
2019-02-26 21:08:12 +00:00
$query = $this->querydb($fixedid);
if ($query->num_rows() == 0) {
$query = $this->querydb($id);
if ($query->num_rows() > 0) {
$data['results'] = $query;
$this->load->view('view_log/partial/log_ajax.php', $data);
}
else {
$this->load->model('search');
2019-02-26 21:08:12 +00:00
$iota_search = $this->search->callsign_iota($id);
2019-02-26 21:08:12 +00:00
if ($iota_search->num_rows() > 0)
{
$data['results'] = $iota_search;
$this->load->view('view_log/partial/log_ajax.php', $data);
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
2019-02-26 21:08:12 +00:00
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
2019-02-26 21:08:12 +00:00
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
} /*else {
// Lookup using hamli
$this->load->library('hamli');
2019-02-26 21:08:12 +00:00
$data['callsign'] = $this->hamli->callsign($id);
}*/
2019-02-26 21:08:12 +00:00
$data['id'] = strtoupper($id);
2019-02-26 21:08:12 +00:00
$this->load->view('search/result', $data);
}
2019-02-26 21:08:12 +00:00
}
} else {
$data['results'] = $query;
$this->load->view('view_log/partial/log_ajax.php', $data);
2019-02-26 21:08:12 +00:00
}
}
function querydb($id) {
$this->db->from($this->config->item('table_name'));
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->join('dxcc_entities', 'dxcc_entities.adif = '.$this->config->item('table_name').'.COL_DXCC', 'left outer');
2023-06-19 11:05:44 +00:00
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
$this->db->group_start();
$this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id);
$this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id);
$this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id);
$this->db->group_end();
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc');
return $this->db->get();
2022-11-04 15:40:15 +00:00
}
function search_duplicates($station_id) {
$station_id = $this->security->xss_clean($station_id);
2019-02-26 21:08:12 +00:00
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'select count(*) as occurence, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from ' . $this->config->item('table_name') .
' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')';
if ($station_id != 'All') {
$sql .= ' and station_profile.station_id = ' . $station_id;
}
$sql .= ' group by col_call, col_mode, COL_SUBMODE, STATION_CALLSIGN, col_band, COL_SAT_NAME having count(*) > 1 and timediff(maxtime, mintime) < 3000';
$query = $this->db->query($sql);
$data['qsos'] = $query;
$this->load->view('search/duplicates_result.php', $data);
2022-11-04 15:40:15 +00:00
}
2019-02-26 21:08:12 +00:00
function search_lotw_unconfirmed($station_id) {
$station_id = $this->security->xss_clean($station_id);
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'select COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, COL_TIME_ON, lotw_users.lastupload from ' . $this->config->item('table_name') .
' join station_profile on ' . $this->config->item('table_name') . '.station_id = station_profile.station_id
join lotw_users on ' . $this->config->item('table_name') . '.col_call = lotw_users.callsign
where ' . $this->config->item('table_name') .'.station_id in ('. $location_list . ')';
if ($station_id != 'All') {
$sql .= ' and station_profile.station_id = ' . $station_id;
}
$sql .= " and COL_LOTW_QSL_RCVD <> 'Y' and " . $this->config->item('table_name') . ".COL_TIME_ON < lotw_users.lastupload";
$query = $this->db->query($sql);
$data['qsos'] = $query;
$this->load->view('search/lotw_unconfirmed_result.php', $data);
}
function search_incorrect_cq_zones($station_id) {
$station_id = $this->security->xss_clean($station_id);
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'select *, (select group_concat(distinct cqzone order by cqzone) from dxcc_master where countrycode = thcv.col_dxcc and cqzone <> \'\' order by cqzone asc) as correctcqzone from ' . $this->config->item('table_name') .
' thcv join station_profile on thcv.station_id = station_profile.station_id where thcv.station_id in ('. $location_list . ')
and not exists (select 1 from dxcc_master where countrycode = thcv.col_dxcc and cqzone = col_cqz) and col_dxcc > 0
';
if ($station_id != 'All') {
$sql .= ' and station_profile.station_id = ' . $station_id;
}
$query = $this->db->query($sql);
$data['qsos'] = $query;
$this->load->view('search/cqzones_result.php', $data);
}
2019-02-26 21:08:12 +00:00
/*
* Provide a dxcc search, returning results json encoded
*/
function local_find_dxcc($call = "", $date = "") {
$this->load->model("logbook_model");
if ($date == ''){
$date = date("Y-m-d");
}
$ans = $this->logbook_model->check_dxcc_stored_proc($call, $date);
print json_encode($ans);
}
2019-06-13 23:14:39 +00:00
function dxcheck($call = "", $date = "") {
$this->load->model("logbook_model");
if ($date == ''){
$date = date("Y-m-d");
}
$ans = $this->logbook_model->dxcc_lookup($call, $date);
return $ans;
}
function getentity($adif) {
$this->load->model("logbook_model");
$entity = $this->logbook_model->get_entity($adif);
return $entity;
}
2019-02-26 21:08:12 +00:00
/* return station bearing */
function searchbearing($locator, $station_id = null) {
$this->load->library('Qra');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return "";
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
if ($this->session->userdata('user_measurement_base') == NULL) {
$measurement_base = $this->config->item('measurement_base');
}
else {
$measurement_base = $this->session->userdata('user_measurement_base');
}
$bearing = $this->qra->bearing($mylocator, $locator, $measurement_base);
echo $bearing;
}
return "";
}
2023-06-15 16:15:29 +00:00
/* return distance */
function searchdistance($locator, $station_id = null) {
$this->load->library('Qra');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return 0;
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
$distance = $this->qra->distance($mylocator, $locator, 'K');
echo $distance;
2023-06-15 16:15:29 +00:00
}
return 0;
}
2019-02-26 21:08:12 +00:00
/* return station bearing */
function bearing($locator, $unit = 'M', $station_id = null) {
2019-02-26 21:08:12 +00:00
$this->load->library('Qra');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return "";
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
2019-02-26 21:08:12 +00:00
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
$bearing = $this->qra->bearing($mylocator, $locator, $unit);
2019-02-26 21:08:12 +00:00
return $bearing;
}
return "";
}
2019-06-13 23:14:39 +00:00
2023-06-15 14:03:24 +00:00
/* return distance */
function distance($locator, $station_id = null) {
$distance = 0;
$this->load->library('Qra');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return 0;
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
$distance = $this->qra->distance($mylocator, $locator, 'K');
}
return $distance;
2023-06-15 14:03:24 +00:00
}
2019-06-13 23:14:39 +00:00
function qralatlng($qra) {
$this->load->library('Qra');
$latlng = $this->qra->qra2latlong($qra);
return $latlng;
}
function qralatlngjson($qra) {
$this->load->library('Qra');
$latlng = $this->qra->qra2latlong($qra);
print json_encode($latlng);
}
function get_qsos($num, $offset) {
$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
$this->db->from($this->config->item('table_name'));
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
$this->db->limit($num);
$this->db->offset($offset);
return $this->db->get();
}
}