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] 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