diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 349e9c07..da15d933 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -109,6 +109,29 @@ class QSO extends CI_Controller { } } + function qsl_rcvd() { + + $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'); } + $query = $this->logbook_model->qso_info($this->uri->segment(3)); + + $this->load->library('form_validation'); + $this->form_validation->set_rules('id', 'ID', 'required'); + + $data = $query->row(); + if ($this->form_validation->run() == FALSE) + { + $this->load->view('qso/qsl_rcvd', $data); + } + else + { + $this->logbook_model->qsl_rcvd(); + $this->session->set_flashdata('notice', 'QSL registered'); + $this->load->view('qso/qsl_rcvd_done'); + } + } + /* Delete QSO */ function delete($id) { $this->load->model('logbook_model'); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 115b92b4..7e986afc 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -221,6 +221,15 @@ class Logbook_model extends CI_Model { } function add_qso($data) { + + if ($data['COL_DXCC'] == "Not Found"){ + $data['COL_DXCC'] = NULL; + } + + if (!is_null($data['COL_RX_PWR'])) { + $data['COL_RX_PWR'] = str_replace("W", "", $data['COL_RX_PWR']); + } + // Add QSO to database $this->db->insert($this->config->item('table_name'), $data); } @@ -269,6 +278,20 @@ class Logbook_model extends CI_Model { } + + /* QSL received */ + function qsl_rcvd() { + + $data = array( + 'COL_QSLRDATE' => date('Y-m-d'), + 'COL_QSL_RCVD' => "Y" + ); + + $this->db->where('COL_PRIMARY_KEY', $this->input->post('id')); + $this->db->update($this->config->item('table_name'), $data); + + } + /* Return last 10 QSOs */ function last_ten() { $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME'); @@ -830,7 +853,11 @@ class Logbook_model extends CI_Model { // DXCC id - $dxcc = $this->check_dxcc_table($record['call'], $time_off); + if (isset($record['call'])){ + $dxcc = $this->check_dxcc_table($record['call'], $time_off); + } else { + $dxcc = NULL; + } // Store or find country name if(isset($record['country'])) { @@ -883,10 +910,13 @@ class Logbook_model extends CI_Model { } elseif(isset($dxcc[2])) { $cq_zone = $dxcc[2]; } else { - $cq_zone = ""; + //$cq_zone = ""; + $cq_zone = NULL; } - $this->db->where('COL_CALL', $record['call']); + if (isset($record['call'])){ + $this->db->where('COL_CALL', $record['call']); + } $this->db->where('COL_TIME_ON', $time_on); $check = $this->db->get($this->config->item('table_name')); diff --git a/application/views/view_log/partial/log.php b/application/views/view_log/partial/log.php index 29474615..124f27db 100644 --- a/application/views/view_log/partial/log.php +++ b/application/views/view_log/partial/log.php @@ -18,6 +18,7 @@ LoTW + @@ -58,6 +59,7 @@ Edit + QSL RCVD config->item('callsign_tags') == true) { ?> COL_STATION_CALLSIGN != null) { ?> COL_STATION_CALLSIGN; ?> diff --git a/index.php b/index.php index 7d8fe56d..93c6cc50 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,8 @@ * NOTE: If you change these, also change the error_reporting() code below */ #define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); - define('ENVIRONMENT', 'development'); +# define('ENVIRONMENT', 'development'); + define('ENVIRONMENT', 'production'); /* *---------------------------------------------------------------