diff --git a/application/controllers/qso.php b/application/controllers/qso.php index cb64488a..0d85dee8 100644 --- a/application/controllers/qso.php +++ b/application/controllers/qso.php @@ -12,12 +12,15 @@ class QSO extends CI_Controller { public function index() { + + $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['notice'] = false; + $data['radios'] = $this->cat->radios(); $data['query'] = $this->logbook_model->last_ten(); $this->load->library('form_validation'); @@ -45,6 +48,7 @@ class QSO extends CI_Controller { $this->session->set_userdata('mode', $this->input->post('mode')); $this->session->set_userdata('sat_name', $this->input->post('sat_name')); $this->session->set_userdata('sat_mode', $this->input->post('sat_mode')); + $this->session->set_userdata('radio', $this->input->post('radio')); // Get last Ten QSOs $data['query'] = $this->logbook_model->last_ten(); diff --git a/application/controllers/radio.php b/application/controllers/radio.php new file mode 100644 index 00000000..42a17c8e --- /dev/null +++ b/application/controllers/radio.php @@ -0,0 +1,46 @@ +load->model('cat'); + print_r($this->cat->status()); + } + + function frequency($id) { + //$this->db->where('radio', $result['radio']); + $this->db->select('frequency'); + $this->db->where('id', $id); + $query = $this->db->get('cat'); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + echo $row->frequency; + } + } + } + + function mode($id) { + //$this->db->where('radio', $result['radio']); + $this->db->select('mode'); + $this->db->where('id', $id); + $query = $this->db->get('cat'); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + echo strtoupper($row->mode); + } + } + } +} + +?> \ No newline at end of file diff --git a/application/models/cat.php b/application/models/cat.php index e661b9d4..d2fbbb11 100644 --- a/application/models/cat.php +++ b/application/models/cat.php @@ -43,8 +43,34 @@ } function status() { + //$this->db->where('radio', $result['radio']); + $this->db->limit(1); + $query = $this->db->get('cat'); + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + $data = array( + 'radio' => $row->radio, + 'frequency' => $row->frequency, + 'mode' => $row->mode + ); + } + } + + return $data; } + /* Return list of radios */ + function radios() { + $this->db->select('id, radio'); + $query = $this->db->get('cat'); + + return $query; + } + + + } ?> \ No newline at end of file diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 62bb7570..69299bae 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -182,7 +182,14 @@ - + @@ -281,6 +288,127 @@ i=0; $(document).ready(function(){ + + /* Javascript for controlling rig frequency. */ + + // Update frequency every second + setInterval(function() { + if($('select.radios option:selected').val() != '0') { + // Get frequency + $.get('radio/frequency/' + $('select.radios option:selected').val(), function(result) { + $('#frequency').val(result); + if(result >= "100000" && result <= "200000") { + $(".band").val('160m'); + } + if(result >= "300000" && result <= "400000") { + $(".band").val('80m'); + } + if(result >= "525000" && result <= "54500") { + $(".band").val('60m'); + } + if(result >= "700000" && result <= "750000") { + $(".band").val('40m'); + } + if(result >= "1000000" && result <= "110000") { + $(".band").val('30m'); + } + if(result >= "1400000" && result <= "1440000") { + $(".band").val('20m'); + } + if(result >= "1800000" && result <= "1900000") { + $(".band").val('17m'); + } + if(result >= "2100000" && result <= "2160000") { + $(".band").val('15m'); + } + if(result >= "2400000" && result <= "2500000") { + $(".band").val('12m'); + } + if(result >= "2800000" && result <= "3000000") { + $(".band").val('10m'); + } + if(result >= "5000000" && result <= "5600000") { + $(".band").val('6m'); + } + if(result >= "14400000" && result <= "14700000") { + $(".band").val('2m'); + } + if(result >= "43000000" && result <= "44000000") { + $(".band").val('70cm'); + } + }); + + // Get Mode + $.get('radio/mode/' + $('select.radios option:selected').val(), function(result) { + if (result == "LSB" || result == "USB" || result == "SSB") { + $(".mode").val('SSB'); + } else { + $(".mode").val(result); + } + }); + } + }, 1000); + + + // If a radios selected from drop down select radio update. + $('.radios').change(function() { + if($('select.radios option:selected').val() != '0') { + // Get frequency + $.get('radio/frequency/' + $('select.radios option:selected').val(), function(result) { + $('#frequency').val(result); + if(result >= "100000" && result <= "200000") { + $(".band").val('160m'); + } + if(result >= "300000" && result <= "400000") { + $(".band").val('80m'); + } + if(result >= "525000" && result <= "54500") { + $(".band").val('60m'); + } + if(result >= "700000" && result <= "750000") { + $(".band").val('40m'); + } + if(result >= "1000000" && result <= "110000") { + $(".band").val('30m'); + } + if(result >= "1400000" && result <= "1440000") { + $(".band").val('20m'); + } + if(result >= "1800000" && result <= "1900000") { + $(".band").val('17m'); + } + if(result >= "2100000" && result <= "2160000") { + $(".band").val('15m'); + } + if(result >= "2400000" && result <= "2500000") { + $(".band").val('12m'); + } + if(result >= "2800000" && result <= "3000000") { + $(".band").val('10m'); + } + if(result >= "5000000" && result <= "5600000") { + $(".band").val('6m'); + } + if(result >= "14400000" && result <= "14700000") { + $(".band").val('2m'); + } + if(result >= "43000000" && result <= "44000000") { + $(".band").val('70cm'); + } + }); + + // Get Mode + $.get('radio/mode/' + $('select.radios option:selected').val(), function(result) { + if (result == "LSB" || result == "USB" || result == "SSB") { + $(".mode").val('SSB'); + } else { + $(".mode").val(result); + } + }); + + } + }); + /* On Page Load */ var catcher = function() { var changed = false;
Radio + +
Frequency