From 3a415a558729a38794aceccbc84f99215cbf1d7f Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 11:58:47 +0200 Subject: [PATCH 01/13] [Cabrillo export] Added contest export for cabrillo --- application/controllers/Cabrillo.php | 82 ++++++++++++++ application/libraries/Cabrilloformat.php | 63 +++++++++++ application/models/Contesting_model.php | 103 ++++++++++++++++++ application/views/cabrillo/export.php | 12 ++ application/views/cabrillo/index.php | 41 +++++++ application/views/interface_assets/header.php | 2 + assets/js/sections/cabrillo.js | 44 ++++++++ 7 files changed, 347 insertions(+) create mode 100644 application/controllers/Cabrillo.php create mode 100644 application/libraries/Cabrilloformat.php create mode 100644 application/views/cabrillo/export.php create mode 100644 application/views/cabrillo/index.php create mode 100644 assets/js/sections/cabrillo.js diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php new file mode 100644 index 00000000..5cf61dde --- /dev/null +++ b/application/controllers/Cabrillo.php @@ -0,0 +1,82 @@ +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() + { + $data['page_title'] = "Export Cabrillo"; + + $this->load->model('Contesting_model'); + + $data['contestyears'] = $this->Contesting_model->get_logged_years(); + + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/sections/cabrillo.js' + ]; + + $this->load->view('interface_assets/header', $data); + $this->load->view('cabrillo/index'); + $this->load->view('interface_assets/footer', $footerData); + } + + public function getContests() { + $this->load->model('Contesting_model'); + $result = $this->Contesting_model->get_logged_contests($this->input->post('year')); + + header('Content-Type: application/json'); + echo json_encode($result); + } + + public function getContestDates() { + $this->load->model('Contesting_model'); + $result = $this->Contesting_model->get_contest_dates($this->input->post('year'), $this->input->post('contestid')); + + header('Content-Type: application/json'); + echo json_encode($result); + } + + public function export() { + // Set memory limit to unlimited to allow heavy usage + ini_set('memory_limit', '-1'); + $this->load->model('Contesting_model'); + + $contest_id = $this->security->xss_clean($this->input->post('contestid')); + $fromto = $this->security->xss_clean($this->input->post('contestdates')); + + $fromto = explode(',', $fromto); + + $from = $fromto[0]; + $to = $fromto[1]; + + $data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id); + + $data['contest_id'] = $contest_id; + $data['callsign'] = ''; + $data['claimed_score'] = ''; + $data['operators'] = ''; + $data['club'] = ''; + $data['name'] = ''; + $data['address1'] = ''; + $data['address2'] = ''; + $data['address3'] = ''; + $data['soapbox'] = ''; + + $this->load->view('cabrillo/export', $data); + } +} \ No newline at end of file diff --git a/application/libraries/Cabrilloformat.php b/application/libraries/Cabrilloformat.php new file mode 100644 index 00000000..4f849c74 --- /dev/null +++ b/application/libraries/Cabrilloformat.php @@ -0,0 +1,63 @@ +COL_FREQ, 0, -3); + + if($qso->COL_MODE == "SSB") { + $mode = "PH"; + } elseif($qso->COL_MODE == "RTTY") { + $mode = "RY"; + } else { + $mode = $qso->COL_MODE; + } + + $time = substr($qso->COL_TIME_ON, 0, -3); + + $time = str_replace(":","",$time); + + if ($qso->COL_STX_STRING != "") { + + if($qso->COL_SRX_STRING != "") { + $rx_string = $qso->COL_SRX_STRING; + } else { + $rx_string = "--"; + } + + return "QSO: ".$freq." ".$mode." ".$time." ".$qso->station_callsign."\t".$qso->COL_RST_SENT." ".$qso->COL_STX." ".$qso->COL_STX_STRING."\t".$qso->COL_CALL."\t".$qso->COL_RST_RCVD." ".$qso->COL_STX." ".$rx_string."\n"; + } else { + return "QSO: ".$freq." ".$mode." ".$time." ".$qso->station_callsign."\t".$qso->COL_RST_SENT." ".$qso->COL_STX."\t".$qso->COL_CALL."\t".$qso->COL_RST_RCVD." ".$qso->COL_STX."\n"; + } + } +} \ No newline at end of file diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 79918db1..6d5c2784 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -160,4 +160,107 @@ class Contesting_model extends CI_Model { return $query; } + + function export_custom($from, $to, $contest_id) { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); + $this->db->from($this->config->item('table_name')); + $this->db->where($this->config->item('table_name').'.station_id', $station_id); + + // If date is set, we format the date and add it to the where-statement + if ($from != 0) { + $from = DateTime::createFromFormat('Y-m-d', $from); + $from = $from->format('Y-m-d'); + $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'"); + } + if ($to != 0) { + $to = DateTime::createFromFormat('Y-m-d', $to); + $to = $to->format('Y-m-d'); + $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'"); + } + + $this->db->where($this->config->item('table_name').'.COL_CONTEST_ID', $contest_id); + + $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); + + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + + return $this->db->get(); + } + + function get_logged_contests2() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select col_contest_id, min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate, year(col_time_on) year, month(col_time_on) month + from logbook l + where coalesce(COL_CONTEST_ID, '') <> '' + and station_id =" . $station_id; + + $sql .= " group by COL_CONTEST_ID , year(col_time_on), month(col_time_on) order by year(col_time_on) desc"; + + $data = $this->db->query($sql); + + return ($data->result()); + } + + function get_logged_years() { + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select distinct year(col_time_on) year + from logbook l + where coalesce(COL_CONTEST_ID, '') <> '' + and station_id =" . $station_id; + + $sql .= " order by year(col_time_on) desc"; + + $data = $this->db->query($sql); + + return ($data->result()); + } + + function get_logged_contests($year) { + $year = $this->security->xss_clean($year); + + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select distinct col_contest_id + from logbook l + where coalesce(COL_CONTEST_ID, '') <> '' + and station_id =" . $station_id . + " and year(col_time_on) ='" . $year . "'"; + + $sql .= " order by COL_CONTEST_ID asc"; + + $data = $this->db->query($sql); + + return $data->result(); + } + + function get_contest_dates($year, $contestid) { + $year = $this->security->xss_clean($year); + $contestid = $this->security->xss_clean($contestid); + + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + $sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate + from logbook l + where coalesce(COL_CONTEST_ID, '') <> '' + and station_id =" . $station_id . + " and year(col_time_on) ='" . $year . "' and col_contest_id ='" . $contestid . "'"; + + $data = $this->db->query($sql); + + return $data->result(); + } } diff --git a/application/views/cabrillo/export.php b/application/views/cabrillo/export.php new file mode 100644 index 00000000..3b6226d0 --- /dev/null +++ b/application/views/cabrillo/export.php @@ -0,0 +1,12 @@ +session->userdata('user_callsign').'-'.date('dmY-Hi').'.log"'); + +$CI =& get_instance(); +$CI->load->library('Cabrilloformat'); + +echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox); +foreach ($qsos->result() as $row) { + echo $CI->cabrilloformat->qso($row); +} +echo $CI->cabrilloformat->footer(); \ No newline at end of file diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php new file mode 100644 index 00000000..2c4b4a1f --- /dev/null +++ b/application/views/cabrillo/index.php @@ -0,0 +1,41 @@ +
+ +
+ +

