diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php
index 642e6fa5..b18cf0b8 100644
--- a/application/controllers/Eqsl.php
+++ b/application/controllers/Eqsl.php
@@ -15,6 +15,7 @@ class eqsl extends CI_Controller {
$folder_name = "images/eqsl_card_images";
$data['storage_used'] = $this->sizeFormat($this->folderSize($folder_name));
+
// Render Page
$data['page_title'] = "eQSL Cards";
@@ -29,6 +30,12 @@ class eqsl extends CI_Controller {
$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'); }
+ $this->load->model('stations');
+ $data['station_profile'] = $this->stations->all_of_user();
+ $active_station_id = $this->stations->find_active();
+ $station_profile = $this->stations->profile($active_station_id);
+ $data['active_station_info'] = $station_profile->row();
+
// Check if eQSL Nicknames have been defined
$this->load->model('eqslmethods_model');
$eqsl_locations = $this->eqslmethods_model->all_of_user_with_eqsl_nick_defined();
@@ -71,29 +78,39 @@ class eqsl extends CI_Controller {
$eqsl_results[] = $this->eqslimporter->fetch($eqsl_password);
}
- }
- else
- {
- if ( ! $this->upload->do_upload())
- {
- $data['page_title'] = "eQSL Import";
- $data['error'] = $this->upload->display_errors();
+ } elseif ($this->input->post('eqslimport') == 'upload') {
+ $station_id4upload=$this->input->post('station_profile');
+ if ($this->stations->check_station_is_accessible($station_id4upload)) {
+ $station_callsign=$this->stations->profile($station_id4upload)->row()->station_callsign;
+ if ( ! $this->upload->do_upload())
+ {
+ $data['page_title'] = "eQSL Import";
+ $data['error'] = $this->upload->display_errors();
- $this->load->view('interface_assets/header', $data);
- $this->load->view('eqsl/import');
- $this->load->view('interface_assets/footer');
+ $this->load->view('interface_assets/header', $data);
+ $this->load->view('eqsl/import');
+ $this->load->view('interface_assets/footer');
- return;
+ return;
+ } else {
+ $data = array('upload_data' => $this->upload->data());
+
+ $this->load->library('EqslImporter');
+ $this->eqslimporter->from_file('./uploads/'.$data['upload_data']['file_name'],$station_callsign);
+
+ $eqsl_results[] = $this->eqslimporter->import();
+ }
+ } else {
+ log_message('error',$station_id4upload." is not valid for user!");
}
- else
- {
- $data = array('upload_data' => $this->upload->data());
+ } else {
+ $data['page_title'] = "eQSL Import";
- $this->load->library('EqslImporter');
- $this->eqslimporter->from_file('./uploads/'.$data['upload_data']['file_name']);
+ $this->load->view('interface_assets/header', $data);
+ $this->load->view('eqsl/import');
+ $this->load->view('interface_assets/footer');
- $eqsl_results[] = $this->eqslimporter->import();
- }
+ return;
}
$data['eqsl_results'] = $eqsl_results;
diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php
index eb00dd44..14602ef7 100644
--- a/application/controllers/Lotw.php
+++ b/application/controllers/Lotw.php
@@ -497,7 +497,7 @@ class Lotw extends CI_Controller {
$record['qsl_rcvd'] = $config['lotw_rcvd_mark'];
}
- $status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
+ $status = $this->logbook_model->import_check($time_on, $record['call'], $record['band'],$record['station_callsign']);
$skipNewQso = $this->input->post('importMissing'); // If import missing was checked
if($status[0] == "No Match" && $skipNewQso != NULL) {
@@ -550,7 +550,12 @@ class Lotw extends CI_Controller {
$ituz = "";
}
- $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz);
+ $station_id = $this->logbook_model->find_correct_station_id($record['station_callsign'], $record['my_gridsquare']);
+ if ($station_id != NULL) {
+ $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd'], $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz, $station_id);
+ } else {
+ $lotw_status = "No matching Grid/OP-Call (check Locations)";
+ }
}
diff --git a/application/libraries/EqslImporter.php b/application/libraries/EqslImporter.php
index 77cc8701..c22e0208 100644
--- a/application/libraries/EqslImporter.php
+++ b/application/libraries/EqslImporter.php
@@ -36,8 +36,9 @@ class EqslImporter
$this->qth_nickname = $qth;
}
- public function from_file($adif_file) {
+ public function from_file($adif_file,$station_callsign) {
$this->init('ADIF upload', $adif_file);
+ $this->callsign=$station_callsign;
}
// generate a sanitized file name from a callsign and a QTH nickname
@@ -136,6 +137,7 @@ class EqslImporter
$query = $this->CI->db->query('SELECT eqsl_rcvd_mark FROM config');
$q = $query->row();
$config['eqsl_rcvd_mark'] = $q->eqsl_rcvd_mark;
+ $station_callsign=$this->callsign;
$this->CI->adif_parser->load_from_file($this->adif_file);
$this->CI->adif_parser->initialize();
@@ -154,14 +156,14 @@ class EqslImporter
$record['qsl_sent'] = $config['eqsl_rcvd_mark'];
}
- $status = $this->CI->logbook_model->import_check($time_on, $record['call'], $record['band']);
+ $status = $this->CI->logbook_model->import_check($time_on, $record['call'], $record['band'],$station_callsign);
$qsoid = 0;
if ($status[0] == "Found") {
$qsoid = $status[1];
- $dupe = $this->CI->eqslmethods_model->eqsl_dupe_check($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']);
+ $dupe = $this->CI->eqslmethods_model->eqsl_dupe_check($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark'],$station_callsign);
if ($dupe == false) {
$updated += 1;
- $eqsl_status = $this->CI->eqslmethods_model->eqsl_update($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']);
+ $eqsl_status = $this->CI->eqslmethods_model->eqsl_update($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark'],$station_callsign);
} else {
$dupes += 1;
$eqsl_status = "Already received an eQSL for this QSO.";
diff --git a/application/models/Eqslmethods_model.php b/application/models/Eqslmethods_model.php
index 369a4117..e53ea5c3 100644
--- a/application/models/Eqslmethods_model.php
+++ b/application/models/Eqslmethods_model.php
@@ -156,7 +156,7 @@ class Eqslmethods_model extends CI_Model {
// Update a QSO with eQSL QSL info
// We could also probably use this use this: http://eqsl.cc/qslcard/VerifyQSO.txt
// http://www.eqsl.cc/qslcard/ImportADIF.txt
- function eqsl_update($datetime, $callsign, $band, $qsl_status) {
+ function eqsl_update($datetime, $callsign, $band, $qsl_status,$station_callsign) {
$data = array(
'COL_EQSL_QSLRDATE' => date('Y-m-d H:i:s'), // eQSL doesn't give us a date, so let's use current
'COL_EQSL_QSL_RCVD' => $qsl_status
@@ -165,6 +165,7 @@ class Eqslmethods_model extends CI_Model {
$this->db->where('COL_TIME_ON >= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL -15 MINUTE )');
$this->db->where('COL_TIME_ON <= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL 15 MINUTE )');
$this->db->where('COL_CALL', $callsign);
+ $this->db->where('COL_STATION_CALLSIGN', $station_callsign);
$this->db->where('COL_BAND', $band);
$this->db->update($this->config->item('table_name'), $data);
@@ -173,12 +174,13 @@ class Eqslmethods_model extends CI_Model {
}
// Determine if we've already received an eQSL for this QSO
- function eqsl_dupe_check($datetime, $callsign, $band, $qsl_status) {
+ function eqsl_dupe_check($datetime, $callsign, $band, $qsl_status,$station_callsign) {
$this->db->select('COL_EQSL_QSLRDATE');
$this->db->where('COL_TIME_ON >= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL -15 MINUTE )');
$this->db->where('COL_TIME_ON <= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL 15 MINUTE )');
$this->db->where('COL_CALL', $callsign);
$this->db->where('COL_BAND', $band);
+ $this->db->where('COL_STATION_CALLSIGN', $station_callsign);
$this->db->where('COL_EQSL_QSL_RCVD', $qsl_status);
$this->db->limit(1);
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 7900a6ca..e612c5ff 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -2469,12 +2469,13 @@ class Logbook_model extends CI_Model {
}
/* Used to check if the qso is already in the database */
- function import_check($datetime, $callsign, $band) {
+ function import_check($datetime, $callsign, $band,$station_callsign) {
$this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_BAND');
$this->db->where('COL_TIME_ON >= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL -15 MINUTE )');
$this->db->where('COL_TIME_ON <= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL 15 MINUTE )');
$this->db->where('COL_CALL', $callsign);
+ $this->db->where('COL_STATION_CALLSIGN', $station_callsign);
$this->db->where('COL_BAND', $band);
$query = $this->db->get($this->config->item('table_name'));
@@ -2488,7 +2489,7 @@ class Logbook_model extends CI_Model {
}
}
- function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz) {
+ function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status, $state, $qsl_gridsquare, $iota, $cnty, $cqz, $ituz, $station_id) {
$data = array(
'COL_LOTW_QSLRDATE' => $qsl_date,
@@ -2517,6 +2518,7 @@ class Logbook_model extends CI_Model {
$this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"');
$this->db->where('COL_CALL', $callsign);
$this->db->where('COL_BAND', $band);
+ $this->db->where('station_id', $station_id);
$this->db->update($this->config->item('table_name'), $data);
unset($data);
diff --git a/application/views/eqsl/import.php b/application/views/eqsl/import.php
index 1808f11e..2c9edf72 100644
--- a/application/views/eqsl/import.php
+++ b/application/views/eqsl/import.php
@@ -29,10 +29,18 @@
-
+
Upload the Exported ADIF file from eQSL from the Download Inbox page, to mark QSOs as confirmed on eQSL.
Important Log files must have the file type .adi
+Choose Station(location) eQSL File belongs to:
+