Added LotW-Gradient to add_qso and changed getting lotw-info from File to DB
这个提交包含在:
父节点
b5898f8490
当前提交
b9c39ed6ed
共有 4 个文件被更改,包括 33 次插入 和 23 次删除
|
|
@ -98,30 +98,15 @@ class Logbook extends CI_Controller {
|
|||
$callsign = str_replace("-","/",$callsign);
|
||||
|
||||
// Check if callsign is an LOTW User
|
||||
$lotw_member = "";
|
||||
$lotw_file_name = "./updates/lotw_users.csv";
|
||||
|
||||
if (file_exists($lotw_file_name)) {
|
||||
$f = fopen($lotw_file_name, "r");
|
||||
$result = false;
|
||||
while ($row = fgetcsv($f)) {
|
||||
if ($row[0] == strtoupper($callsign)) {
|
||||
$result = $row[0];
|
||||
$lotw_member = "active";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($lotw_member != "active") {
|
||||
$lotw_member = "not found";
|
||||
}
|
||||
fclose($f);
|
||||
} else {
|
||||
$lotw_member = "not found";
|
||||
}
|
||||
|
||||
// Check Database for all other data
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$lotw_days=$this->logbook_model->check_last_lotw($callsign);
|
||||
if ($lotw_days != null) {
|
||||
$lotw_member="active";
|
||||
} else {
|
||||
$lotw_member="not found";
|
||||
}
|
||||
|
||||
$return = [
|
||||
"callsign" => strtoupper($callsign),
|
||||
|
|
@ -137,6 +122,7 @@ class Logbook extends CI_Controller {
|
|||
"bearing" => "",
|
||||
"workedBefore" => false,
|
||||
"lotw_member" => $lotw_member,
|
||||
"lotw_days" => $lotw_days,
|
||||
"image" => "",
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -296,6 +296,16 @@ class Logbook_model extends CI_Model {
|
|||
$this->add_qso($data, $skipexport = false);
|
||||
}
|
||||
|
||||
public function check_last_lotw($call){ // Fetch difference in days when $call has last updated LotW
|
||||
|
||||
$sql="select datediff(now(),lastupload) as DAYS from lotw_users where callsign = ?"; // Use binding to prevent SQL-injection
|
||||
$query = $this->db->query($sql, $call);
|
||||
$row = $query->row();
|
||||
if (isset($row)) {
|
||||
return($row->DAYS);
|
||||
}
|
||||
}
|
||||
|
||||
public function check_station($id){
|
||||
|
||||
$this->db->select('station_profile.*, dxcc_entities.name as station_country');
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
<div class="form-group col-md-9">
|
||||
<label for="callsign"><?php echo lang('gen_hamradio_callsign'); ?></label>
|
||||
<input type="text" class="form-control" id="callsign" name="callsign" required>
|
||||
<small id="callsign_info" class="badge badge-secondary"></small> <small id="lotw_info" class="badge badge-light"></small>
|
||||
<small id="callsign_info" class="badge badge-secondary"></small> <small id="lotw_info" class="badge badge-success"></small>
|
||||
</div>
|
||||
<div class="form-group col-md-3 align-self-center">
|
||||
<small id="qrz_info" class="badge badge-secondary"></small>
|
||||
|
|
|
|||
|
|
@ -329,6 +329,9 @@ function reset_fields() {
|
|||
$('#country').val("");
|
||||
$('#continent').val("");
|
||||
$('#lotw_info').text("");
|
||||
$('#lotw_info').removeClass("lotw_info_red");
|
||||
$('#lotw_info').removeClass("lotw_info_yellow");
|
||||
$('#lotw_info').removeClass("lotw_info_orange");
|
||||
$('#qrz_info').text("");
|
||||
$('#hamqth_info').text("");
|
||||
$('#sota_info').text("");
|
||||
|
|
@ -457,6 +460,17 @@ $("#callsign").focusout(function() {
|
|||
|
||||
if(result.lotw_member == "active") {
|
||||
$('#lotw_info').text("LoTW");
|
||||
if (result.lotw_days > 365) {
|
||||
$('#lotw_info').addClass('lotw_info_red');
|
||||
} else if (result.lotw_days > 30) {
|
||||
$('#lotw_info').addClass('lotw_info_orange');
|
||||
$lotw_hint = ' lotw_info_orange';
|
||||
} else if (result.lotw_days > 7) {
|
||||
$('#lotw_info').addClass('lotw_info_yellow');
|
||||
}
|
||||
$('#lotw_info').attr('data-toggle',"tooltip");
|
||||
$('#lotw_info').attr('data-original-title',"LoTW User. Last upload was "+result.lotw_days+" days ago");
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
}
|
||||
$('#qrz_info').html('<a target="_blank" href="https://www.qrz.com/db/'+find_callsign+'"><img width="32" height="32" src="'+base_url+'images/icons/qrz.com.png"></a>');
|
||||
$('#qrz_info').attr('title', 'Lookup '+find_callsign+' info on qrz.com');
|
||||
|
|
|
|||
正在加载…
在新工单中引用