[QRZ Logbook] option for realtime logging added

pull/712/head
Andreas 2020-11-18 11:50:15 +01:00
rodzic 388bfb848a
commit e149d34ba1
6 zmienionych plików z 59 dodań i 15 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 55;
$config['migration_version'] = 56;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -0,0 +1,20 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_add_qrz_upload_realtime_option extends CI_Migration {
public function up()
{
$fields = array(
'qrzrealtime bool DEFAULT TRUE',
);
$this->dbforge->add_column('station_profile', $fields);
}
public function down()
{
$this->dbforge->drop_column('station_profile', 'qrzrealtime');
}
}

Wyświetl plik

@ -336,15 +336,19 @@ class Logbook_model extends CI_Model {
$data['COL_RX_PWR'] = str_replace("W", "", $data['COL_RX_PWR']);
}
$result = $this->exists_qrz_api_key($data['station_id']);
// Push qso to qrz if apikey is set
if ($apikey = $this->exists_qrz_api_key($data['station_id'])) {
$adif = $this->create_adif_from_data($data);
$result = $this->push_qso_to_qrz($apikey, $adif);
IF ($result['status'] == 'OK') {
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y';
$data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now"));
if ($result) {
if ($result->qrzrealtime == 1) {
$adif = $this->create_adif_from_data($data);
$result = $this->push_qso_to_qrz($result->qrzapikey, $adif);
IF ($result['status'] == 'OK') {
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y';
$data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now"));
}
}
}
}
// Add QSO to database
$this->db->insert($this->config->item('table_name'), $data);
@ -354,7 +358,7 @@ class Logbook_model extends CI_Model {
* Function checks if a QRZ API Key exists in the table with the given station id
*/
function exists_qrz_api_key($station_id) {
$sql = 'select qrzapikey from station_profile
$sql = 'select qrzapikey, qrzrealtime from station_profile
where station_id = ' . $station_id;
$query = $this->db->query($sql);
@ -362,7 +366,7 @@ class Logbook_model extends CI_Model {
$result = $query->row();
if ($result) {
return $result->qrzapikey;
return $result;
}
else {
return false;

Wyświetl plik

@ -53,6 +53,7 @@ class Stations extends CI_Model {
'state' => xss_clean($this->input->post('station_state', true)),
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
);
// Insert Records
@ -77,6 +78,7 @@ class Stations extends CI_Model {
'state' => xss_clean($this->input->post('station_state', true)),
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
);
$this->db->where('station_id', xss_clean($this->input->post('station_id', true)));

Wyświetl plik

@ -200,10 +200,19 @@
<small id="eqslhelp" class="form-text text-muted">eQSL QTH Nickname.</small>
</div>
<div class="form-group">
<label for="qrzApiKey">QRZ.com Logbook API Key</label>
<input type="text" class="form-control" name="qrzapikey" id="qrzApiKey" aria-describedby="qrzApiKeyHelp">
<small id="qrzApiKeyHelp" class="form-text text-muted">Find your API key on <a href="https://logbook.qrz.com/logbook" target="_blank">QRZ.com's settings page</a></small>
<div class="form-row">
<div class="form-group col-sm-6">
<label for="qrzApiKey">QRZ.com Logbook API Key</label>
<input type="text" class="form-control" name="qrzapikey" id="qrzApiKey" aria-describedby="qrzApiKeyHelp">
<small id="qrzApiKeyHelp" class="form-text text-muted">Find your API key on <a href="https://logbook.qrz.com/logbook" target="_blank">QRZ.com's settings page</a></small>
</div>
<div class="form-group col-sm-6">
<label for="qrzrealtime">QRZ.com Logbook Realtime Upload</label>
<select class="custom-select" id="qrzrealtime" name="qrzrealtime">
<option value="1" selected>True</option>
<option value="0">False</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Create Station Profile</button>

Wyświetl plik

@ -222,11 +222,20 @@
<small id="eqslhelp" class="form-text text-muted">eQSL QTH Nickname.</small>
</div>
<div class="form-group">
<div class="form-row">
<div class="form-group col-sm-6">
<label for="qrzApiKey">QRZ.com Logbook API Key</label>
<input type="text" class="form-control" name="qrzapikey" id="qrzApiKey" aria-describedby="qrzApiKeyHelp" value="<?php if(set_value('qrzapikey') != "") { echo set_value('qrzapikey'); } else { echo $my_station_profile->qrzapikey; } ?>">
<small id="qrzApiKeyHelp" class="form-text text-muted">Find your API key on <a href="https://logbook.qrz.com/logbook" target="_blank">QRZ.com's settings page</a></small>
</div>
<div class="form-group col-sm-6">
<label for="qrzrealtime">QRZ.com Logbook Realtime Upload</label>
<select class="custom-select" id="qrzrealtime" name="qrzrealtime">
<option value="1" <?php if ($my_station_profile->qrzrealtime == 1) { echo " selected =\"selected\""; } ?>>True</option>
<option value="0" <?php if ($my_station_profile->qrzrealtime == 0) { echo " selected =\"selected\""; } ?>>False</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Update Station Profile</button>