Merge pull request #457 from AndreasK79/Adif_import_options
Added a few options on ADIF import. Added mode to duplicate check whe…
这个提交包含在:
当前提交
43a5926ce7
共有 4 个文件被更改,包括 91 次插入 和 39 次删除
|
|
@ -195,7 +195,8 @@ class adif extends CI_Controller {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$custom_errors .= $this->logbook_model->import($record, $this->input->post('station_profile'));
|
$custom_errors .= $this->logbook_model->import($record, $this->input->post('station_profile'),
|
||||||
|
$this->input->post('skipDuplicate'), $this->input->post('markLotw'), $this->input->post('dxccAdif'));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,7 @@ class ADIF_Parser
|
||||||
public function initialize() //this function locates the <EOH>
|
public function initialize() //this function locates the <EOH>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$pos = stripos(strtoupper($this->data), "<EOH>");;
|
||||||
$eoh_upper = stripos($this->data, "<EOH>");
|
|
||||||
|
|
||||||
if($eoh_upper == true) {
|
|
||||||
$pos = stripos($this->data, "<EOH>");;
|
|
||||||
} else {
|
|
||||||
$pos = stripos($this->data, "<eoh>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if($pos == false) //did we find the end of headers?
|
if($pos == false) //did we find the end of headers?
|
||||||
{
|
{
|
||||||
|
|
@ -41,7 +34,6 @@ class ADIF_Parser
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//get headers
|
//get headers
|
||||||
|
|
||||||
$this->i = 0;
|
$this->i = 0;
|
||||||
|
|
|
||||||
|
|
@ -1095,8 +1095,6 @@ class Logbook_model extends CI_Model {
|
||||||
|
|
||||||
// Show all QSOs we need to send to eQSL
|
// Show all QSOs we need to send to eQSL
|
||||||
function eqsl_not_yet_sent() {
|
function eqsl_not_yet_sent() {
|
||||||
|
|
||||||
|
|
||||||
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE');
|
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE');
|
||||||
$this->db->from('station_profile');
|
$this->db->from('station_profile');
|
||||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id AND station_profile.eqslqthnickname != ""','left');
|
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id AND station_profile.eqslqthnickname != ""','left');
|
||||||
|
|
@ -1106,7 +1104,7 @@ class Logbook_model extends CI_Model {
|
||||||
return $this->db->get();
|
return $this->db->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function import($record, $station_id = "0") {
|
function import($record, $station_id = "0", $skipDuplicate, $markLotw, $dxccAdif) {
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
$CI->load->library('frequency');
|
$CI->load->library('frequency');
|
||||||
$my_error = "";
|
$my_error = "";
|
||||||
|
|
@ -1116,7 +1114,7 @@ class Logbook_model extends CI_Model {
|
||||||
if (isset($record['time_off'])) {
|
if (isset($record['time_off'])) {
|
||||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
|
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
|
||||||
} else {
|
} else {
|
||||||
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
|
$time_off = $time_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store Freq
|
// Store Freq
|
||||||
|
|
@ -1138,7 +1136,6 @@ class Logbook_model extends CI_Model {
|
||||||
$freq = "0";
|
$freq = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for RX Freq
|
// Check for RX Freq
|
||||||
// Check if 'freq' is defined in the import?
|
// Check if 'freq' is defined in the import?
|
||||||
if (isset($record['freq_rx'])){
|
if (isset($record['freq_rx'])){
|
||||||
|
|
@ -1160,7 +1157,15 @@ class Logbook_model extends CI_Model {
|
||||||
|
|
||||||
// DXCC id
|
// DXCC id
|
||||||
if (isset($record['call'])){
|
if (isset($record['call'])){
|
||||||
|
if ($dxccAdif != NULL) {
|
||||||
|
if (isset($record['dxcc'])) {
|
||||||
|
$dxcc = array($record['dxcc'], $this->get_entity($record['dxcc']));
|
||||||
|
} else {
|
||||||
|
$dxcc = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$dxcc = NULL;
|
$dxcc = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1172,7 +1177,6 @@ class Logbook_model extends CI_Model {
|
||||||
$country = ucwords(strtolower($dxcc[1]));
|
$country = ucwords(strtolower($dxcc[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// RST recevied
|
// RST recevied
|
||||||
if(isset($record['rst_rcvd'])) {
|
if(isset($record['rst_rcvd'])) {
|
||||||
$rst_rx = $record['rst_rcvd'];
|
$rst_rx = $record['rst_rcvd'];
|
||||||
|
|
@ -1198,7 +1202,6 @@ class Logbook_model extends CI_Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(isset($record['band_rx'])) {
|
if(isset($record['band_rx'])) {
|
||||||
$band_rx = $record['band_rx'];
|
$band_rx = $record['band_rx'];
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1216,7 +1219,6 @@ class Logbook_model extends CI_Model {
|
||||||
} elseif(isset($dxcc[2])) {
|
} elseif(isset($dxcc[2])) {
|
||||||
$cq_zone = $dxcc[2];
|
$cq_zone = $dxcc[2];
|
||||||
} else {
|
} else {
|
||||||
//$cq_zone = "";
|
|
||||||
$cq_zone = NULL;
|
$cq_zone = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1290,7 +1292,6 @@ class Logbook_model extends CI_Model {
|
||||||
qslrdate, qslsdate
|
qslrdate, qslsdate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (isset($record['qslrdate'])){
|
if (isset($record['qslrdate'])){
|
||||||
if(validateADIFDate($record['qslrdate']) == true){
|
if(validateADIFDate($record['qslrdate']) == true){
|
||||||
$input_qslrdate = $record['qslrdate'];
|
$input_qslrdate = $record['qslrdate'];
|
||||||
|
|
@ -1340,7 +1341,6 @@ class Logbook_model extends CI_Model {
|
||||||
/*
|
/*
|
||||||
Validate LOTW Fields
|
Validate LOTW Fields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isset($record['lotw_qsl_rcvd'])){
|
if (isset($record['lotw_qsl_rcvd'])){
|
||||||
$input_lotw_qsl_rcvd = mb_strimwidth($record['lotw_qsl_rcvd'], 0, 1);
|
$input_lotw_qsl_rcvd = mb_strimwidth($record['lotw_qsl_rcvd'], 0, 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1349,6 +1349,8 @@ class Logbook_model extends CI_Model {
|
||||||
|
|
||||||
if (isset($record['lotw_qsl_sent'])){
|
if (isset($record['lotw_qsl_sent'])){
|
||||||
$input_lotw_qsl_sent = mb_strimwidth($record['lotw_qsl_sent'], 0, 1);
|
$input_lotw_qsl_sent = mb_strimwidth($record['lotw_qsl_sent'], 0, 1);
|
||||||
|
} else if ($markLotw != NULL) {
|
||||||
|
$input_lotw_qsl_sent = "Y";
|
||||||
} else {
|
} else {
|
||||||
$input_lotw_qsl_sent = "";
|
$input_lotw_qsl_sent = "";
|
||||||
}
|
}
|
||||||
|
|
@ -1371,10 +1373,18 @@ class Logbook_model extends CI_Model {
|
||||||
$input_lotw_qslsdate = NULL;
|
$input_lotw_qslsdate = NULL;
|
||||||
$my_error .= "Error QSO: Date: ".$time_on." Callsign: ".$record['call']." the lotw_qslsdate is invalid (YYYYMMDD): ".$record['lotw_qslsdate']."<br>";
|
$my_error .= "Error QSO: Date: ".$time_on." Callsign: ".$record['call']." the lotw_qslsdate is invalid (YYYYMMDD): ".$record['lotw_qslsdate']."<br>";
|
||||||
}
|
}
|
||||||
|
} else if ($markLotw != NULL) {
|
||||||
|
$input_lotw_qslsdate = $date = date("Y-m-d H:i:s", strtotime("now"));
|
||||||
} else {
|
} else {
|
||||||
$input_lotw_qslsdate = NULL;
|
$input_lotw_qslsdate = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($record['mode'])) {
|
||||||
|
$input_mode = $record['mode'];
|
||||||
|
} else {
|
||||||
|
$input_mode = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Get active station_id from station profile if one hasn't been provided
|
// Get active station_id from station profile if one hasn't been provided
|
||||||
if($station_id == "" || $station_id == "0") {
|
if($station_id == "" || $station_id == "0") {
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
|
|
@ -1383,16 +1393,27 @@ class Logbook_model extends CI_Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if QSO is already in the database
|
// Check if QSO is already in the database
|
||||||
|
if ($skipDuplicate != NULL) {
|
||||||
|
$skip = false;
|
||||||
|
} else {
|
||||||
if (isset($record['call'])){
|
if (isset($record['call'])){
|
||||||
$this->db->where('COL_CALL', $record['call']);
|
$this->db->where('COL_CALL', $record['call']);
|
||||||
}
|
}
|
||||||
$this->db->where('COL_TIME_ON', $time_on);
|
$this->db->where('COL_TIME_ON', $time_on);
|
||||||
$this->db->where('COL_BAND', $band);
|
$this->db->where('COL_BAND', $band);
|
||||||
|
$this->db->where('COL_MODE', $input_mode);
|
||||||
$this->db->where('station_id', $station_id);
|
$this->db->where('station_id', $station_id);
|
||||||
$check = $this->db->get($this->config->item('table_name'));
|
$check = $this->db->get($this->config->item('table_name'));
|
||||||
|
|
||||||
// If QSO is not in the database add it
|
// If dupe is not found, set variable to add QSO
|
||||||
if ($check->num_rows() <= 0)
|
if ($check->num_rows() <= 0) {
|
||||||
|
$skip = false;
|
||||||
|
} else {
|
||||||
|
$skip = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$skip)
|
||||||
{
|
{
|
||||||
// Create array with QSO Data use ?:
|
// Create array with QSO Data use ?:
|
||||||
$data = array(
|
$data = array(
|
||||||
|
|
@ -1455,7 +1476,7 @@ class Logbook_model extends CI_Model {
|
||||||
'COL_LOTW_QSLSDATE' => $input_lotw_qslsdate,
|
'COL_LOTW_QSLSDATE' => $input_lotw_qslsdate,
|
||||||
'COL_LOTW_STATUS' => (!empty($record['lotw_status'])) ? $record['lotw_status'] : '',
|
'COL_LOTW_STATUS' => (!empty($record['lotw_status'])) ? $record['lotw_status'] : '',
|
||||||
'COL_MAX_BURSTS' => (!empty($record['max_bursts'])) ? $record['max_bursts'] : null,
|
'COL_MAX_BURSTS' => (!empty($record['max_bursts'])) ? $record['max_bursts'] : null,
|
||||||
'COL_MODE' => (!empty($record['mode'])) ? $record['mode'] : '',
|
'COL_MODE' => $input_mode,
|
||||||
'COL_MS_SHOWER' => (!empty($record['ms_shower'])) ? $record['ms_shower'] : '',
|
'COL_MS_SHOWER' => (!empty($record['ms_shower'])) ? $record['ms_shower'] : '',
|
||||||
'COL_MY_ANTENNA' => (!empty($record['my_antenna'])) ? $record['my_antenna'] : '',
|
'COL_MY_ANTENNA' => (!empty($record['my_antenna'])) ? $record['my_antenna'] : '',
|
||||||
'COL_MY_ANTENNA_INTL' => (!empty($record['my_antenna_intl'])) ? $record['my_antenna_intl'] : '',
|
'COL_MY_ANTENNA_INTL' => (!empty($record['my_antenna_intl'])) ? $record['my_antenna_intl'] : '',
|
||||||
|
|
@ -1658,6 +1679,17 @@ class Logbook_model extends CI_Model {
|
||||||
return array("Not Found", "Not Found");
|
return array("Not Found", "Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_entity($dxcc){
|
||||||
|
$sql = "select name from dxcc_entities where adif = " . $dxcc;
|
||||||
|
$query = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($query->result() > 0){
|
||||||
|
$row = $query->row_array();
|
||||||
|
return $row['name'];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Same as check_dxcc_table, but the functionality is in
|
* Same as check_dxcc_table, but the functionality is in
|
||||||
* a stored procedure which we call
|
* a stored procedure which we call
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,33 @@
|
||||||
<label class="sr-only" for="inlineFormInputName2">ADIF file</label>
|
<label class="sr-only" for="inlineFormInputName2">ADIF file</label>
|
||||||
<input class="file-input mb-2 mr-sm-2" type="file" name="userfile" size="20" />
|
<input class="file-input mb-2 mr-sm-2" type="file" name="userfile" size="20" />
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
<div class="form-check-inline">
|
||||||
|
<input class="form-check-input" type="checkbox" name="skipDuplicate" value="1" id="skipDuplicate">
|
||||||
|
<label class="form-check-label" for="skipDuplicate">Skip duplicate QSO check</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
<div class="form-check-inline">
|
||||||
|
<input class="form-check-input" type="checkbox" name="markLotw" value="1" id="markLotw">
|
||||||
|
<label class="form-check-label" for="markLotw">Mark imported QSOs as uploaded to LoTW (use if ADIF does not contain this information)</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
<div class="form-check-inline">
|
||||||
|
<input class="form-check-input" type="checkbox" name="dxccAdif" value="1" id="dxccAdif">
|
||||||
|
<label class="form-check-label" for="dxccAdif">Use DXCC set in ADIF (Cloudlog tries to determine DXCC if not checked)</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary mb-2" value="Upload">Upload</button>
|
<button type="submit" class="btn btn-primary mb-2" value="Upload">Upload</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用