From b9e53b48ca8063940facbf78a8746964f13e5f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=A4del?= Date: Mon, 25 Feb 2019 23:13:09 +0100 Subject: [PATCH 1/3] Fixed CAT database layout, added downlink frequency selection, repaired frequency storage over multiple QSOs --- application/controllers/Qso.php | 111 ++----- application/controllers/Radio.php | 24 +- application/views/qso/manual.php | 530 ------------------------------ sql/tables/cat.sql | 4 +- 4 files changed, 42 insertions(+), 627 deletions(-) delete mode 100644 application/views/qso/manual.php diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 527d251e..69ae43c4 100644 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -43,29 +43,30 @@ class QSO extends CI_Controller { { // Add QSO // $this->logbook_model->add(); - //change to create_qso function as add and create_qso duplicate functionality - $this->logbook_model->create_qso(); - + //change to create_qso function as add and create_qso duplicate functionality + $this->logbook_model->create_qso(); + // Store Basic QSO Info for reuse - // Put data in an array first, then call set_userdata once. - // This solves the problem of CI dumping out the session - // cookie each time set_userdata is called. - // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/ - // $qso_data = [ - // 18-Jan-2016 - make php v5.3 friendly! - $qso_data = array( - 'band' => $this->input->post('band'), - 'freq' => $this->input->post('freq'), - 'mode' => $this->input->post('mode'), - 'sat_name' => $this->input->post('sat_name'), - 'sat_mode' => $this->input->post('sat_mode'), - 'radio' => $this->input->post('radio'), - 'station_profile_id' => $this->input->post('station_profile') - ); - // ]; + // Put data in an array first, then call set_userdata once. + // This solves the problem of CI dumping out the session + // cookie each time set_userdata is called. + // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/ + // $qso_data = [ + // 18-Jan-2016 - make php v5.3 friendly! + $qso_data = array( + 'band' => $this->input->post('band'), + 'freq' => $this->input->post('freq_display'), + 'freq_rx' => $this->input->post('freq_display_rx'), + 'mode' => $this->input->post('mode'), + 'sat_name' => $this->input->post('sat_name'), + 'sat_mode' => $this->input->post('sat_mode'), + 'radio' => $this->input->post('radio'), + 'station_profile_id' => $this->input->post('station_profile') + ); + // ]; - $this->session->set_userdata($qso_data); - + $this->session->set_userdata($qso_data); + // Get last 16 qsos $data['query'] = $this->logbook_model->last_custom('16'); @@ -81,74 +82,6 @@ class QSO extends CI_Controller { } } - /* - Function: manual - Usage: Post QSO Logging - */ - - public function manual() - { - - $this->load->model('cat'); - $this->load->model('logbook_model'); - $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'); } - - - $data['notice'] = false; - $data['radios'] = $this->cat->radios(); - $data['query'] = $this->logbook_model->last_custom('16'); - - $this->load->library('form_validation'); - - $this->form_validation->set_rules('start_date', 'Date', 'required'); - $this->form_validation->set_rules('start_time', 'Time', 'required'); - $this->form_validation->set_rules('callsign', 'Callsign', 'required'); - - if ($this->form_validation->run() == FALSE) - { - $data['page_title'] = "Add QSO"; - - $this->load->view('layout/header', $data); - $this->load->view('qso/manual'); - $this->load->view('layout/footer'); - } - else - { - // Add QSO - $this->logbook_model->create_qso(); - - // Store Basic QSO Info for reuse - //$qso_data = [ - // 18-Jan-2016 - make php v5.3 friendly! - $qso_data = array( - 'band' => $this->input->post('band'), - 'freq' => $this->input->post('freq'), - 'mode' => $this->input->post('mode'), - 'sat_name' => $this->input->post('sat_name'), - 'sat_mode' => $this->input->post('sat_mode'), - 'radio' => $this->input->post('radio') - ); - //]; - - $this->session->set_userdata($qso_data); - - // Get last Ten QSOs - $data['query'] = $this->logbook_model->last_ten(); - - // Set Any Notice Messages - $data['notice'] = "QSO Added"; - - // Load view to create another contact - $data['page_title'] = "Manual QSO"; - - $this->load->view('layout/header', $data); - $this->load->view('qso/manual'); - $this->load->view('layout/footer'); - } - } - - function edit() { $this->load->model('logbook_model'); diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index fae31806..c2cb6940 100644 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -61,7 +61,11 @@ } - function frequency($id) { + function frequency_downlink($id) { + return $this->frequency($id, true); + } + + function frequency($id, $downlink = false) { // Check Auth $this->load->model('user_model'); @@ -77,19 +81,25 @@ foreach ($query->result() as $row) { if( $row->frequency == "0") { - $this->db->select('uplink_freq'); + $this->db->select('uplink_freq, downlink_freq'); $this->db->where('id', $id); $query = $this->db->get('cat'); if ($query->num_rows() > 0) { - foreach ($query->result() as $row) + foreach ($query->result() as $row) { - echo strtoupper($row->uplink_freq); + if ($downlink) + echo strtoupper($row->downlink_freq); + else + echo strtoupper($row->uplink_freq); } } } else { - echo $row->frequency; + if ($downlink) + echo ""; + else + echo strtoupper($row->frequency); } } } @@ -168,7 +178,9 @@ { foreach ($query->result() as $row) { - + $uplink_mode = ""; + $downlink_mode = ""; + if ($row->uplink_freq > 144000000 && $row->uplink_freq < 147000000) { $uplink_mode = "V"; } elseif ($row->uplink_freq > 432000000 && $row->uplink_freq < 438000000) { diff --git a/application/views/qso/manual.php b/application/views/qso/manual.php deleted file mode 100644 index 9a6cec42..00000000 --- a/application/views/qso/manual.php +++ /dev/null @@ -1,530 +0,0 @@ - - - - - - - - - - -
- - -
- -
- - - -
- -
- - -
-
- -

Manual QSO

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date
Callsign
Mode - - Band -
RST (S) RST (R)
Name
Location
Locator
Comment
- - -
- -
- - - -
-
- - - - - - - - - -
Propagation Mode - -
IOTA e.g: EU-005
-
-
- - - - - - - - - -
Radio - -
Frequency
-
-
- - - - - - - - - - -
Sat Name
Sat Mode
-
-
- - - - - - - - - - - - - -
Sent
Method
Via
-
-
- -
- - -
-
-
- -
-

Last 16 QSOs

- - - - - - - - - - - - - result() as $row) { ?> - - '; ?> - - - - - - - COL_SAT_NAME != null) { ?> - - - - - - - -
DateTimeCallModeSentRecvBand
COL_TIME_ON); echo date('d/m/y', $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?>COL_PRIMARY_KEY; ?>">COL_CALL); ?>COL_MODE; ?>COL_RST_SENT; ?>COL_RST_RCVD; ?>COL_SAT_NAME; ?>COL_BAND; ?>
- -
-
- -
- - - - \ No newline at end of file diff --git a/sql/tables/cat.sql b/sql/tables/cat.sql index f55b3f7d..e10e7ae7 100644 --- a/sql/tables/cat.sql +++ b/sql/tables/cat.sql @@ -1,10 +1,10 @@ CREATE TABLE IF NOT EXISTS `cat` ( `id` int(11) NOT NULL auto_increment, `radio` varchar(250) NOT NULL, - `frequency` int(11) NOT NULL, + `frequency` bigint(13) NOT NULL, `mode` varchar(10) NOT NULL, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ; -ALTER TABLE `cat` ADD `downlink_freq` INT(11) DEFAULT NULL AFTER `mode`, ADD `uplink_freq` INT(11) DEFAULT NULL AFTER `downlink_freq`, ADD `downlink_mode` VARCHAR(255) DEFAULT NULL AFTER `uplink_freq`, ADD `uplink_mode` VARCHAR(255) DEFAULT NULL AFTER `downlink_mode`, ADD `sat_name` VARCHAR(255) DEFAULT NULL AFTER `uplink_mode`; \ No newline at end of file +ALTER TABLE `cat` ADD `downlink_freq` bigint(13) DEFAULT NULL AFTER `mode`, ADD `uplink_freq` bigint(13) DEFAULT NULL AFTER `downlink_freq`, ADD `downlink_mode` VARCHAR(255) DEFAULT NULL AFTER `uplink_freq`, ADD `uplink_mode` VARCHAR(255) DEFAULT NULL AFTER `downlink_mode`, ADD `sat_name` VARCHAR(255) DEFAULT NULL AFTER `uplink_mode`; \ No newline at end of file From 47ea38b4e7be110fcd31359415a7865d5bdb08a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=A4del?= Date: Mon, 25 Feb 2019 23:17:00 +0100 Subject: [PATCH 2/3] Fix invalid sat mode output --- application/controllers/Radio.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index c2cb6940..588544ca 100644 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -180,7 +180,7 @@ { $uplink_mode = ""; $downlink_mode = ""; - + if ($row->uplink_freq > 144000000 && $row->uplink_freq < 147000000) { $uplink_mode = "V"; } elseif ($row->uplink_freq > 432000000 && $row->uplink_freq < 438000000) { @@ -196,8 +196,9 @@ } elseif ($row->downlink_freq > 28000000 && $row->downlink_freq < 30000000) { $downlink_mode = "A"; } - - echo $uplink_mode."/".$downlink_mode; + + if ($uplink_mode != "" && $downlink_mode != "") + echo $uplink_mode."/".$downlink_mode; } } } From 3077fe7c7967532aa9861fd8e02caf1ed6057040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=A4del?= Date: Mon, 25 Feb 2019 23:17:23 +0100 Subject: [PATCH 3/3] Save downlink frequency in the database --- application/models/Logbook_model.php | 6 +++--- application/views/qso/index.php | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 03271048..5f7651cc 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -60,7 +60,7 @@ class Logbook_model extends CI_Model { 'COL_IOTA' => trim($this->input->post('iota_ref')), 'COL_MY_GRIDSQUARE' => strtoupper($locator), 'COL_DISTANCE' => "0", - 'COL_FREQ_RX' => 0, + 'COL_FREQ_RX' => $this->input->post('freq_display_rx'), 'COL_BAND_RX' => null, 'COL_ANT_AZ' => null, 'COL_ANT_EL' => null, @@ -141,7 +141,7 @@ class Logbook_model extends CI_Model { 'COL_IOTA' => trim($this->input->post('iota_ref')), 'COL_MY_GRIDSQUARE' => $locator, 'COL_DISTANCE' => "0", - 'COL_FREQ_RX' => 0, + 'COL_FREQ_RX' => $this->input->post('freq_display_rx'), 'COL_BAND_RX' => null, 'COL_ANT_AZ' => null, 'COL_ANT_EL' => null, @@ -255,7 +255,7 @@ class Logbook_model extends CI_Model { 'COL_IOTA' => $this->input->post('iota_ref'), 'COL_QTH' => $this->input->post('qth'), 'COL_PROP_MODE' => $this->input->post('prop_mode'), - 'COL_FREQ_RX' => '0', + 'COL_FREQ_RX' => $this->input->post('freq_display_rx'), 'COL_STX_STRING' => $this->input->post('stx_string'), 'COL_SRX_STRING' => $this->input->post('srx_string') ); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index b7ede3cc..c23ea6c5 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -215,7 +215,11 @@ Frequency - + + + + Frequency (RX) + @@ -337,7 +341,13 @@ $(".band").val(frequencyToBand(result)); } }); - + $.get('radio/frequency_downlink/' + $('select.radios option:selected').val(), function(result) { + if(result == "0") { + } else { + $('#frequency_rx').val(result); + } + }); + // Get Mode $.get('radio/mode/' + $('select.radios option:selected').val(), function(result) { if (result == "LSB" || result == "USB" || result == "SSB") { @@ -415,15 +425,21 @@ $(window).bind('beforeunload', catcher); }); - $.get('qso/band_to_freq/' + $('.band').val() + '/' + $('.mode').val(), function(result) { + // Only set the frequency when not set by userdata/PHP. + if ($('#frequency').val() == "") + { + $.get('qso/band_to_freq/' + $('.band').val() + '/' + $('.mode').val(), function(result) { $('#frequency').val(result); - }); + $('#frequency_rx').val(""); + }); + } /* Calculate Frequency */ /* on band change */ $('.band').change(function() { $.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function(result) { $('#frequency').val(result); + $('#frequency_rx').val(""); }); }); @@ -431,9 +447,9 @@ $('.mode').change(function() { $.get('qso/band_to_freq/' + $('.band').val() + '/' + $('.mode').val(), function(result) { $('#frequency').val(result); + $('#frequency_rx').val(""); }); - }); - + }); /* On Key up Calculate Bearing and Distance */ $("#locator").keyup(function(){ if ($(this).val()) {