diff --git a/README.md b/README.md index c0aef1749..76900284f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,6 @@ Thanks to Andy (VE7CXZ), Gavin (M1BXF), Graham (W5ISP), Robert (M0VFC), Corby (K Cloudlog is supported by Patreon and donations via PayPal, thanks to the following people: -Paul (M0TZO), Tim (G4VXE), Paul (N8HM), Michelle (W5NYV), Mitchell (AD0HJ), Dan (M0TCB), Martin (DK3ML), Juan Carlos (EA5WA), Iain (M0PCB), Charlie (GM1TGY), Ondrej (OK1CDJ), Trystan (G0KAY), Oliver (DL6KBG), Volkmar Schirmer, Jordan (M0PIR), Thomas Ziegler, Mathis (DB9MAT), Ken (VE3HLS), Tyler (WL7T), Jeremy Taylor, Ben Kuhn, Eric Thresher, Michael Cullen, Juuso (OH1JW), Anthony Castiglia, Fernando Ramirez-Ferrer, Robert Dixon, Mark Percival, Julia (KV1V), Timo Tomasini, Ant (NU1U), Christopher Williams, Danny Barnes, Vic, Tom (M0LTE), smurphboy, Lars (SM0TGU), Theo (PD9DP), Stefan (SM0RGM). Peter (G0ABI), Lou (KI5FTY), Michael (DG3NAB), Dragan (4O4A), minorsecond, Emily (W7AYQ), Steve (M0SKM), Rob (M0VFC), Doug (WA6L), Petr (OK1PKR), Fabian (HB9HI). +Paul (M0TZO), Tim (G4VXE), Paul (N8HM), Michelle (W5NYV), Mitchell (AD0HJ), Dan (M0TCB), Martin (DK3ML), Juan Carlos (EA5WA), Iain (M0PCB), Charlie (GM1TGY), Ondrej (OK1CDJ), Trystan (G0KAY), Oliver (DL6KBG), Volkmar Schirmer, Jordan (M0PIR), Thomas Ziegler, Mathis (DB9MAT), Ken (VE3HLS), Tyler (WL7T), Jeremy Taylor, Ben Kuhn, Eric Thresher, Michael Cullen, Juuso (OH1JW), Anthony Castiglia, Fernando Ramirez-Ferrer, Robert Dixon, Mark Percival, Julia (KV1V), Timo Tomasini, Ant (NU1U), Christopher Williams, Danny Barnes, Vic, Tom (M0LTE), smurphboy, Lars (SM0TGU), Theo (PD9DP), Stefan (SM0RGM). Peter (G0ABI), Lou (KI5FTY), Michael (DG3NAB), Dragan (4O4A), minorsecond, Emily (W7AYQ), Steve (M0SKM), Rob (M0VFC), Doug (WA6L), Petr (OK1PKR), Fabian (HB9HIL). If you'd like to donate to Cloudlog to help allow @magicbug spend less time doing commercial work and more time coding Cloudlog then you can donate via [PayPal](https://paypal.me/PGoodhall), [Github Sponsor](https://github.com/sponsors/magicbug) or become a [Patreon](https://www.patreon.com/2m0sql) diff --git a/application/config/migration.php b/application/config/migration.php index f11c7f7bd..769923a31 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ | */ -$config['migration_version'] = 140; +$config['migration_version'] = 143; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Api.php b/application/controllers/Api.php index 7a1e96345..1230ff20b 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -185,8 +185,6 @@ function qso() { die(); } - $this->api_model->update_last_used($obj['key']); - if($obj['type'] == "adif" && $obj['string'] != "") { // Load the logbook model for adding QSO records $this->load->model('logbook_model'); @@ -207,6 +205,14 @@ function qso() { if(isset($obj['station_profile_id'])) { + if(isset($record['station_callsign']) && $this->stations->check_station_against_callsign($obj['station_profile_id'], $record['station_callsign']) == false) { + http_response_code(401); + echo json_encode(['status' => 'failed', 'reason' => "station callsign does not match station callsign in station profile."]); + die(); + } + + $this->api_model->update_last_used($obj['key']); + $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true); } diff --git a/application/controllers/Components.php b/application/controllers/Components.php new file mode 100644 index 000000000..942dcbc35 --- /dev/null +++ b/application/controllers/Components.php @@ -0,0 +1,24 @@ +load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() { + $url = 'https://oscarwatch.org/scripts/hamsat_json.php'; + $json = file_get_contents($url); + $data['rovedata'] = json_decode($json, true); + + // load view + $this->load->view('components/hamsat/table', $data); + } +} \ No newline at end of file diff --git a/application/controllers/Hamsat.php b/application/controllers/Hamsat.php new file mode 100644 index 000000000..d2cc9b0be --- /dev/null +++ b/application/controllers/Hamsat.php @@ -0,0 +1,23 @@ +load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() { + // Load public view + $data['page_title'] = "Hamsat - Satellite Roving"; + $this->load->view('interface_assets/header', $data); + $this->load->view('/hamsat/index'); + $this->load->view('interface_assets/footer'); + } +} \ No newline at end of file diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 95cb05ff7..801fafc0d 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -153,6 +153,7 @@ function json($tempcallsign, $temptype, $tempband, $tempmode, $tempstation_id = $return['callsign_state'] = $this->nval($callbook['state'] ?? '', $this->logbook_model->call_state($callsign)); $return['callsign_us_county'] = $this->nval($callbook['us_county'] ?? '', $this->logbook_model->call_us_county($callsign)); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); + $return['confirmed'] = $this->confirmed_grid_before($return['callsign_qra'], $type, $band, $mode); if ($this->session->userdata('user_show_profile_image')) { if (isset($callbook)) { @@ -181,7 +182,70 @@ function nval($val1, $val2) { return (($val2 ?? "") === "" ? ($val1 ?? "") : ($val2 ?? "")); } - function worked_grid_before($gridsquare, $type, $band, $mode) + function confirmed_grid_before($gridsquare, $type, $band, $mode) { + if (strlen($gridsquare) < 4) + return false; + + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $user_gridmap_confirmation = $this->session->userdata('user_gridmap_confirmation'); + + if(!empty($logbooks_locations_array)) { + $extrawhere=''; + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'Q') !== false) { + $extrawhere="COL_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'L') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'E') !== false) { + if ($extrawhere!='') { + $extrawherei.=" OR"; + } + $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + } + + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } else { + $CI->load->model('logbook_model'); + $this->db->where('COL_MODE', $CI->logbook_model->get_main_mode_from_mode($mode)); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } + + $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); + + + $query = $this->db->get($this->config->item('table_name')); + + + foreach ($query->result() as $workedBeforeRow) { + return true; + } + } + return false; + } + +function worked_grid_before($gridsquare, $type, $band, $mode) { if (strlen($gridsquare) < 4) return false; @@ -226,8 +290,9 @@ function worked_grid_before($gridsquare, $type, $band, $mode) function jsonlookupgrid($gridsquare, $type, $band, $mode) { $return = [ "workedBefore" => false, + "confirmed" => false, ]; - + $user_gridmap_confirmation = $this->session->userdata('user_gridmap_confirmation'); $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -251,6 +316,51 @@ function jsonlookupgrid($gridsquare, $type, $band, $mode) { $return['workedBefore'] = true; } + + $extrawhere=''; + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'Q') !== false) { + $extrawhere="COL_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'L') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'E') !== false) { + if ($extrawhere!='') { + $extrawherei.=" OR"; + } + $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + } + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } else { + $CI->load->model('logbook_model'); + $this->db->where('COL_MODE', $CI->logbook_model->get_main_mode_from_mode($mode)); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } + + $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['confirmed']=true; + } + header('Content-Type: application/json'); echo json_encode($return, JSON_PRETTY_PRINT); @@ -261,12 +371,14 @@ function jsonlookupdxcc($country, $type, $band, $mode) { $return = [ "workedBefore" => false, + "confirmed" => false, ]; + $user_gridmap_confirmation = $this->session->userdata('user_gridmap_confirmation'); $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'); + $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'); if(!empty($logbooks_locations_array)) { if($type == "SAT") { @@ -287,12 +399,59 @@ function jsonlookupdxcc($country, $type, $band, $mode) { $return['workedBefore'] = true; } + $extrawhere=''; + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'Q') !== false) { + $extrawhere="COL_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'L') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'E') !== false) { + if ($extrawhere!='') { + $extrawherei.=" OR"; + } + $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + } + + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } else { + $CI->load->model('logbook_model'); + $this->db->where('COL_MODE', $CI->logbook_model->get_main_mode_from_mode($mode)); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } + + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_COUNTRY', urldecode($country)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) { + $return['confirmed']=true; + } + + header('Content-Type: application/json'); echo json_encode($return, JSON_PRETTY_PRINT); return; } else { $return['workedBefore'] = false; + $return['confirmed'] = false; header('Content-Type: application/json'); echo json_encode($return, JSON_PRETTY_PRINT); @@ -307,8 +466,10 @@ function jsonlookupcallsign($callsign, $type, $band, $mode) { $return = [ "workedBefore" => false, + "confirmed" => false, ]; + $user_gridmap_confirmation = $this->session->userdata('user_gridmap_confirmation'); $CI =& get_instance(); $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -333,11 +494,56 @@ function jsonlookupcallsign($callsign, $type, $band, $mode) { $return['workedBefore'] = true; } + $extrawhere=''; + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'Q') !== false) { + $extrawhere="COL_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'L') !== false) { + if ($extrawhere!='') { + $extrawhere.=" OR"; + } + $extrawhere.=" COL_LOTW_QSL_RCVD='Y'"; + } + if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'E') !== false) { + if ($extrawhere!='') { + $extrawherei.=" OR"; + } + $extrawhere.=" COL_EQSL_QSL_RCVD='Y'"; + } + + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } else { + $CI->load->model('logbook_model'); + $this->db->where('COL_MODE', $CI->logbook_model->get_main_mode_from_mode($mode)); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + if ($extrawhere != '') { + $this->db->where('('.$extrawhere.')'); + } else { + $this->db->where("1=0"); + } + } + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_CALL', strtoupper($callsign)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) { + $return['confirmed'] = true; + } + header('Content-Type: application/json'); echo json_encode($return, JSON_PRETTY_PRINT); return; } else { $return['workedBefore'] = false; + $return['confirmed'] = false; header('Content-Type: application/json'); echo json_encode($return, JSON_PRETTY_PRINT); return; @@ -473,7 +679,7 @@ function partial($id) { $html = ""; 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->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, '.$this->config->item('table_name').'.COL_MY_GRIDSQUARE, '.$this->config->item('table_name').'.COL_CONTEST_ID, '.$this->config->item('table_name').'.COL_STATE, 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'); @@ -492,31 +698,27 @@ function partial($id) { $html .= "
Date | "; - $html .= "Callsign | "; - $html .= "Mode | "; - $html .= "RST (S) | "; - $html .= "RST (R) | "; - 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 .= "Frequency | "; - } else { - $html .= "Band | "; - } + $html .= "Date | "; + $html .= "Callsign | "; + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); + $html .= $this->part_table_header_col($this, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); switch($this->session->userdata('user_previous_qsl_type')) { case 0: - $html .= "".lang('gen_hamradio_qsl')." | "; + $html .= "".lang('gen_hamradio_qsl')." | "; break; case 1: - $html .= "".lang('lotw_short')." | "; + $html .= "".lang('lotw_short')." | "; break; case 2: - $html .= "".lang('eqsl_short')." | "; + $html .= "".lang('eqsl_short')." | "; break; default: - $html .= "".lang('gen_hamradio_qsl')." | "; + $html .= "".lang('gen_hamradio_qsl')." | "; break; } - $html .= ""; + $html .= " | "; $html .= " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
".date($custom_date_format, $timestamp). date(' H:i',strtotime($row->COL_TIME_ON)) . " | "; $html .= "" . str_replace('0','Ø',strtoupper($row->COL_CALL)) . " | "; - if ($row->COL_SUBMODE==null) - $html .= "".$row->COL_MODE." | "; - else - $html .= "".$row->COL_SUBMODE." | "; - $html .= "".$row->COL_RST_SENT." | "; - $html .= "".$row->COL_RST_RCVD." | "; - if($row->COL_SAT_NAME != null) { - $html .= "".$row->COL_SAT_NAME." | "; - } 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 .= "".$this->frequency->hz_to_mhz($row->COL_FREQ)." | "; - } else { - $html .= "".$row->COL_BAND." | "; - } - } + $html .= $this->part_table_col($row, $this->session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); + $html .= $this->part_table_col($row, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); if ($this->session->userdata('user_previous_qsl_type') == 1) { $html .= ""; $html .= "input->post('grid')); + $station_id = xss_clean($this->input->post('stationProfile')); $this->load->library('Qra'); if($locator != null) { @@ -915,7 +1108,9 @@ function searchbearing($locator, $station_id = null) { } /* return distance */ - function searchdistance($locator, $station_id = null) { + function searchdistance() { + $locator = xss_clean($this->input->post('grid')); + $station_id = xss_clean($this->input->post('stationProfile')); $this->load->library('Qra'); if($locator != null) { @@ -1010,7 +1205,8 @@ function qralatlng($qra) { return $latlng; } - function qralatlngjson($qra) { + function qralatlngjson() { + $qra = xss_clean($this->input->post('qra')); $this->load->library('Qra'); $latlng = $this->qra->qra2latlong($qra); print json_encode($latlng); @@ -1029,4 +1225,56 @@ function get_qsos($num, $offset) { return $this->db->get(); } + function part_table_header_col($ctx, $name) { + $ret=''; + switch($name) { + case 'Mode': $ret.= ' | '.$ctx->lang->line('gen_hamradio_mode').' | '; break; + case 'RSTS': $ret.= ''.$ctx->lang->line('gen_hamradio_rsts').' | '; break; + case 'RSTR': $ret.= ''.$ctx->lang->line('gen_hamradio_rstr').' | '; break; + case 'Country': $ret.= ''.$ctx->lang->line('general_word_country').' | '; break; + case 'IOTA': $ret.= ''.$ctx->lang->line('gen_hamradio_iota').' | '; break; + case 'SOTA': $ret.= ''.$ctx->lang->line('gen_hamradio_sota').' | '; break; + case 'WWFF': $ret.= ''.$ctx->lang->line('gen_hamradio_wwff').' | '; break; + case 'POTA': $ret.= ''.$ctx->lang->line('gen_hamradio_pota').' | '; break; + case 'State': $ret.= ''.$ctx->lang->line('gen_hamradio_state').' | '; break; + case 'Grid': $ret.= ''.$ctx->lang->line('gen_hamradio_gridsquare').' | '; break; + case 'Distance': $ret.= ''.$ctx->lang->line('gen_hamradio_distance').' | '; break; + case 'Band': $ret.= ''.$ctx->lang->line('gen_hamradio_band').' | '; break; + case 'Frequency': $ret.= ''.$ctx->lang->line('gen_hamradio_frequency').' | '; break; + case 'Operator': $ret.= ''.$ctx->lang->line('gen_hamradio_operator').' | '; break; + } + return $ret; + } + + function part_QrbCalcLink($mygrid, $grid, $vucc) { + $ret=''; + if (!empty($grid)) { + $ret.= $grid . ' '; + } else if (!empty($vucc)) { + $ret.= $vucc .' '; + } + return $ret; + } + + function part_table_col($row, $name) { + $ret=''; + $ci =& get_instance(); + switch($name) { + case 'Mode': $ret.= ''; $ret.= $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE . ' | '; break; + case 'RSTS': $ret.= '' . $row->COL_RST_SENT; if ($row->COL_STX) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge badge-light">'; $ret.=sprintf("%03d", $row->COL_STX); $ret.= '';} if ($row->COL_STX_STRING) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge badge-light">' . $row->COL_STX_STRING . '';} $ret.= ' | '; break; + case 'RSTR': $ret.= '' . $row->COL_RST_RCVD; if ($row->COL_SRX) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge badge-light">'; $ret.=sprintf("%03d", $row->COL_SRX); $ret.= '';} if ($row->COL_SRX_STRING) { $ret.= ' COL_CONTEST_ID:"n/a").'" class="badge badge-light">' . $row->COL_SRX_STRING . '';} $ret.= ' | '; break; + case 'Country': $ret.= '' . ucwords(strtolower(($row->COL_COUNTRY))); if ($row->end != NULL) $ret.= ' '.$ci->lang->line('gen_hamradio_deleted_dxcc').'' . ' | '; break; + case 'IOTA': $ret.= '' . ($row->COL_IOTA) . ' | '; break; + case 'SOTA': $ret.= '' . ($row->COL_SOTA_REF) . ' | '; break; + case 'WWFF': $ret.= '' . ($row->COL_WWFF_REF) . ' | '; break; + case 'POTA': $ret.= '' . ($row->COL_POTA_REF) . ' | '; break; + case 'Grid': $ret.= '' . $this->part_QrbCalcLink($row->COL_MY_GRIDSQUARE, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE) . ' | '; break; + case 'Distance': $ret.= '' . ($row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ' | '; break; + case 'Band': $ret.= ''; if($row->COL_SAT_NAME != null) { $ret.= ''.$row->COL_SAT_NAME.' | '; } else { $ret.= strtolower($row->COL_BAND); } $ret.= ''; break; + case 'Frequency': $ret.= ''; if($row->COL_SAT_NAME != null) { $ret.= ''.$row->COL_SAT_NAME.' | '; } else { if($row->COL_FREQ != null) { $ret.= $ci->frequency->hz_to_mhz($row->COL_FREQ); } else { $ret.= strtolower($row->COL_BAND); } } $ret.= ''; break; + case 'State': $ret.= '' . ($row->COL_STATE) . ' | '; break; + case 'Operator': $ret.= '' . ($row->COL_OPERATOR) . ' | '; break; + } + return $ret; + } } diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 456c3e26e..9fc9f54e5 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -25,6 +25,7 @@ function index() { $this->load->model('bands'); $this->load->model('iota'); $this->load->model('dxcc'); + $this->load->model('user_options_model'); $stationIds = []; @@ -40,6 +41,11 @@ function index() { $data['page_title'] = "Advanced logbook"; $data['hasDatePicker'] = true; + $userOptions = $this->user_options_model->get_options('LogbookAdvanced')->result(); + if (isset($userOptions[0])) { + $data['options'] = $userOptions[0]->option_value; + } + $pageData = []; $pageData['datePlaceholder'] = 'DD/MM/YYYY'; $pageData['deOptions'] = $deOptions; @@ -404,4 +410,42 @@ public function calculateCoordinates($qso, $lat, $long, $mygrid, $measurement_ba return $data; } + + public function userOptions() { + $this->load->model('user_options_model'); + $userOptions = $this->user_options_model->get_options('LogbookAdvanced')->result(); + if (isset($userOptions[0])) { + $data['options'] = $options = json_decode($userOptions[0]->option_value); + } else { + $data['options'] = null; + } + $this->load->view('logbookadvanced/useroptions', $data); + } + + public function setUserOptions() { + $json_string['datetime']['show'] = $this->input->post('datetime'); + $json_string['de']['show'] = $this->input->post('de'); + $json_string['dx']['show'] = $this->input->post('dx'); + $json_string['mode']['show'] = $this->input->post('mode'); + $json_string['rstr']['show'] = $this->input->post('rstr'); + $json_string['rsts']['show'] = $this->input->post('rsts'); + $json_string['band']['show'] = $this->input->post('band'); + $json_string['myrefs']['show'] = $this->input->post('myrefs'); + $json_string['refs']['show'] = $this->input->post('refs'); + $json_string['name']['show'] = $this->input->post('name'); + $json_string['qslvia']['show'] = $this->input->post('qslvia'); + $json_string['qsl']['show'] = $this->input->post('qsl'); + $json_string['lotw']['show'] = $this->input->post('lotw'); + $json_string['eqsl']['show'] = $this->input->post('eqsl'); + $json_string['qslmsg']['show'] = $this->input->post('qslmsg'); + $json_string['dxcc']['show'] = $this->input->post('dxcc'); + $json_string['state']['show'] = $this->input->post('state'); + $json_string['cqzone']['show'] = $this->input->post('cqzone'); + $json_string['iota']['show'] = $this->input->post('iota'); + + $obj['column_settings']= json_encode($json_string); + + $this->load->model('user_options_model'); + $this->user_options_model->set_option('LogbookAdvanced', 'LogbookAdvanced', $obj); + } } diff --git a/application/language/english/account_lang.php b/application/language/english/account_lang.php index 54025f593..645f27177 100644 --- a/application/language/english/account_lang.php +++ b/application/language/english/account_lang.php @@ -95,3 +95,4 @@ $lang['account_gridmap_settings'] = 'Settings for Gridsquare Map'; $lang['account_gridmap_default_band'] = 'Default Band'; +$lang['account_qsl_settings'] = 'Default QSL-Method shown in views (Gridsquare and Add-QSO)'; diff --git a/application/language/english/menu_lang.php b/application/language/english/menu_lang.php index 7a02243b8..4d6acd63b 100644 --- a/application/language/english/menu_lang.php +++ b/application/language/english/menu_lang.php @@ -14,8 +14,8 @@ $lang['menu_live_contest_logging'] = 'Live Contest Logging'; $lang['menu_post_contest_logging'] = 'Post Contest Logging'; $lang['menu_bandmap'] = 'Bandmap'; -$lang['menu_view_qsl'] = 'View QSL'; -$lang['menu_view_eqsl'] = 'View eQSL'; +$lang['menu_view_qsl'] = 'View QSL Cards'; +$lang['menu_view_eqsl'] = 'View eQSL Cards'; $lang['menu_notes'] = 'Notes'; diff --git a/application/language/german/account_lang.php b/application/language/german/account_lang.php index bd9ef7c68..4c853f137 100644 --- a/application/language/german/account_lang.php +++ b/application/language/german/account_lang.php @@ -95,3 +95,4 @@ $lang['account_gridmap_settings'] = 'Einstellung der Planquadratkarte'; $lang['account_gridmap_default_band'] = 'Standardband'; +$lang['account_qsl_settings'] = 'QSL-Methoden, die in der Planquadratkarte und beim anlegen eines QSOs angezeigt werden'; diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index a9122c29e..627fade1f 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -26,9 +26,12 @@ function bearing($tx, $rx, $unit = 'M') { $my = qra2latlong($tx); $stn = qra2latlong($rx); - $bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit); - - return $bearing; + if ($my !== false && $stn !== false ) { + $bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit); + return $bearing; + } else { + return false; + } } /* @@ -168,6 +171,11 @@ function qra2latlong($strQRA) { if (substr_count($strQRA, ',') == 3) { // Handle grid corners $grids = explode(',', $strQRA); + $gridlengths = array(strlen($grids[0]), strlen($grids[1]), strlen($grids[2]), strlen($grids[3])); + $same = array_count_values($gridlengths); + if (count($same) != 1) { + return false; + } $coords = array(0, 0); for($i=0; $i<4; $i++) { $cornercoords[$i] = qra2latlong($grids[$i]); @@ -178,6 +186,9 @@ function qra2latlong($strQRA) { } else if (substr_count($strQRA, ',') == 1) { // Handle grid lines $grids = explode(',', $strQRA); + if (strlen($grids[0]) != strlen($grids[1])) { + return false; + } $coords = array(0, 0); for($i=0; $i<2; $i++) { $linecoords[$i] = qra2latlong($grids[$i]); diff --git a/application/migrations/141_alter_user_options_table.php b/application/migrations/141_alter_user_options_table.php new file mode 100644 index 000000000..f62cbba65 --- /dev/null +++ b/application/migrations/141_alter_user_options_table.php @@ -0,0 +1,13 @@ +db->query("ALTER TABLE user_options CHANGE COLUMN option_value option_value text DEFAULT NULL;"); + } + + public function down(){ + } +} diff --git a/application/migrations/142_alter_lotw_user_table.php b/application/migrations/142_alter_lotw_user_table.php new file mode 100644 index 000000000..958982975 --- /dev/null +++ b/application/migrations/142_alter_lotw_user_table.php @@ -0,0 +1,16 @@ +db->query("ALTER TABLE lotw_users ADD UNIQUE INDEX callsign_UNIQUE (callsign ASC)"); + $this->db->query("ALTER TABLE lotw_users DROP INDEX callsign"); + } + + public function down(){ + $this->db->query("ALTER TABLE lotw_users DROP INDEX callsign_UNIQUE"); + $this->db->query("ALTER TABLE lotw_users ADD INDEX callsign (callsign)"); + } +} diff --git a/application/migrations/143_tag_2_4_9.php b/application/migrations/143_tag_2_4_9.php new file mode 100644 index 000000000..ec1bd57ec --- /dev/null +++ b/application/migrations/143_tag_2_4_9.php @@ -0,0 +1,24 @@ +db->where('option_name', 'version'); + $this->db->update('options', array('option_value' => '2.4.9')); + } + + public function down() + { + $this->db->where('option_name', 'version'); + $this->db->update('options', array('option_value' => '2.4.8')); + } +} \ No newline at end of file diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 42fe8bbc9..e2ef90739 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1132,7 +1132,7 @@ function last_custom($num) { $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if(!empty($logbooks_locations_array)) { - $this->db->select('COL_CALL, COL_BAND, COL_FREQ, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME'); + $this->db->select('COL_CALL, COL_BAND, COL_FREQ, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_SRX, COL_SRX_STRING, COL_STX, COL_STX_STRING, COL_VUCC_GRIDS, COL_GRIDSQUARE, COL_MY_GRIDSQUARE, COL_OPERATOR, COL_IOTA, COL_WWFF_REF, COL_POTA_REF, COL_STATE, COL_CNTY, COL_DISTANCE, COL_SOTA_REF, COL_CONTEST_ID'); $this->db->where_in('station_id', $logbooks_locations_array); $this->db->order_by("COL_TIME_ON", "desc"); $this->db->limit($num); @@ -1467,6 +1467,9 @@ function get_qsos($num, $offset, $StationLocationsArray = null) { $this->db->select($this->config->item('table_name').'.*, station_profile.*, dxcc_entities.*, lotw_users.callsign, lotw_users.lastupload'); $this->db->from($this->config->item('table_name')); + // remove anything thats duplicated based on COL_PRIMARY_KEY + $this->db->distinct(''.$this->config->item('table_name').'.COL_PRIMARY_KEY'); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left'); $this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer'); diff --git a/application/models/Stations.php b/application/models/Stations.php index b780b0a93..054921cf1 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -485,6 +485,17 @@ public function check_station_against_user($stationid, $userid) { } return false; } + + public function check_station_against_callsign($stationid, $callsign) { + $this->db->select('station_id'); + $this->db->where('station_callsign', $callsign); + $this->db->where('station_id', $stationid); + $query = $this->db->get('station_profile'); + if ($query->num_rows() == 1) { + return true; + } + return false; + } } ?> diff --git a/application/views/components/hamsat/table.php b/application/views/components/hamsat/table.php new file mode 100644 index 000000000..bb56551bf --- /dev/null +++ b/application/views/components/hamsat/table.php @@ -0,0 +1,63 @@ +
Date / Time | +Callsign | +Satellite | +Gridsquare | ++ |
---|---|---|---|---|
+ 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'); + } + + ?> + + + + - - + + | ++ | = $rove['satellite'] ?> | ++ + + load->model('logbook_model'); + $worked = $CI->logbook_model->check_if_grid_worked_in_logbook($rove['gridsquare'], null, "SAT"); + if ($worked != 0) { + echo " " . $rove['gridsquare'] . ""; + } else { + echo " " . $rove['gridsquare'] . ""; + } + ?> + + + | +Track | +
- + | -Date/Time | -De | -Dx | -Mode | -RST (S) | -RST (R) | -Band | -My Refs | -Refs | -Name | -QSL Via | -QSL | - session->userdata('user_eqsl_name') != ""){ + datetime->show ?? "true") == "true") { + echo 'Date/Time | '; + } ?> + de->show ?? "true") == "true") { + echo 'De | '; + } ?> + dx->show ?? "true") == "true") { + echo 'Dx | '; + } ?> + mode->show ?? "true") == "true") { + echo 'Mode | '; + } ?> + rsts->show ?? "true") == "true") { + echo 'RST (S) | '; + } ?> + rstr->show ?? "true") == "true") { + echo 'RST (R) | '; + } ?> + band->show ?? "true") == "true") { + echo 'Band | '; + } ?> + myrefs->show ?? "true") == "true") { + echo 'My Refs | '; + } ?> + refs->show ?? "true") == "true") { + echo 'Refs | '; + } ?> + name->show ?? "true") == "true") { + echo 'Name | '; + } ?> + qslvia->show ?? "true") == "true") { + echo 'QSL Via | '; + } ?> + qsl->show ?? "true") == "true") { + echo 'QSL | '; + } ?> + session->userdata('user_eqsl_name') != "" && ($options->eqsl->show ?? "true") == "true"){ echo 'eQSL | '; } ?> - session->userdata('user_lotw_name') != ""){ + session->userdata('user_lotw_name') != "" && ($options->lotw->show ?? "true") == "true"){ echo 'LoTW | '; } ?> -QSL Msg | -DXCC | -State | -CQ Zone | -IOTA | + qslmsg->show ?? "true") == "true") { + echo 'QSL Msg | '; + } ?> + dxcc->show ?? "true") == "true") { + echo 'DXCC | '; + } ?> + state->show ?? "true") == "true") { + echo 'State | '; + } ?> + cqzone->show ?? "true") == "true") { + echo 'CQ Zone | '; + } ?> + iota->show ?? "true") == "true") { + echo 'IOTA | '; + } ?>
---|
Column | +Show | +
---|---|
Date/Time | +datetime->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
De | +de->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
Dx | +dx->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
Mode | +mode->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
RST (S) | +rsts->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
RST (R) | +rstr->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
Band | +band->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
My Refs | +myrefs->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
Refs | +refs->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
Name | +name->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
QSL Via | +qslvia->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
QSL | +qsl->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
LoTW | +lotw->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
eQSL | +eqsl->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
QSL Msg | +qslmsg->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
DXCC | +dxcc->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
State | +state->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
CQ Zone | +cqzone->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
IOTA | +iota->show ?? "true") == "true") { echo 'checked'; } ?>> |
+
/ | -- | - | - | - 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') { - echo ' | '.lang('gen_hamradio_frequency').' | '; - } else { - echo ''.lang('gen_hamradio_band').' | '; - } - ?> -/ | ++ session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); + echo_table_header_col($this, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); + echo_table_header_col($this, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); + echo_table_header_col($this, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); + ?> + COL_CALL)); ?> - | COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?> | -COL_RST_SENT; ?> | -COL_RST_RCVD; ?> | - COL_SAT_NAME != null) { ?> -COL_SAT_NAME; ?> | - 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') { - echo ''; - if ($row->COL_FREQ != null) { - echo $this->frequency->hz_to_mhz($row->COL_FREQ); - } else { - echo $row->COL_BAND; - } - echo ' | '; - } else { - echo ''.$row->COL_BAND.' | '; - } - } ?> - + session->userdata('user_column1')==""?'Mode':$this->session->userdata('user_column1')); + echo_table_col($row, $this->session->userdata('user_column2')==""?'RSTS':$this->session->userdata('user_column2')); + echo_table_col($row, $this->session->userdata('user_column3')==""?'RSTR':$this->session->userdata('user_column3')); + echo_table_col($row, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); + ?> +
---|
/ | -- | - | - | - 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') { - echo ' | '.lang('gen_hamradio_frequency').' | '; - } else { - echo ''.lang('gen_hamradio_band').' | '; - } - ?> -|
'; - $timestamp = strtotime($row->COL_TIME_ON); - echo date($custom_date_format, $timestamp); - echo date(' H:i',strtotime($row->COL_TIME_ON)); - ?> - | -- COL_CALL)); ?> - | -COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?> | -COL_RST_SENT; ?> | -COL_RST_RCVD; ?> | - COL_SAT_NAME != null) { ?> -COL_SAT_NAME; ?> | - 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') { - echo ''; - if ($row->COL_FREQ != null) { - echo $this->frequency->hz_to_mhz($row->COL_FREQ); - } else { - echo $row->COL_BAND; - } - echo ' | '; - } else { - echo ''.$row->COL_BAND.' | '; - } - } ?> -