diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 1c89ecf7..527d251e 100644 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -14,12 +14,14 @@ class QSO extends CI_Controller { { $this->load->model('cat'); + $this->load->model('stations'); $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['stations'] = $this->stations->all(); $data['radios'] = $this->cat->radios(); $data['query'] = $this->logbook_model->last_custom('16'); @@ -57,7 +59,8 @@ class QSO extends CI_Controller { 'mode' => $this->input->post('mode'), 'sat_name' => $this->input->post('sat_name'), 'sat_mode' => $this->input->post('sat_mode'), - 'radio' => $this->input->post('radio') + 'radio' => $this->input->post('radio'), + 'station_profile_id' => $this->input->post('station_profile') ); // ]; diff --git a/application/controllers/Station.php b/application/controllers/Station.php new file mode 100644 index 00000000..037d4d09 --- /dev/null +++ b/application/controllers/Station.php @@ -0,0 +1,61 @@ +load->model('stations'); + $data['stations'] = $this->stations->all(); + + // Render Page + $data['page_title'] = "Station Profiles"; + $this->load->view('layout/header', $data); + $this->load->view('station_profile/index'); + $this->load->view('layout/footer'); + } + + public function create() + { + $this->load->model('stations'); + $this->load->model('dxcc'); + $data['dxcc_list'] = $this->dxcc->list(); + + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('station_profile_name', 'Station Profile Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $data['page_title'] = "Create Station Profile"; + $this->load->view('layout/header', $data); + $this->load->view('station_profile/create'); + $this->load->view('layout/footer'); + } + else + { + $this->stations->add(); + + redirect('station'); + } + } + + public function edit() + { + + } + + public function delete($id) { + $this->load->model('stations'); + $this->stations->delete($id); + + redirect('station'); + } + +} \ No newline at end of file diff --git a/application/libraries/Frequency.php b/application/libraries/Frequency.php index 42e838be..6dfb46a9 100644 --- a/application/libraries/Frequency.php +++ b/application/libraries/Frequency.php @@ -15,6 +15,10 @@ class Frequency { 'SSB'=>"3700000", 'DATA'=>"3583000", "CW"=>"3550000"), + '60m'=>array( + 'SSB'=>"5330000", + 'DATA'=>"5330000", + "CW"=>"5260000"), '40m'=>array( 'SSB'=>"7100000", 'DATA'=>"7040000", diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 04b9fb42..514407d5 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -85,5 +85,10 @@ class DXCC extends CI_Model { function empty_table($table) { $this->db->empty_table($table); } + + function list() { + $this->db->order_by('name', 'ASC'); + return $this->db->get('dxcc_entities'); + } } ?> diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2a4bf960..03271048 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -112,7 +112,6 @@ class Logbook_model extends CI_Model { $locator = $this->config->item('locator'); } - // Create array with QSO Data $data = array( 'COL_TIME_ON' => $datetime, @@ -164,6 +163,29 @@ class Logbook_model extends CI_Model { 'COL_CQZ' => $this->input->post('cqz'), ); + // If station profile has been provided fill in the fields + if($this->input->post('station_profile') != "0") { + $station = $this->check_station($this->input->post('station_profile')); + + if (strpos(trim($station['station_gridsquare']), ',') !== false) { + $data['COL_MY_VUCC_GRIDS'] = strtoupper(trim($station['station_gridsquare'])); + } else { + $data['COL_MY_GRIDSQUARE'] = strtoupper(trim($station['station_gridsquare'])); + } + + $data['COL_MY_CITY'] = strtoupper(trim($station['station_city'])); + $data['COL_MY_IOTA'] = strtoupper(trim($station['station_iota'])); + $data['COL_MY_SOTA_REF'] = strtoupper(trim($station['station_sota'])); + + $data['COL_STATION_CALLSIGN'] = strtoupper(trim($station['station_callsign'])); + $data['COL_MY_DXCC'] = strtoupper(trim($station['station_dxcc'])); + $data['COL_MY_COUNTRY'] = strtoupper(trim($station['station_country'])); + $data['COL_MY_CNTY'] = strtoupper(trim($station['station_cnty'])); + $data['COL_MY_CQ_ZONE'] = strtoupper(trim($station['station_cq'])); + $data['COL_MY_ITU_ZONE'] = strtoupper(trim($station['station_itu'])); + } + + // Decide whether its single gridsquare or a multi which makes it vucc_grids if (strpos(trim($this->input->post('locator')), ',') !== false) { $data['COL_VUCC_GRIDS'] = strtoupper(trim($this->input->post('locator'))); } else { @@ -185,6 +207,17 @@ class Logbook_model extends CI_Model { $this->add_qso($data); } + public function check_station($id){ + + $this->db->where('station_id', $id); + $query = $this->db->get('station_profile'); + + if ($query->num_rows() > 0) { + $row = $query->row_array(); + return($row); + } + } + function add_qso($data) { // Add QSO to database $this->db->insert($this->config->item('table_name'), $data); diff --git a/application/models/Stations.php b/application/models/Stations.php new file mode 100644 index 00000000..c92f4ff9 --- /dev/null +++ b/application/models/Stations.php @@ -0,0 +1,59 @@ +db->get('station_profile'); + } + + + function add() { + $data = array( + 'station_profile_name' => $this->input->post('station_profile_name'), + 'station_gridsquare' => strtoupper($this->input->post('gridsquare')), + 'station_city' => $this->input->post('city'), + 'station_iota' => strtoupper($this->input->post('iota')), + 'station_sota' => strtoupper($this->input->post('sota')), + 'station_callsign' => $this->input->post('station_callsign'), + 'station_dxcc' => $this->input->post('dxcc'), + 'station_country' => $this->input->post('station_country'), + 'station_cnty' => $this->input->post('station_cnty'), + 'station_cq' => $this->input->post('station_cq'), + 'station_itu' => $this->input->post('station_itu'), + ); + + $this->db->insert('station_profile', $data); + } + + function edit() { + $data = array( + 'station_profile_name' => $this->input->post('station_profile_name'), + 'station_gridsquare' => $this->input->post('gridsquare'), + 'station_city' => $this->input->post('city'), + 'station_iota' => $this->input->post('iota'), + 'station_sota' => $this->input->post('sota'), + 'station_callsign' => $this->input->post('station_callsign'), + 'station_dxcc' => $this->input->post('dxcc'), + 'station_country' => $this->input->post('station_country'), + 'station_cnty' => $this->input->post('station_cnty'), + 'station_cq' => $this->input->post('station_cq'), + 'station_itu' => $this->input->post('station_itu'), + ); + + $this->db->where('station_id', $this->input->post('station_id')); + $this->db->update('station_profile', $data); + } + + function delete($id) { + $this->db->delete('station_profile', array('station_id' => $id)); + } + +} + +?> \ No newline at end of file diff --git a/application/views/layout/header.php b/application/views/layout/header.php index 26d63055..35c325ae 100644 --- a/application/views/layout/header.php +++ b/application/views/layout/header.php @@ -79,6 +79,7 @@ Admin