diff --git a/application/controllers/lotw.php b/application/controllers/lotw.php
new file mode 100644
index 000000000..c9c254d3d
--- /dev/null
+++ b/application/controllers/lotw.php
@@ -0,0 +1,105 @@
+load->helper(array('form', 'url'));
+
+ $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'); }
+ }
+
+ public function import() {
+ $data['page_title'] = "LoTW ADIF Import";
+
+ $config['upload_path'] = './uploads/';
+ $config['allowed_types'] = 'adi|ADI';
+
+ $this->load->library('upload', $config);
+
+ if ( ! $this->upload->do_upload())
+ {
+ $data['error'] = $this->upload->display_errors();
+
+ $this->load->view('layout/header', $data);
+ $this->load->view('lotw/import');
+ $this->load->view('layout/footer');
+ }
+ else
+ {
+
+ $data = array('upload_data' => $this->upload->data());
+
+ ini_set('memory_limit', '-1');
+ set_time_limit(0);
+
+ $this->load->model('logbook_model');
+
+ $this->load->library('adif_parser');
+
+ $this->adif_parser->load_from_file('./uploads/'.$data['upload_data']['file_name']);
+
+ $this->adif_parser->initialize();
+
+ $table = "
";
+
+ while($record = $this->adif_parser->get_record())
+ {
+ if(count($record) == 0)
+ {
+ break;
+ };
+
+
+
+ //echo date('Y-m-d', strtotime($record['qso_date']))."
";
+ //echo date('H:m', strtotime($record['time_on']))."
";
+
+ //$this->logbook_model->import($record);
+
+ //echo $record["call"]."
";
+ //print_r($record->);
+
+ $time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
+
+ $qsl_date = date('Y-m-d', strtotime($record['qslrdate'])) ." ".date('H:i', strtotime($record['qslrdate']));
+
+ if (isset($record['time_off'])) {
+ $time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
+ } else {
+ $time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
+ }
+
+ $status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
+ $lotw_status = $this->logbook_model->lotw_update($time_on, $record['call'], $record['band'], $qsl_date, $record['qsl_rcvd']);
+
+ $table .= "";
+ $table .= "| ".$time_on." | ";
+ $table .= "".$record['call']." | ";
+ $table .= "".$record['mode']." | ";
+ $table .= "".$record['qsl_rcvd']." | ";
+ $table .= "".$qsl_date." | ";
+ $table .= "QSO Record: ".$status." | ";
+ $table .= "LoTW Record: ".$lotw_status." | ";
+ $table .= "
";
+ };
+
+ $table .= "
";
+
+ unlink('./uploads/'.$data['upload_data']['file_name']);
+
+ $data['lotw_table'] = $table;
+
+ $data['page_title'] = "LoTW ADIF Information";
+ $this->load->view('layout/header', $data);
+ $this->load->view('lotw/analysis');
+ $this->load->view('layout/footer');
+
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php
index f4a5d6f3f..0da44b0f4 100644
--- a/application/models/logbook_model.php
+++ b/application/models/logbook_model.php
@@ -551,6 +551,39 @@ class Logbook_model extends CI_Model {
$this->db->where('COL_PRIMARY_KEY', $id);
$this->db->delete($this->config->item('table_name'));
}
+
+ /* Used to check if the qso is already in the database */
+ function import_check($datetime, $callsign, $band) {
+
+ $this->db->select('COL_TIME_ON, COL_CALL, COL_BAND');
+ $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);
+
+ $query = $this->db->get($this->config->item('table_name'));
+
+ if ($query->num_rows() > 0)
+ {
+ return "Found";
+ } else {
+ return "No Match";
+ }
+ }
+
+ function lotw_update($datetime, $callsign, $band, $qsl_date, $qsl_status) {
+ $data = array(
+ 'COL_LOTW_QSLRDATE' => $qsl_date,
+ 'COL_LOTW_QSL_RCVD' => $qsl_status
+ );
+
+ $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->update($this->config->item('table_name'), $data);
+
+ return "Updated";
+ }
function import($record) {
// Join date+time
diff --git a/application/views/lotw/analysis.php b/application/views/lotw/analysis.php
new file mode 100644
index 000000000..82aab837e
--- /dev/null
+++ b/application/views/lotw/analysis.php
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/application/views/lotw/import.php b/application/views/lotw/import.php
new file mode 100644
index 000000000..178a4b801
--- /dev/null
+++ b/application/views/lotw/import.php
@@ -0,0 +1,18 @@
+
+
+
+
Upload the Exported ADIF file from LoTW from the Download Report Area, to mark QSOs as confirmed on LOTW.
+
+
Important Log files must have the file type .adi
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uploads/lotwreport.adi b/uploads/lotwreport.adi
new file mode 100644
index 000000000..7619cb17a
--- /dev/null
+++ b/uploads/lotwreport.adi
@@ -0,0 +1,31495 @@
+ARRL Logbook of the World Status Report
+Generated at 2013-02-15 18:25:43
+for 2e0sql
+Query:
+ OWNCALL: 2E0SQL
+ QSL ONLY: YES
+ QSL SINCE: 2011-04-20 00:00:00
+
+LoTW
+2013-02-14 19:40:58
+
+1993
+
+
+
+2E0SQL
+2E0SQL
+G7VJR
+80M
+CW
+20120108
+145206
+Y
+20130214
+223
+G7
+JO02af
+
+
+2E0SQL
+2E0SQL
+LY7A
+20M
+SSB
+20120317
+160700
+Y
+20130214
+146
+LY7
+15
+29
+KO14xv
+
+
+2E0SQL
+2E0SQL
+LY7A
+10M
+CW
+20120527
+120429
+Y
+20130214
+146
+LY7
+15
+29
+KO14xv
+
+
+2E0SQL
+2E0SQL
+M0IAA
+80M
+SSB
+20120711
+192900
+Y
+20130214
+223
+M0
+14
+27
+IO93fp
+
+
+2E0SQL
+2E0SQL
+EA3GHZ
+15M
+SSB
+20110519
+125501
+Y
+20130213
+281
+EA3
+14
+37
+JN00ho
+
+
+2E0SQL
+2E0SQL
+VA3MJR
+40M
+JT65
+20121214
+233900
+Y
+20130208
+1
+VA3
+4
+4
+FN03bf
+ON
+
+
+2E0SQL
+2E0SQL
+IK2HDF
+6M
+CW
+20110520
+162107
+Y
+20130207
+248
+IK2
+28
+15
+JN45ia
+
+
+2E0SQL
+2E0SQL
+RA4HL
+20M
+RTTY
+20111112
+164353
+Y
+20130206
+54
+RA4
+16
+29
+LO43fd
+
+
+2E0SQL
+2E0SQL
+TM0HQ
+40M
+SSB
+20120714
+163500
+Y
+20130205
+227
+TM0
+14
+27
+
+
+2E0SQL
+2E0SQL
+IT9TYR
+6M
+SSB
+20120508
+171318
+Y
+20130205
+248
+IT9
+15
+28
+EU-025
+JM78qf
+
+
+2E0SQL
+2E0SQL
+SQ8JX
+20M
+SSB
+20120317
+164500
+Y
+20130205
+269
+SQ8
+15
+28
+
+
+2E0SQL
+2E0SQL
+PA2DKW
+40M
+SSB
+20110601
+221736
+Y
+20130203
+263
+PA2
+14
+27
+JO22ia
+
+
+2E0SQL
+2E0SQL
+IK0YUT
+15M
+SSB
+20121027
+150600
+Y
+20130203
+248
+IK0
+14
+28
+JN63ee
+
+
+2E0SQL
+2E0SQL
+KB0MDQ
+20M
+JT65
+20120615
+234900
+Y
+20130202
+291
+KB0
+EN26uk
+MN
+MN,CROW WING
+
+
+2E0SQL
+2E0SQL
+LY7Z
+20M
+SSB
+20121027
+105200
+Y
+20130129
+146
+LY7
+15
+29
+KO16ja
+
+
+2E0SQL
+2E0SQL
+OM7YC
+20M
+PSK63
+20120204
+163015
+Y
+20130129
+504
+OM7
+15
+28
+JN98si
+
+
+2E0SQL
+2E0SQL
+LY7Z
+20M
+CW
+20121125
+164818
+Y
+20130127
+146
+LY7
+