From c124a0200ca410f7adcf2d2d416012fa37564171 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 19 Aug 2019 22:25:50 +0100 Subject: [PATCH] You can now select station profile for ADIF file when importing --- application/controllers/Adif.php | 6 +++++- application/models/Logbook_model.php | 30 +++++++++++++++++++++++++++- application/models/Stations.php | 5 +++++ application/views/adif/import.php | 8 +++++++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/application/controllers/Adif.php b/application/controllers/Adif.php index 02499ac6..7213244f 100644 --- a/application/controllers/Adif.php +++ b/application/controllers/Adif.php @@ -95,6 +95,8 @@ class adif extends CI_Controller { } public function index() { + $this->load->model('stations'); + $data['station_profile'] = $this->stations->all(); $data['page_title'] = "ADIF Import"; $data['max_upload'] = ini_get('upload_max_filesize'); $this->load->view('interface_assets/header', $data); @@ -103,6 +105,8 @@ class adif extends CI_Controller { } public function import() { + $this->load->model('stations'); + $data['station_profile'] = $this->stations->all(); $data['page_title'] = "ADIF Import"; @@ -145,7 +149,7 @@ class adif extends CI_Controller { }; - $this->logbook_model->import($record); + $this->logbook_model->import($record, $this->input->post('station_profile')); }; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index aac155a1..757a31b7 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -917,10 +917,11 @@ class Logbook_model extends CI_Model { return $this->db->get($this->config->item('table_name')); } - function import($record) { + function import($record, $station_id = "0") { $CI =& get_instance(); $CI->load->library('frequency'); + // Join date+time $time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on'])); @@ -1197,6 +1198,33 @@ class Logbook_model extends CI_Model { 'COL_WEB' => (!empty($record['web'])) ? $record['web'] : '' ); + if($station_id != "0") { + $station_result = $this->db->where('station_id', $station_id) + ->get('station_profile'); + + + if ($station_result->num_rows() > 0){ + $row = $station_result->row_array(); + + if (strpos(trim($row['station_gridsquare']), ',') !== false) { + $data['COL_MY_VUCC_GRIDS'] = strtoupper(trim($row['station_gridsquare'])); + } else { + $data['COL_MY_GRIDSQUARE'] = strtoupper(trim($row['station_gridsquare'])); + } + + $data['COL_MY_CITY'] = strtoupper(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_STATION_CALLSIGN'] = strtoupper(trim($row['station_callsign'])); + $data['COL_MY_DXCC'] = strtoupper(trim($row['station_dxcc'])); + $data['COL_MY_COUNTRY'] = strtoupper(trim($row['station_country'])); + $data['COL_MY_CNTY'] = strtoupper(trim($row['station_cnty'])); + $data['COL_MY_CQ_ZONE'] = strtoupper(trim($row['station_cq'])); + $data['COL_MY_ITU_ZONE'] = strtoupper(trim($row['station_itu'])); + } + } + $this->add_qso($data); diff --git a/application/models/Stations.php b/application/models/Stations.php index c92f4ff9..47a8e8f2 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -12,6 +12,11 @@ class Stations extends CI_Model { return $this->db->get('station_profile'); } + function profile($id) { + $this->db->where('station_id', $id); + return $this->db->get('station_profile'); + } + function add() { $data = array( diff --git a/application/views/adif/import.php b/application/views/adif/import.php index 9ebfe5d3..9d794ba0 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -19,7 +19,13 @@

Important Log files must have the file type .adi

-
+ +