+ +
+
+ Export a contest to a Cabrillo log +
+
+ + '; + if ($contestyears) { ?> + +
+
+
Select year:
+ + +
+
+
+
+
+
+ + + +
+
+
\ No newline at end of file diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 620ef3fb..5263d56b 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -230,6 +230,8 @@ SOTA CSV Export + Cabrillo Export + Select contest: ' + + '' + + ' '); + + $.each(data, function(key, value) { + $('#contestid') + .append($("") + .attr("value",value.col_contest_id) + .text(value.col_contest_id)); + }); + } + }); +} + +function loadContestDates() { + $.ajax({ + url: base_url+'index.php/cabrillo/getContestDates', + type: 'post', + data: {'year': $("#year").val(), + 'contestid': $("#contestid").val()}, + success: function (data) { + $(".contestdates").append('
Select daterange:
' + + '' + + ' '); + + $.each(data, function(key, value) { + $('#contestdates') + .append($("") + .attr("value", value.mindate + ',' + value.maxdate) + .text(value.mindate + ' - ' + value.maxdate)); + }); + } + }); +} \ No newline at end of file From bcdf01ef2a2c22ee7ab7c406737b3a95f124d176 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 12:12:14 +0200 Subject: [PATCH 02/13] [Cabrillo export] Adjusted javascript to remove correct tags --- assets/js/sections/cabrillo.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/js/sections/cabrillo.js b/assets/js/sections/cabrillo.js index 031b5c81..c5a55c18 100644 --- a/assets/js/sections/cabrillo.js +++ b/assets/js/sections/cabrillo.js @@ -1,6 +1,6 @@ function loadContests() { - $(".stationinfo").empty(); - $(".searchinfo").empty(); + $(".contestname").empty(); + $(".contestdates").empty(); $.ajax({ url: base_url+'index.php/cabrillo/getContests', type: 'post', @@ -22,6 +22,7 @@ function loadContests() { } function loadContestDates() { + $(".contestdates").empty(); $.ajax({ url: base_url+'index.php/cabrillo/getContestDates', type: 'post', From 1249076d6dba5a6b7e5256249490ca819d1bdd87 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:25:15 +0200 Subject: [PATCH 03/13] [Cabrillo export] Fixed tablename --- application/models/Contesting_model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 6d5c2784..7e6dc3f2 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -197,7 +197,7 @@ class Contesting_model extends CI_Model { $station_id = $CI->Stations->find_active(); $sql = "select col_contest_id, min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate, year(col_time_on) year, month(col_time_on) month - from logbook l + from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id; @@ -214,7 +214,7 @@ class Contesting_model extends CI_Model { $station_id = $CI->Stations->find_active(); $sql = "select distinct year(col_time_on) year - from logbook l + from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id; @@ -233,7 +233,7 @@ class Contesting_model extends CI_Model { $station_id = $CI->Stations->find_active(); $sql = "select distinct col_contest_id - from logbook l + from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id . " and year(col_time_on) ='" . $year . "'"; @@ -254,7 +254,7 @@ class Contesting_model extends CI_Model { $station_id = $CI->Stations->find_active(); $sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate - from logbook l + from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id . " and year(col_time_on) ='" . $year . "' and col_contest_id ='" . $contestid . "'"; From 7423c9eae6a15d54156fdba01088a8e39d4a8a7d Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:31:30 +0200 Subject: [PATCH 04/13] [Cabrillo export] Changed filename --- application/views/cabrillo/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/cabrillo/export.php b/application/views/cabrillo/export.php index 3b6226d0..f793d43d 100644 --- a/application/views/cabrillo/export.php +++ b/application/views/cabrillo/export.php @@ -1,6 +1,6 @@ session->userdata('user_callsign').'-'.date('dmY-Hi').'.log"'); +header('Content-Disposition: attachment; filename="'.$callsign.'-'.$contest_id.'-'.date('dmY-Hi').'.cbr"'); $CI =& get_instance(); $CI->load->library('Cabrilloformat'); From ef3c92d9cf46e27dcce70993887c28a4ae92dda2 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 14:24:03 +0200 Subject: [PATCH 05/13] [Cabrillo export] Added station location --- application/controllers/Cabrillo.php | 48 +++++++++++++++++++----- application/libraries/Cabrilloformat.php | 6 ++- application/models/Contesting_model.php | 30 +++------------ application/views/cabrillo/export.php | 2 +- application/views/cabrillo/index.php | 21 +++++++---- assets/js/sections/cabrillo.js | 31 ++++++++++++++- 6 files changed, 92 insertions(+), 46 deletions(-) diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index 5cf61dde..eb921baf 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -9,21 +9,24 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Cabrillo extends CI_Controller { - function __construct() - { + function __construct() { parent::__construct(); $this->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() - { + public function index() { $data['page_title'] = "Export Cabrillo"; $this->load->model('Contesting_model'); + $this->load->model('stations'); - $data['contestyears'] = $this->Contesting_model->get_logged_years(); + $data['station_profile'] = $this->stations->all_of_user(); + $active_station_id = $this->stations->find_active(); + $station_profile = $this->stations->profile($active_station_id); + + $data['active_station_info'] = $station_profile->row(); $footerData = []; $footerData['scripts'] = [ @@ -37,7 +40,20 @@ class Cabrillo extends CI_Controller { public function getContests() { $this->load->model('Contesting_model'); - $result = $this->Contesting_model->get_logged_contests($this->input->post('year')); + + $station_id = $this->security->xss_clean($this->input->post('station_id')); + $year = $this->security->xss_clean($this->input->post('year')); + $result = $this->Contesting_model->get_logged_contests($station_id, $year); + + header('Content-Type: application/json'); + echo json_encode($result); + } + + public function getYears() { + $this->load->model('Contesting_model'); + $station_id = $this->security->xss_clean($this->input->post('station_id')); + + $result = $this->Contesting_model->get_logged_years($station_id); header('Content-Type: application/json'); echo json_encode($result); @@ -45,7 +61,11 @@ class Cabrillo extends CI_Controller { public function getContestDates() { $this->load->model('Contesting_model'); - $result = $this->Contesting_model->get_contest_dates($this->input->post('year'), $this->input->post('contestid')); + $station_id = $this->security->xss_clean($this->input->post('station_id')); + $year = $this->security->xss_clean($this->input->post('year')); + $contestid = $this->security->xss_clean($this->input->post('contestid')); + + $result = $this->Contesting_model->get_contest_dates($station_id, $year, $contestid); header('Content-Type: application/json'); echo json_encode($result); @@ -56,6 +76,11 @@ class Cabrillo extends CI_Controller { ini_set('memory_limit', '-1'); $this->load->model('Contesting_model'); + $this->load->model('stations'); + + + + $station_id = $this->security->xss_clean($this->input->post('station_id')); $contest_id = $this->security->xss_clean($this->input->post('contestid')); $fromto = $this->security->xss_clean($this->input->post('contestdates')); @@ -64,10 +89,14 @@ class Cabrillo extends CI_Controller { $from = $fromto[0]; $to = $fromto[1]; - $data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id); + $station = $this->stations->profile($station_id); + + $station = $station->row(); + + $data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id, $station_id); $data['contest_id'] = $contest_id; - $data['callsign'] = ''; + $data['callsign'] = $station->station_callsign; $data['claimed_score'] = ''; $data['operators'] = ''; $data['club'] = ''; @@ -76,6 +105,7 @@ class Cabrillo extends CI_Controller { $data['address2'] = ''; $data['address3'] = ''; $data['soapbox'] = ''; + $data['gridlocator'] = $station->station_gridsquare; $this->load->view('cabrillo/export', $data); } diff --git a/application/libraries/Cabrilloformat.php b/application/libraries/Cabrilloformat.php index 4f849c74..b3a060bc 100644 --- a/application/libraries/Cabrilloformat.php +++ b/application/libraries/Cabrilloformat.php @@ -2,7 +2,7 @@ class Cabrilloformat { - public function header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox) { + public function header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator) { $cab_header = ""; $cab_header .= "START-OF-LOG: 3.0"."\r\n"; $cab_header .= "CONTEST: ".$contest_id."\r\n"; @@ -24,6 +24,10 @@ class Cabrilloformat { $cab_header .= "ADDRESS: ".$address3."\r\n"; $cab_header .= "SOAPBOX: ".$soapbox."\r\n"; + if($gridlocator != null) { + $cab_header .= "GRID-LOCATOR: ".$gridlocator."\r\n"; + } + return $cab_header; } diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 7e6dc3f2..e139d919 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -161,11 +161,7 @@ class Contesting_model extends CI_Model { return $query; } - function export_custom($from, $to, $contest_id) { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - + function export_custom($from, $to, $contest_id, $station_id) { $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); $this->db->from($this->config->item('table_name')); $this->db->where($this->config->item('table_name').'.station_id', $station_id); @@ -208,10 +204,7 @@ class Contesting_model extends CI_Model { return ($data->result()); } - function get_logged_years() { - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); + function get_logged_years($station_id) { $sql = "select distinct year(col_time_on) year from " . $this->config->item('table_name') . " @@ -222,16 +215,10 @@ class Contesting_model extends CI_Model { $data = $this->db->query($sql); - return ($data->result()); + return $data->result(); } - function get_logged_contests($year) { - $year = $this->security->xss_clean($year); - - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - + function get_logged_contests($station_id, $year) { $sql = "select distinct col_contest_id from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' @@ -245,14 +232,7 @@ class Contesting_model extends CI_Model { return $data->result(); } - function get_contest_dates($year, $contestid) { - $year = $this->security->xss_clean($year); - $contestid = $this->security->xss_clean($contestid); - - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - + function get_contest_dates($station_id, $year, $contestid) { $sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' diff --git a/application/views/cabrillo/export.php b/application/views/cabrillo/export.php index f793d43d..d4e5e6f0 100644 --- a/application/views/cabrillo/export.php +++ b/application/views/cabrillo/export.php @@ -5,7 +5,7 @@ header('Content-Disposition: attachment; filename="'.$callsign.'-'.$contest_id.' $CI =& get_instance(); $CI->load->library('Cabrilloformat'); -echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox); +echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator); foreach ($qsos->result() as $row) { echo $CI->cabrilloformat->qso($row); } diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php index 2c4b4a1f..a002cce3 100644 --- a/application/views/cabrillo/index.php +++ b/application/views/cabrillo/index.php @@ -12,17 +12,22 @@ '; - if ($contestyears) { ?> + + + if ($station_profile) { ?>
-
Select year:
- - +
Select Station Location:
+ + +
+ +
diff --git a/assets/js/sections/cabrillo.js b/assets/js/sections/cabrillo.js index c5a55c18..b2daec13 100644 --- a/assets/js/sections/cabrillo.js +++ b/assets/js/sections/cabrillo.js @@ -1,10 +1,36 @@ +function loadYears() { + $(".contestyear").empty(); + $(".contestname").empty(); + $(".contestdates").empty(); + $.ajax({ + url: base_url+'index.php/cabrillo/getYears', + type: 'post', + data: {'station_id': $("#station_id").val()}, + success: function (data) { + $(".contestyear").append('
Select year:
' + + '' + + ' '); + + $.each(data, function(key, value) { + $('#year') + .append($("") + .attr("value",value.year) + .text(value.year)); + }); + } + }); +} + function loadContests() { $(".contestname").empty(); $(".contestdates").empty(); $.ajax({ url: base_url+'index.php/cabrillo/getContests', type: 'post', - data: {'year': $("#year").val()}, + data: {'year': $("#year").val(), + 'station_id': $("#station_id").val() + }, success: function (data) { $(".contestname").append('
Select contest:
' + '' + From bae96ce1e64f2c894f633ef52d9b0406ddbea75f Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:01:53 +0200 Subject: [PATCH 06/13] [Cabrillo export] Added better date selection --- application/controllers/Cabrillo.php | 9 ++------- application/models/Contesting_model.php | 2 +- assets/js/sections/cabrillo.js | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index eb921baf..d23e5a87 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -78,16 +78,11 @@ class Cabrillo extends CI_Controller { $this->load->model('stations'); - - $station_id = $this->security->xss_clean($this->input->post('station_id')); $contest_id = $this->security->xss_clean($this->input->post('contestid')); - $fromto = $this->security->xss_clean($this->input->post('contestdates')); - $fromto = explode(',', $fromto); - - $from = $fromto[0]; - $to = $fromto[1]; + $from = $this->security->xss_clean($this->input->post('contestdatesfrom')); + $to = $this->security->xss_clean($this->input->post('contestdatesto')); $station = $this->stations->profile($station_id); diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index e139d919..2a615a7f 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -233,7 +233,7 @@ class Contesting_model extends CI_Model { } function get_contest_dates($station_id, $year, $contestid) { - $sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate + $sql = "select distinct (date(col_time_on)) date from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id . diff --git a/assets/js/sections/cabrillo.js b/assets/js/sections/cabrillo.js index b2daec13..f428cdf0 100644 --- a/assets/js/sections/cabrillo.js +++ b/assets/js/sections/cabrillo.js @@ -7,6 +7,7 @@ function loadYears() { type: 'post', data: {'station_id': $("#station_id").val()}, success: function (data) { + if (data.length > 0) { $(".contestyear").append('
Select year:
' + '' + @@ -18,6 +19,9 @@ function loadYears() { .attr("value",value.year) .text(value.year)); }); + } else { + $(".contestyear").append("No contests were found for this station location!"); + } } }); } @@ -56,16 +60,26 @@ function loadContestDates() { 'contestid': $("#contestid").val(), 'station_id': $("#station_id").val()}, success: function (data) { - $(".contestdates").append('
Select daterange:
' + - '' + + '' + + '' + ' '); $.each(data, function(key, value) { - $('#contestdates') + $('#contestdatesfrom') .append($("") - .attr("value", value.mindate + ',' + value.maxdate) - .text(value.mindate + ' - ' + value.maxdate)); + .attr("value", value.date) + .text(value.date)); + }); + + + $.each(data, function(key, value) { + $('#contestdatesto') + .append($("") + .attr("value", value.date) + .text(value.date)); }); } }); From fa947770a82542db4e193ac8b80b4a0da00e1786 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:07:05 +0200 Subject: [PATCH 07/13] [Cabrillo export] Tweaked layout width --- application/views/cabrillo/index.php | 4 ++-- assets/js/sections/cabrillo.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php index a002cce3..1ce852ac 100644 --- a/application/views/cabrillo/index.php +++ b/application/views/cabrillo/index.php @@ -18,8 +18,8 @@
-
Select Station Location:
- result() as $station) { ?> diff --git a/assets/js/sections/cabrillo.js b/assets/js/sections/cabrillo.js index f428cdf0..c12c9c89 100644 --- a/assets/js/sections/cabrillo.js +++ b/assets/js/sections/cabrillo.js @@ -8,7 +8,7 @@ function loadYears() { data: {'station_id': $("#station_id").val()}, success: function (data) { if (data.length > 0) { - $(".contestyear").append('
Select year:
' + + $(".contestyear").append('
Select year:
' + '' + ' '); @@ -36,8 +36,8 @@ function loadContests() { 'station_id': $("#station_id").val() }, success: function (data) { - $(".contestname").append('
Select contest:
' + - '' + '' + ' '); @@ -60,10 +60,10 @@ function loadContestDates() { 'contestid': $("#contestid").val(), 'station_id': $("#station_id").val()}, success: function (data) { - $(".contestdates").append('
Select date range:
' + - '' + '' + - '' + '' + ' '); From 695bf7caa727e61529d322916e2c8e8427326bbd Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:09:34 +0200 Subject: [PATCH 08/13] [Cabrillo export] Increased station location width --- application/views/cabrillo/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php index 1ce852ac..bec0fbfe 100644 --- a/application/views/cabrillo/index.php +++ b/application/views/cabrillo/index.php @@ -19,7 +19,7 @@
Select Station Location:
- result() as $station) { ?> From 36fce4023df70a1f82a923543851015f1c387b50 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2023 16:46:55 +0200 Subject: [PATCH 09/13] Refactor cbr format according to spec --- application/libraries/Cabrilloformat.php | 72 +++++++++++++++++++----- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/application/libraries/Cabrilloformat.php b/application/libraries/Cabrilloformat.php index b3a060bc..56b698e1 100644 --- a/application/libraries/Cabrilloformat.php +++ b/application/libraries/Cabrilloformat.php @@ -38,6 +38,62 @@ class Cabrilloformat { public function qso($qso) { $freq = substr($qso->COL_FREQ, 0, -3); + if ($freq > 30000) { + if ($freq > 250000000) { + $freq = "LIGHT"; + } + if ($freq >= 241000000 && $freq <= 250000000 ) { + $freq = "241G"; + } + if ($freq >= 134000000 && $freq <= 141000000 ) { + $freq = "134G"; + } + if ($freq >= 122250000 && $freq <= 123000000 ) { + $freq = "122G"; + } + if ($freq >= 75500000 && $freq <= 81500000 ) { + $freq = "75G"; + } + if ($freq >= 47000000 && $freq <= 47200000 ) { + $freq = "47G"; + } + if ($freq >= 24000000 && $freq <= 24250000 ) { + $freq = "24G"; + } + if ($freq >= 10000000 && $freq <= 10500000 ) { + $freq = "10G"; + } + if ($freq >= 5650000 && $freq <= 5850000 ) { + $freq = "5.7G"; + } + if ($freq >= 3400000 && $freq <= 3475000 ) { + $freq = "3.4G"; + } + if ($freq >= 2320000 && $freq <= 2450000 ) { + $freq = "2.4G"; + } + if ($freq >= 1240000 && $freq <= 1300000 ) { + $freq = "1.2G"; + } + if ($freq >= 902000 && $freq <= 928000 ) { + $freq = "902"; + } + if ($freq >= 430000 && $freq <= 440000 ) { + $freq = "432"; + } + if ($freq >= 222000 && $freq <= 225000 ) { + $freq = "222"; + } + if ($freq >= 144000 && $freq <= 146000 ) { + $freq = "144"; + } + if ($freq >= 70150 && $freq <= 70210 ) { + $freq = "70"; + } + if ($freq >= 50000 && $freq <= 52000 ) { + $freq = "50"; + } + } if($qso->COL_MODE == "SSB") { $mode = "PH"; @@ -51,17 +107,7 @@ class Cabrilloformat { $time = str_replace(":","",$time); - if ($qso->COL_STX_STRING != "") { - - if($qso->COL_SRX_STRING != "") { - $rx_string = $qso->COL_SRX_STRING; - } else { - $rx_string = "--"; - } - - return "QSO: ".$freq." ".$mode." ".$time." ".$qso->station_callsign."\t".$qso->COL_RST_SENT." ".$qso->COL_STX." ".$qso->COL_STX_STRING."\t".$qso->COL_CALL."\t".$qso->COL_RST_RCVD." ".$qso->COL_STX." ".$rx_string."\n"; - } else { - return "QSO: ".$freq." ".$mode." ".$time." ".$qso->station_callsign."\t".$qso->COL_RST_SENT." ".$qso->COL_STX."\t".$qso->COL_CALL."\t".$qso->COL_RST_RCVD." ".$qso->COL_STX."\n"; - } + // Format according to https://wwrof.org/cabrillo/cabrillo-qso-data/ + return "QSO: ".sprintf("%6s", $freq)." ".$mode." ".$time." ".sprintf("%-13s", $qso->station_callsign)." ".sprintf("%3s", $qso->COL_RST_SENT)." ".sprintf("%-6s", sprintf("%03d", $qso->COL_STX))." ".sprintf("%-13s", $qso->COL_CALL)." ".sprintf("%3s", $qso->COL_RST_RCVD)." ".sprintf("%-6s", sprintf("%03d", $qso->COL_SRX))." 0\n"; } -} \ No newline at end of file +} From a48858acda39401e0a3eab0d7405a440093ae3de Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:30:12 +0200 Subject: [PATCH 10/13] [Cabrillo export] Added more info to the form --- application/controllers/Cabrillo.php | 31 +++-- application/libraries/Cabrilloformat.php | 24 +++- application/views/cabrillo/export.php | 4 +- application/views/cabrillo/index.php | 139 +++++++++++++++++++++++ assets/js/sections/cabrillo.js | 7 +- 5 files changed, 192 insertions(+), 13 deletions(-) diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index d23e5a87..4d02e015 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -78,6 +78,8 @@ class Cabrillo extends CI_Controller { $this->load->model('stations'); + $this->load->model('user_model'); + $station_id = $this->security->xss_clean($this->input->post('station_id')); $contest_id = $this->security->xss_clean($this->input->post('contestid')); @@ -88,18 +90,33 @@ class Cabrillo extends CI_Controller { $station = $station->row(); + $userinfo = $this->user_model->get_by_id($this->session->userdata('user_id')); + + $userinfo = $userinfo->row(); + $data['qsos'] = $this->Contesting_model->export_custom($from, $to, $contest_id, $station_id); $data['contest_id'] = $contest_id; $data['callsign'] = $station->station_callsign; $data['claimed_score'] = ''; - $data['operators'] = ''; - $data['club'] = ''; - $data['name'] = ''; - $data['address1'] = ''; - $data['address2'] = ''; - $data['address3'] = ''; - $data['soapbox'] = ''; + $data['categoryoperator'] = $this->security->xss_clean($this->input->post('categoryoperator')); + $data['categoryassisted'] = $this->security->xss_clean($this->input->post('categoryassisted')); + $data['categoryband'] = $this->security->xss_clean($this->input->post('categoryband')); + $data['categorymode'] = $this->security->xss_clean($this->input->post('categorymode')); + $data['categorypower'] = $this->security->xss_clean($this->input->post('categorypower')); + $data['categorystation'] = $this->security->xss_clean($this->input->post('categorystation')); + $data['categorytransmitter'] = $this->security->xss_clean($this->input->post('categorytransmitter')); + $data['categoryoverlay'] = $this->security->xss_clean($this->input->post('categoryoverlay')); + $data['operators'] = $this->security->xss_clean($this->input->post('operators')); + $data['club'] = $this->security->xss_clean($this->input->post('club')); + $data['name'] = $userinfo->user_firstname . ' ' . $userinfo->user_lastname; + $data['email'] = $userinfo->user_email; + $data['address'] = $this->security->xss_clean($this->input->post('address')); + $data['addresscity'] = $this->security->xss_clean($this->input->post('addresscity')); + $data['addressstateprovince'] = $this->security->xss_clean($this->input->post('addressstateprovince')); + $data['addresspostalcode'] = $this->security->xss_clean($this->input->post('addresspostalcode')); + $data['addresscountry'] = $this->security->xss_clean($this->input->post('addresscountry')); + $data['soapbox'] = $this->security->xss_clean($this->input->post('soapbox')); $data['gridlocator'] = $station->station_gridsquare; $this->load->view('cabrillo/export', $data); diff --git a/application/libraries/Cabrilloformat.php b/application/libraries/Cabrilloformat.php index 56b698e1..55b83f29 100644 --- a/application/libraries/Cabrilloformat.php +++ b/application/libraries/Cabrilloformat.php @@ -2,7 +2,9 @@ class Cabrilloformat { - public function header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator) { + public function header($contest_id, $callsign, $claimed_score, + $operators, $club, $name, $address, $addresscity, $addressstateprovince, $addresspostalcode, $addresscountry, $soapbox, $gridlocator, + $categoryoverlay, $categorytransmitter, $categorystation, $categorypower, $categorymode, $categoryband, $categoryassisted, $categoryoperator, $email) { $cab_header = ""; $cab_header .= "START-OF-LOG: 3.0"."\r\n"; $cab_header .= "CONTEST: ".$contest_id."\r\n"; @@ -18,16 +20,30 @@ class Cabrilloformat { $cab_header .= "CLUB: ".$club."\r\n"; } + $cab_header .= "CATEGORY-OPERATOR: ".$categoryoperator."\r\n"; + $cab_header .= "CATEGORY-BAND: ".$categoryassisted."\r\n"; + $cab_header .= "CATEGORY-ASSISTED: ".$categoryband."\r\n"; + $cab_header .= "CATEGORY-MODE: ".$categorymode."\r\n"; + $cab_header .= "CATEGORY-POWER: ".$categorypower."\r\n"; + $cab_header .= "CATEGORY-STATION: ".$categorystation."\r\n"; + $cab_header .= "CATEGORY-TRANSMITTER: ".$categorytransmitter."\r\n"; + $cab_header .= "CATEGORY-OVERLAY: ".$categoryoverlay."\r\n"; + $cab_header .= "NAME: ".$name."\r\n"; - $cab_header .= "ADDRESS: ".$address1."\r\n"; - $cab_header .= "ADDRESS: ".$address2."\r\n"; - $cab_header .= "ADDRESS: ".$address3."\r\n"; + $cab_header .= "ADDRESS: ".$address."\r\n"; + $cab_header .= "ADDRESS-CITY: ".$addresscity."\r\n"; + $cab_header .= "ADDRESS-STATE-PROVINCE: ".$addressstateprovince."\r\n"; + $cab_header .= "ADDRESS-POSTALCODE: ".$addresspostalcode."\r\n"; + $cab_header .= "ADDRESS-COUNTRY: ".$addresscountry."\r\n"; + $cab_header .= "EMAIL: ".$email."\r\n"; $cab_header .= "SOAPBOX: ".$soapbox."\r\n"; if($gridlocator != null) { $cab_header .= "GRID-LOCATOR: ".$gridlocator."\r\n"; } + $cab_header .= "CREATED-BY: Cloudlog"."\r\n"; + return $cab_header; } diff --git a/application/views/cabrillo/export.php b/application/views/cabrillo/export.php index d4e5e6f0..5b189564 100644 --- a/application/views/cabrillo/export.php +++ b/application/views/cabrillo/export.php @@ -5,7 +5,9 @@ header('Content-Disposition: attachment; filename="'.$callsign.'-'.$contest_id.' $CI =& get_instance(); $CI->load->library('Cabrilloformat'); -echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, $operators, $club, $name, $address1, $address2, $address3, $soapbox, $gridlocator); +echo $CI->cabrilloformat->header($contest_id, $callsign, $claimed_score, + $operators, $club, $name, $address, $addresscity, $addressstateprovince, $addresspostalcode, $addresscountry, $soapbox, $gridlocator, + $categoryoverlay, $categorytransmitter, $categorystation, $categorypower, $categorymode, $categoryband, $categoryassisted, $categoryoperator, $email); foreach ($qsos->result() as $row) { echo $CI->cabrilloformat->qso($row); } diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php index bec0fbfe..e1c3e29e 100644 --- a/application/views/cabrillo/index.php +++ b/application/views/cabrillo/index.php @@ -33,6 +33,145 @@
+ + + + + + + + + + + + + + + + + ' + '' + - ' '); + ' '); $.each(data, function(key, value) { $('#contestdatesfrom') @@ -83,4 +84,8 @@ function loadContestDates() { }); } }); +} + +function addAdditionalInfo() { + $(".additionalinfo").removeAttr("hidden"); } \ No newline at end of file From 01c342f393d3b5fdd197071ec6ede870da8cc6a5 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 14 Apr 2023 08:00:48 +0200 Subject: [PATCH 11/13] [Cabrillo export] Changed order for dropdowns --- application/views/cabrillo/index.php | 122 +++++++++++++-------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/application/views/cabrillo/index.php b/application/views/cabrillo/index.php index e1c3e29e..38824bc7 100644 --- a/application/views/cabrillo/index.php +++ b/application/views/cabrillo/index.php @@ -40,103 +40,103 @@