Merge pull request #2035 from hugosilvaparagramanet/feature/export-to-qo-100-dx-club
Basic QO-100 Dx Club API integration
这个提交包含在:
当前提交
c1d2a98da8
共有 12 个文件被更改,包括 705 次插入 和 80 次删除
|
|
@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
|||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 114;
|
||||
$config['migration_version'] = 115;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
161
application/controllers/Webadif.php
普通文件
161
application/controllers/Webadif.php
普通文件
|
|
@ -0,0 +1,161 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/* Controller to interact with the webADIF API */
|
||||
class Webadif extends CI_Controller {
|
||||
|
||||
/*
|
||||
* Upload QSO to webADIF
|
||||
* When called from the url cloudlog/webadif/upload, the function loops through all station_id's with a webADIF
|
||||
* api key defined.
|
||||
* All QSOs not previously uploaded, will then be uploaded, one at a time
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
$this->setOptions();
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$station_ids = $this->logbook_model->get_station_id_with_webadif_api();
|
||||
|
||||
if ($station_ids) {
|
||||
foreach ($station_ids as $station) {
|
||||
$webadif_api_key = $station->webadifapikey;
|
||||
$webadif_api_url = $station->webadifapiurl;
|
||||
if ($this->mass_upload_qsos($station->station_id, $webadif_api_key, $webadif_api_url)) {
|
||||
echo "QSOs have been uploaded to QO-100 Dx Club.";
|
||||
log_message('info', 'QSOs have been uploaded to QO-100 Dx Club.');
|
||||
} else {
|
||||
echo "No QSOs found for upload.";
|
||||
log_message('info', 'No QSOs found for upload.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "No station profiles with a QO-100 Dx Club API Key found.";
|
||||
log_message('error', "No station profiles with a QO-100 Dx Club API Key found.");
|
||||
}
|
||||
}
|
||||
|
||||
function setOptions() {
|
||||
$this->config->load('config');
|
||||
ini_set('memory_limit', '-1');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function gets all QSOs from given station_id, that are not previously uploaded to webADIF consumer.
|
||||
* Adif is build for each qso, and then uploaded, one at a time
|
||||
*/
|
||||
function mass_upload_qsos($station_id, $webadif_api_key, $webadif_api_url) {
|
||||
$i = 0;
|
||||
$data['qsos'] = $this->logbook_model->get_webadif_qsos($station_id);
|
||||
$errormessages=array();
|
||||
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
|
||||
if ($data['qsos']) {
|
||||
foreach ($data['qsos']->result() as $qso) {
|
||||
$adif = $CI->adifhelper->getAdifLine($qso);
|
||||
$result = $this->logbook_model->push_qso_to_webadif($webadif_api_url, $webadif_api_key, $adif);
|
||||
|
||||
if ($result) {
|
||||
$this->logbook_model->mark_webadif_qsos_sent($qso->COL_PRIMARY_KEY);
|
||||
$i++;
|
||||
} else {
|
||||
$errorMessage = 'QO-100 Dx Club upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
|
||||
log_message('error', $errorMessage);
|
||||
$errormessages[] = $errorMessage;
|
||||
}
|
||||
}
|
||||
$result=[];
|
||||
$result['status'] = 'OK';
|
||||
$result['count'] = $i;
|
||||
$result['errormessages'] = $errormessages;
|
||||
return $result;
|
||||
} else {
|
||||
$result=[];
|
||||
$result['status'] = 'Error';
|
||||
$result['count'] = $i;
|
||||
$result['errormessages'] = $errormessages;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for displaying the uid for manually selecting log for upload to webADIF consumer
|
||||
*/
|
||||
public function export() {
|
||||
$this->load->model('stations');
|
||||
|
||||
$data['page_title'] = "QO-100 Dx Club Upload";
|
||||
|
||||
$data['station_profiles'] = $this->stations->stations_with_webadif_api_key();
|
||||
$data['station_profile'] = $this->stations->stations_with_webadif_api_key();
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('webadif/export');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for ajax-function when selecting log for upload to webADIF consumer
|
||||
*/
|
||||
public function upload_station() {
|
||||
$this->setOptions();
|
||||
$this->load->model('stations');
|
||||
|
||||
$postData = $this->input->post();
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$result = $this->logbook_model->exists_webadif_api_key($postData['station_id']);
|
||||
$webadif_api_key = $result->webadifapikey;
|
||||
$webadif_api_url = $result->webadifapiurl;
|
||||
header('Content-type: application/json');
|
||||
$result = $this->mass_upload_qsos($postData['station_id'], $webadif_api_key, $webadif_api_url);
|
||||
if ($result['status'] == 'OK') {
|
||||
$stationinfo = $this->stations->stations_with_webadif_api_key();
|
||||
$info = $stationinfo->result();
|
||||
|
||||
$data['status'] = 'OK';
|
||||
$data['info'] = $info;
|
||||
$data['infomessage'] = $result['count'] . " QSOs are now uploaded to QO-100 Dx Club";
|
||||
$data['errormessages'] = $result['errormessages'];
|
||||
echo json_encode($data);
|
||||
} else {
|
||||
$data['status'] = 'Error';
|
||||
$data['info'] = 'Error: No QSOs found to upload.';
|
||||
$data['errormessages'] = $result['errormessages'];
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function mark_webadif() {
|
||||
// Set memory limit to unlimited to allow heavy usage
|
||||
ini_set('memory_limit', '-1');
|
||||
$data['page_title'] = "QO-100 Dx Club Upload";
|
||||
|
||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||
$from = $this->security->xss_clean($this->input->post('from'));
|
||||
$to = $this->security->xss_clean($this->input->post('to'));
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$data['qsos'] = $this->logbook_model->get_webadif_qsos(
|
||||
$station_id,
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
|
||||
if ($data['qsos']!==null) {
|
||||
foreach ($data['qsos']->result() as $qso) {
|
||||
$this->logbook_model->mark_webadif_qsos_sent($qso->COL_PRIMARY_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('webadif/mark_webadif', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_webadif_api_export extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->field_exists('webadifapikey', 'station_profile')) {
|
||||
$fields = array(
|
||||
'webadifapikey varchar(50) DEFAULT NULL'
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
if (!$this->db->field_exists('webadifapiurl', 'station_profile')) {
|
||||
$fields = array(
|
||||
'webadifapiurl varchar(256) DEFAULT NULL'
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
if (!$this->db->field_exists('webadifrealtime', 'station_profile')) {
|
||||
$fields = array(
|
||||
'webadifrealtime bool DEFAULT FALSE'
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
|
||||
|
||||
if (!$this->db->table_exists('webadif')) {
|
||||
$this->dbforge->add_field(array(
|
||||
'id' => array(
|
||||
'type' => 'INT',
|
||||
'auto_increment' => TRUE
|
||||
),
|
||||
'qso_id' => array(
|
||||
'type' => 'int',
|
||||
),
|
||||
'upload_date' => array(
|
||||
'type' => 'datetime',
|
||||
),
|
||||
));
|
||||
|
||||
$this->dbforge->add_key('id', TRUE);
|
||||
$this->dbforge->add_key(array('qso_id','upload_date'), FALSE);
|
||||
|
||||
$this->dbforge->create_table('webadif');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dbforge->drop_column('station_profile', 'webadifapikey');
|
||||
$this->dbforge->drop_column('station_profile', 'webadifapiurl');
|
||||
$this->dbforge->drop_column('station_profile', 'webadifrealtime');
|
||||
$this->dbforge->drop_table('webadif');
|
||||
}
|
||||
}
|
||||
|
|
@ -481,6 +481,25 @@ class Logbook_model extends CI_Model {
|
|||
$this->mark_qrz_qsos_sent($last_id);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->exists_webadif_api_key($data['station_id']);
|
||||
// Push qso to webadif if apikey is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
if (isset($result->webadifapikey) && $result->webadifrealtime == 1) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
$qso = $this->get_qso($last_id)->result();
|
||||
|
||||
$adif = $CI->adifhelper->getAdifLine($qso[0]);
|
||||
$result = $this->push_qso_to_webadif(
|
||||
$result->webadifapiurl,
|
||||
$result->webadifapikey,
|
||||
$adif
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
$this->mark_webadif_qsos_sent($last_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -503,6 +522,25 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function checks if a WebADIF API Key exists in the table with the given station id
|
||||
*/
|
||||
function exists_webadif_api_key($station_id) {
|
||||
$sql = 'select webadifapikey, webadifapiurl, webadifrealtime from station_profile
|
||||
where station_id = ' . $station_id;
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$result = $query->row();
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function uploads a QSO to QRZ with the API given.
|
||||
* $adif contains a line with the QSO in the ADIF format. QSO ends with an <EOR>
|
||||
|
|
@ -545,6 +583,36 @@ class Logbook_model extends CI_Model {
|
|||
curl_close($ch);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function uploads a QSO to WebADIF consumer with the API given.
|
||||
* $adif contains a line with the QSO in the ADIF format.
|
||||
*/
|
||||
function push_qso_to_webadif($url, $apikey, $adif) : bool{
|
||||
|
||||
$headers = array(
|
||||
'Content-Type: text/plain',
|
||||
'X-API-Key: ' . $apikey
|
||||
);
|
||||
|
||||
if (substr($url, -1) !== "/") {
|
||||
$url .= "/";
|
||||
}
|
||||
|
||||
$ch = curl_init( $url . "qso");
|
||||
curl_setopt( $ch, CURLOPT_POST, true);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, (string)$adif);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$content = curl_exec($ch); // TODO: better error handling
|
||||
$errors = curl_error($ch);
|
||||
$response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
return $response === 200;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to QRZ.
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
|
|
@ -562,6 +630,22 @@ class Logbook_model extends CI_Model {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to WebADIF.
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
*/
|
||||
function mark_webadif_qsos_sent($primarykey)
|
||||
{
|
||||
$data = array(
|
||||
'upload_date' => date("Y-m-d H:i:s", strtotime("now")),
|
||||
'qso_id' => $primarykey,
|
||||
);
|
||||
|
||||
$this->db->insert('webadif', $data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function upload_amsat_status($data) {
|
||||
$sat_name = '';
|
||||
if ($data['COL_SAT_NAME'] == 'AO-7') {
|
||||
|
|
@ -1192,6 +1276,47 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
/*
|
||||
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to webADIF
|
||||
*/
|
||||
function get_webadif_qsos($station_id,$from, $to){
|
||||
$sql = "
|
||||
SELECT qsos.*, station_profile.*
|
||||
FROM %s qsos
|
||||
INNER JOIN station_profile ON qsos.station_id = station_profile.station_id
|
||||
LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id
|
||||
WHERE qsos.station_id = %d
|
||||
AND webadif.upload_date IS NULL
|
||||
";
|
||||
$sql = sprintf(
|
||||
$sql,
|
||||
$this->config->item('table_name'),
|
||||
$station_id
|
||||
);
|
||||
if ($from) {
|
||||
$from = DateTime::createFromFormat('d/m/Y', $from);
|
||||
$from = $from->format('Y-m-d');
|
||||
|
||||
$sql.=" AND qsos.COL_TIME_ON >= %s";
|
||||
$sql=sprintf(
|
||||
$sql,
|
||||
$this->db->escape($from)
|
||||
);
|
||||
}
|
||||
if ($to) {
|
||||
$to = DateTime::createFromFormat('d/m/Y', $to);
|
||||
$to = $to->format('Y-m-d');
|
||||
|
||||
$sql.=" AND qsos.COL_TIME_ON <= %s";
|
||||
$sql=sprintf(
|
||||
$sql,
|
||||
$this->db->escape($to)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all the station_id's with QRZ API Key's
|
||||
*/
|
||||
function get_station_id_with_qrz_api() {
|
||||
|
|
@ -1210,6 +1335,26 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all the station_id's with QRZ API Key's
|
||||
*/
|
||||
function get_station_id_with_webadif_api() {
|
||||
$sql = "
|
||||
SELECT station_id, webadifapikey, webadifapiurl
|
||||
FROM station_profile
|
||||
WHERE COALESCE(webadifapikey, '') <> ''
|
||||
AND COALESCE(webadifapiurl, '') <> ''
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->result();
|
||||
if ($result) {
|
||||
return $result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function get_last_qsos($num, $StationLocationsArray = null) {
|
||||
|
||||
if($StationLocationsArray == null) {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ class Stations extends CI_Model {
|
|||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
|
||||
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
|
||||
'webadifapikey' => xss_clean($this->input->post('webadifapikey', true)),
|
||||
'webadifapiurl' => 'https://qo100dx.club/api',
|
||||
'webadifrealtime' => xss_clean($this->input->post('webadifrealtime', true)),
|
||||
);
|
||||
|
||||
// Insert Records
|
||||
|
|
@ -111,6 +114,9 @@ class Stations extends CI_Model {
|
|||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
'oqrs_email' => xss_clean($this->input->post('oqrsemail', true)),
|
||||
'oqrs_text' => xss_clean($this->input->post('oqrstext', true)),
|
||||
'webadifapikey' => xss_clean($this->input->post('webadifapikey', true)),
|
||||
'webadifapiurl' => 'https://qo100dx.club/api',
|
||||
'webadifrealtime' => xss_clean($this->input->post('webadifrealtime', true)),
|
||||
);
|
||||
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
|
|
@ -339,6 +345,35 @@ class Stations extends CI_Model {
|
|||
return $query;
|
||||
}
|
||||
|
||||
function stations_with_webadif_api_key() {
|
||||
$sql="
|
||||
SELECT station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, notc.c notcount, totc.c totcount
|
||||
FROM station_profile
|
||||
INNER JOIN (
|
||||
SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c
|
||||
FROM %s qsos
|
||||
LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id
|
||||
WHERE webadif.qso_id IS NULL
|
||||
GROUP BY qsos.station_id
|
||||
) notc ON station_profile.station_id = notc.station_id
|
||||
INNER JOIN (
|
||||
SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c
|
||||
FROM %s qsos
|
||||
GROUP BY qsos.station_id
|
||||
) totc ON station_profile.station_id = totc.station_id
|
||||
WHERE COALESCE(station_profile.webadifapikey, '') <> ''
|
||||
AND COALESCE(station_profile.webadifapiurl, '') <> ''
|
||||
AND station_profile.user_id = %d
|
||||
";
|
||||
$sql=sprintf(
|
||||
$sql,
|
||||
$this->config->item('table_name'),
|
||||
$this->config->item('table_name'),
|
||||
$this->session->userdata('user_id')
|
||||
);
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: are_eqsl_nicks_defined
|
||||
* Description: Returns number of station profiles with eqslnicknames
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ function load_was_map() {
|
|||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/continents.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "adif" || $this->uri->segment(1) == "qrz") { ?>
|
||||
<?php if ($this->uri->segment(1) == "adif" || $this->uri->segment(1) == "qrz" || $this->uri->segment(1) == "webadif") { ?>
|
||||
<!-- Javascript used for ADIF Import and Export Areas -->
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||
|
|
@ -1600,6 +1600,9 @@ $(document).ready(function(){
|
|||
<?php if ($this->uri->segment(1) == "qrz") { ?>
|
||||
<script src="<?php echo base_url(); ?>assets/js/sections/qrzlogbook.js"></script>
|
||||
<?php } ?>
|
||||
<?php if ($this->uri->segment(1) == "webadif") { ?>
|
||||
<script src="<?php echo base_url(); ?>assets/js/sections/webadif.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<script>
|
||||
function displayQso(id) {
|
||||
|
|
|
|||
|
|
@ -257,6 +257,8 @@ $oqrs_requests = $CI->oqrs_model->oqrs_requests($location_list);
|
|||
|
||||
<a class="dropdown-item" href="<?php echo site_url('qrz/export');?>" title="Upload to QRZ.com logbook"><i class="fas fa-sync"></i> QRZ Logbook</a>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('webadif/export');?>" title="Upload to webADIF"><i class="fas fa-sync"></i> QO-100 Dx Club Upload</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('api/help');?>" title="Manage API keys"><i class="fas fa-key"></i> API Keys</a>
|
||||
|
|
|
|||
|
|
@ -241,6 +241,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="webadifApiKey"> QO-100 Dx Club API Key </label>
|
||||
<input type="text" class="form-control" name="webadifapikey" id="webadifApiKey" aria-describedby="webadifApiKeyHelp">
|
||||
<small id="webadifApiKeyHelp" class="form-text text-muted">Create your API key on <a href="https://qo100dx.club" target="_blank">your QO-100 Dx Club's profile page</a></small>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="webadifrealtime">QO-100 Dx Club Realtime Upload</label>
|
||||
<select class="custom-select" id="webadifrealtime" name="webadifrealtime">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected>No</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="oqrs">OQRS Enabled</label>
|
||||
<select class="custom-select" id="oqrs" name="oqrs">
|
||||
|
|
|
|||
|
|
@ -356,6 +356,27 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<h5 class="card-header">QO-100 Dx Club</h5>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="webadifApiKey">QO-100 Dx Club API Key</label>
|
||||
<input type="text" class="form-control" name="webadifapikey" id="webadifApiKey" aria-describedby="webadifApiKeyHelp" value="<?php if(set_value('webadifapikey') != "") { echo set_value('webadifapikey'); } else { echo $my_station_profile->webadifapikey; } ?>">
|
||||
<small id="webadifApiKeyHelp" class="form-text text-muted">Create your API key on <a href="https://qo100dx.club" target="_blank">your QO-100 Dx Club's profile page</a></small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="webadifrealtime">QO-100 Dx Club Realtime Upload</label>
|
||||
<select class="custom-select" id="webadifrealtime" name="webadifrealtime">
|
||||
<option value="1" <?php if ($my_station_profile->webadifrealtime == 1) { echo " selected =\"selected\""; } ?>>Yes</option>
|
||||
<option value="0" <?php if ($my_station_profile->webadifrealtime == 0) { echo " selected =\"selected\""; } ?>>No</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
<div class="container adif">
|
||||
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<ul class="nav nav-tabs card-header-tabs pull-right" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="export-tab" data-toggle="tab" href="#export" role="tab" aria-controls="import" aria-selected="true">Upload Logbook</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="mark-tab" data-toggle="tab" href="#mark" role="tab" aria-controls="export" aria-selected="false">Mark QSOs</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="export" role="tabpanel" aria-labelledby="export-tab">
|
||||
<p>Here you can see and upload all QSOs which have not been previously uploaded to QO-100 Dx Club.</p>
|
||||
<p>You need to set a QO-100 Dx Club API key in your station profile. Only station profiles with an API Key are displayed.</p>
|
||||
<p><span class="badge badge-warning">Warning</span>This might take a while as QSO uploads are processed sequentially.</p>
|
||||
|
||||
<?php
|
||||
if ($station_profile->result()) {
|
||||
echo '
|
||||
|
||||
<table class="table table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Profile name</td>
|
||||
<td>Station callsign</td>
|
||||
<td>Total QSOs not uploaded</td>
|
||||
<td>Total QSOs uploaded</td>
|
||||
<td>Actions</td>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($station_profile->result() as $station) { // Fills the table with the data
|
||||
echo '<tr>';
|
||||
echo '<td>' . $station->station_profile_name . '</td>';
|
||||
echo '<td>' . $station->station_callsign . '</td>';
|
||||
echo '<td id ="notcount'.$station->station_id.'">' . $station->notcount . '</td>';
|
||||
echo '<td id ="totcount'.$station->station_id.'">' . $station->totcount . '</td>';
|
||||
echo '<td><button id="webadifUpload" type="button" name="webadifUpload" class="btn btn-primary btn-sm ld-ext-right" onclick="ExportWebADIF('. $station->station_id .')"><i class="fas fa-cloud-upload-alt"></i> Upload<div class="ld ld-ring ld-spin"></div></button></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table>';
|
||||
|
||||
}
|
||||
else {
|
||||
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div class="tab-pane fade" id="mark" role="tabpanel" aria-labelledby="home-tab">
|
||||
|
||||
<form class="form" action="<?php echo site_url('webadif/mark_webadif'); ?>" method="post" enctype="multipart/form-data">
|
||||
<select name="station_profile" class="custom-select mb-4 mr-sm-4" style="width: 30%;">
|
||||
<option value="0">Select Station Location</option>
|
||||
<?php foreach ($station_profiles->result() as $station) { ?>
|
||||
<option value="<?php echo $station->station_id; ?>">Callsign: <?php echo $station->station_callsign; ?> (<?php echo $station->station_profile_name; ?>)</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p><span class="badge badge-warning">Warning</span> If a date range is not selected then all QSOs will be marked!</p>
|
||||
<p class="card-text">From date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker5" data-target-input="nearest">
|
||||
<input name="from" type="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker5" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="card-text">To date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker6" data-target-input="nearest">
|
||||
<input name="to" "totype="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker2"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker6" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="button" id="markWebAdifAsExported" class="btn-sm btn-primary" value="Export">Mark QSOs as exported to QO-100 Dx Club</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<div class="container">
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
<p><?php echo $this->session->flashdata('message'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
QSOs marked
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">Yay, it's done!</h3>
|
||||
<p class="card-text">The QSOs are marked as exported to QO-100 Dx Club.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
70
assets/js/sections/webadif.js
普通文件
70
assets/js/sections/webadif.js
普通文件
|
|
@ -0,0 +1,70 @@
|
|||
$(function () {
|
||||
$('#datetimepicker5').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('#datetimepicker6').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#markWebAdifAsExported').click(function(e){
|
||||
let form = $(this).closest('form');
|
||||
let station = form.find('select[name=station_profile]');
|
||||
if (station.val() == 0) {
|
||||
station.addClass('is-invalid');
|
||||
}else{
|
||||
form.submit();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function ExportWebADIF(station_id) {
|
||||
if ($(".alert").length > 0) {
|
||||
$(".alert").remove();
|
||||
}
|
||||
if ($(".errormessages").length > 0) {
|
||||
$(".errormessages").remove();
|
||||
}
|
||||
$(".ld-ext-right").addClass('running');
|
||||
$(".ld-ext-right").prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/webadif/upload_station',
|
||||
type: 'post',
|
||||
data: {'station_id': station_id},
|
||||
success: function (data) {
|
||||
$(".ld-ext-right").removeClass('running');
|
||||
$(".ld-ext-right").prop('disabled', false);
|
||||
if (data.status == 'OK') {
|
||||
$.each(data.info, function(index, value){
|
||||
$('#notcount'+value.station_id).html(value.notcount);
|
||||
$('#totcount'+value.station_id).html(value.totcount);
|
||||
});
|
||||
$(".card-body").append('<div class="alert alert-success" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>' + data.infomessage + '</div>');
|
||||
}
|
||||
else {
|
||||
$(".card-body").append('<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>' + data.info + '</div>');
|
||||
}
|
||||
|
||||
if (data.errormessages.length > 0) {
|
||||
$(".card-body").append('' +
|
||||
'<div class="errormessages"><p>\n' +
|
||||
' <button class="btn btn-danger" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">\n' +
|
||||
' Show error messages\n' +
|
||||
' </button>\n' +
|
||||
' </p>\n' +
|
||||
' <div class="collapse" id="collapseExample">\n' +
|
||||
' <div class="card card-body"><div class="errors"></div>\n' +
|
||||
' </div>\n' +
|
||||
' </div></div>');
|
||||
$.each(data.errormessages, function(index, value) {
|
||||
$(".errors").append('<li>' + value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
正在加载…
在新工单中引用