diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 28a966fc5..38c210ff6 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -28,11 +28,6 @@ class Logbook extends CI_Controller { } $this->load->model('stations'); - // If environment is set to development then show the debug toolbar - if(ENVIRONMENT == 'development') { - $this->output->enable_profiler(TRUE); - } - $this->load->model('logbook_model'); $this->load->library('pagination'); @@ -613,17 +608,17 @@ class Logbook extends CI_Controller { $data['query'] = $this->logbook_model->get_qso($id); $data['dxccFlag'] = $this->dxccflag->get($data['query']->result()[0]->COL_DXCC); - if ($this->session->userdata('user_measurement_base') == NULL) { - $data['measurement_base'] = $this->config->item('measurement_base'); - } - else { - $data['measurement_base'] = $this->session->userdata('user_measurement_base'); - } + if ($this->session->userdata('user_measurement_base') == NULL) { + $data['measurement_base'] = $this->config->item('measurement_base'); + } + else { + $data['measurement_base'] = $this->session->userdata('user_measurement_base'); + } - $this->load->model('Qsl_model'); - $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); - $data['primary_subdivision'] = $this->subdivisions->get_primary_subdivision_name($data['query']->result()[0]->COL_DXCC); - $data['secondary_subdivision'] = $this->subdivisions->get_secondary_subdivision_name($data['query']->result()[0]->COL_DXCC); + $this->load->model('Qsl_model'); + $data['qslimages'] = $this->Qsl_model->getQslForQsoId($id); + $data['primary_subdivision'] = $this->subdivisions->get_primary_subdivision_name($data['query']->result()[0]->COL_DXCC); + $data['secondary_subdivision'] = $this->subdivisions->get_secondary_subdivision_name($data['query']->result()[0]->COL_DXCC); $data['max_upload'] = ini_get('upload_max_filesize'); $this->load->view('interface_assets/mini_header', $data); $this->load->view('view_log/qso'); diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 0463722be..a3ae8a020 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -18,18 +18,17 @@ class QSO extends CI_Controller { 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() { $this->load->model('cat'); $this->load->model('stations'); $this->load->model('logbook_model'); $this->load->model('user_model'); $this->load->model('modes'); - $this->load->model('bands'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->load->model('bands'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } $data['active_station_profile'] = $this->stations->find_active(); - + $data['notice'] = false; $data['stations'] = $this->stations->all_of_user(); $data['radios'] = $this->cat->radios(); @@ -50,21 +49,21 @@ class QSO extends CI_Controller { $this->form_validation->set_rules('mode', 'Mode', 'required'); $this->form_validation->set_rules('locator', 'Locator', 'callback_check_locator'); - // [eQSL default msg] GET user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // + // [eQSL default msg] GET user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // $this->load->model('user_options_model'); $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg',array('option_name'=>'key_station_id','option_key'=>$data['active_station_profile']))->result(); $data['qslmsg'] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; - if ($this->form_validation->run() == FALSE) - { + if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Add QSO"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('qso/index'); - $this->load->view('interface_assets/footer'); - } - else - { + if (validation_errors() != '') { // we're coming from a failed ajax-call + echo json_encode(array('message' => 'Error','errors' => validation_errors())); + } else { // we're not coming from a POST + $this->load->view('interface_assets/header', $data); + $this->load->view('qso/index'); + $this->load->view('interface_assets/footer'); + } + } else { // 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 @@ -73,9 +72,9 @@ class QSO extends CI_Controller { // $qso_data = [ // 18-Jan-2016 - make php v5.3 friendly! $qso_data = array( - 'start_date' => $this->input->post('start_date'), - 'start_time' => $this->input->post('start_time'), - 'end_time' => $this->input->post('end_time'), + 'start_date' => $this->input->post('start_date'), + 'start_time' => $this->input->post('start_time'), + 'end_time' => $this->input->post('end_time'), 'time_stamp' => time(), 'band' => $this->input->post('band'), 'band_rx' => $this->input->post('band_rx'), @@ -99,8 +98,8 @@ class QSO extends CI_Controller { // If SAT name is set make it session set to sat if($this->input->post('sat_name')) { - $this->session->set_userdata('prop_mode', 'SAT'); - } + $this->session->set_userdata('prop_mode', 'SAT'); + } // Add QSO // $this->logbook_model->add(); @@ -108,17 +107,7 @@ class QSO extends CI_Controller { $this->logbook_model->create_qso(); // Get last 5 qsos - $data['query'] = $this->logbook_model->last_custom('5'); - - // Set Any Notice Messages - $data['notice'] = "QSO Added"; - - // Load view to create another contact - $data['page_title'] = "Add QSO"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('qso/index'); - $this->load->view('interface_assets/footer'); + echo json_encode(array('message' => 'success')); } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index a9636cde7..beb7c8197 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1044,6 +1044,12 @@ class Logbook_model extends CI_Model { $station_profile=$this->stations->profile_clean($stationId); $stationCallsign=$station_profile->station_callsign; + $iotaRef = $station_profile->station_iota ?? ''; + $sotaRef = $station_profile->station_sota ?? ''; + $wwffRef = $station_profile->station_wwff ?? ''; + $potaRef = $station_profile->station_pota ?? ''; + $sig = $station_profile->station_sig ?? ''; + $sigInfo = $station_profile->station_sig_info ?? ''; $mode = $this->get_main_mode_if_submode($this->input->post('mode')); if ($mode == null) { @@ -1222,7 +1228,13 @@ class Logbook_model extends CI_Model { 'COL_STATION_CALLSIGN' => $stationCallsign, 'COL_OPERATOR' => $this->input->post('operator_callsign'), 'COL_STATE' =>$this->input->post('usa_state'), - 'COL_CNTY' => $uscounty + 'COL_CNTY' => $uscounty, + 'COL_MY_IOTA' => $iotaRef, + 'COL_MY_SOTA_REF' => $sotaRef, + 'COL_MY_WWFF_REF' => $wwffRef, + 'COL_MY_POTA_REF' => $potaRef, + 'COL_MY_SIG' => $sig, + 'COL_MY_SIG_INFO' => $sigInfo ); if ($this->exists_hrdlog_credentials($data['station_id'])) { @@ -3778,10 +3790,12 @@ function lotw_last_qsl_date($user_id) { } $data['COL_MY_CITY'] = trim($row['station_city']); - $data['COL_MY_IOTA'] = strtoupper(trim($row['station_iota'])); - $data['COL_MY_SOTA_REF'] = strtoupper(trim($row['station_sota'])); - $data['COL_MY_WWFF_REF'] = strtoupper(trim($row['station_wwff'])); - $data['COL_MY_POTA_REF'] = $row['station_pota'] == null ? '' : strtoupper(trim($row['station_pota'])); + $data['COL_MY_IOTA'] = strtoupper(trim($row['station_iota'] ?? '')); + $data['COL_MY_SOTA_REF'] = strtoupper(trim($row['station_sota'] ?? '')); + $data['COL_MY_WWFF_REF'] = strtoupper(trim($row['station_wwff'] ?? '')); + $data['COL_MY_POTA_REF'] = strtoupper(trim($row['station_pota'] ?? '')); + $data['COL_MY_SIG'] = strtoupper(trim($row['station_sig'] ?? '')); + $data['COL_MY_SIG_INFO'] = strtoupper(trim($row['station_sig_info'] ?? '')); $data['COL_STATION_CALLSIGN'] = strtoupper(trim($row['station_callsign'])); $data['COL_MY_DXCC'] = strtoupper(trim($row['station_dxcc'])); diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 558e11f38..7e97f6495 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1054,29 +1054,6 @@ $($('#callsign')).on('keypress',function(e) { } }; - $(function() { - $('form').each(function() { - $(this).data('initialForm', $(this).serialize()); - }).submit(function(e) { - var formEl = this; - var changed = false; - $('form').each(function() { - if (this != formEl && $(this).data('initialForm') != $(this).serialize()) { - changed = true; - $(this).addClass('changed'); - } else { - $(this).removeClass('changed'); - } - }); - if (changed && !confirm('You have an unsaved QSO. Continue with QSO?')) { - e.preventDefault(); - } else { - $(window).unbind('beforeunload', catcher); - } - }); - $(window).bind('beforeunload', catcher); - }); - // Callsign always has focus on load $("#callsign").focus(); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index bd060c8fc..251be9f18 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -558,7 +558,7 @@ - + @@ -568,6 +568,7 @@
+