Added the ability to upload LoTW report adif files and make qsos as confirmed
这个提交包含在:
父节点
be931f3a68
当前提交
a781c39d26
共有 11 个文件被更改,包括 220627 次插入 和 0 次删除
105
application/controllers/lotw.php
普通文件
105
application/controllers/lotw.php
普通文件
|
|
@ -0,0 +1,105 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Lotw extends CI_Controller {
|
||||
|
||||
/* Controls who can access the controller and its functions */
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->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 = "<table>";
|
||||
|
||||
while($record = $this->adif_parser->get_record())
|
||||
{
|
||||
if(count($record) == 0)
|
||||
{
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//echo date('Y-m-d', strtotime($record['qso_date']))."<br>";
|
||||
//echo date('H:m', strtotime($record['time_on']))."<br>";
|
||||
|
||||
//$this->logbook_model->import($record);
|
||||
|
||||
//echo $record["call"]."<br>";
|
||||
//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 .= "<tr>";
|
||||
$table .= "<td>".$time_on."</td>";
|
||||
$table .= "<td>".$record['call']."</td>";
|
||||
$table .= "<td>".$record['mode']."</td>";
|
||||
$table .= "<td>".$record['qsl_rcvd']."</td>";
|
||||
$table .= "<td>".$qsl_date."</td>";
|
||||
$table .= "<td>QSO Record: ".$status."</td>";
|
||||
$table .= "<td>LoTW Record: ".$lotw_status."</td>";
|
||||
$table .= "<tr>";
|
||||
};
|
||||
|
||||
$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');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<div id="container">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<?php echo $lotw_table; ?>
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<div id="container">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<p>Upload the Exported ADIF file from LoTW from the <a href="https://p1k.arrl.org/lotwuser/qsos?qsoscmd=adif" target="_blank">Download Report</a> Area, to mark QSOs as confirmed on LOTW.</p>
|
||||
|
||||
<p><span class="label important">Important</span> Log files must have the file type .adi</p>
|
||||
|
||||
<?php echo form_open_multipart('lotw/import');?>
|
||||
|
||||
<input type="file" name="userfile" size="20" />
|
||||
|
||||
<br /><br />
|
||||
|
||||
<input class="btn primary" type="submit" value="Upload" />
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
31495
uploads/lotwreport.adi
普通文件
31495
uploads/lotwreport.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport1.adi
普通文件
31495
uploads/lotwreport1.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport2.adi
普通文件
31495
uploads/lotwreport2.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport3.adi
普通文件
31495
uploads/lotwreport3.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport4.adi
普通文件
31495
uploads/lotwreport4.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport5.adi
普通文件
31495
uploads/lotwreport5.adi
普通文件
文件差异内容过多而无法显示
加载差异
31495
uploads/lotwreport6.adi
普通文件
31495
uploads/lotwreport6.adi
普通文件
文件差异内容过多而无法显示
加载差异
正在加载…
在新工单中引用