Show infos about last LoTW upload and status

This commit is contained in:
phl0
2024-05-16 09:50:30 +02:00
parent d137302806
commit 51864673b3
10 changed files with 85 additions and 23 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 198;
$config['migration_version'] = 199;
/*
|--------------------------------------------------------------------------

View File

@@ -323,6 +323,7 @@ class Lotw extends CI_Controller {
//with the error message.
if(curl_errno($ch)){
echo $station_profile->station_callsign." (".$station_profile->station_profile_name.") Upload Failed"."<br>";
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
}
$pos = strpos($result, "<!-- .UPL. accepted -->");
@@ -330,12 +331,13 @@ class Lotw extends CI_Controller {
if ($pos === false) {
// Upload of TQ8 Failed for unknown reason
echo $station_profile->station_callsign." (".$station_profile->station_profile_name.") Upload Failed"."<br>";
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed");
} else {
// Upload of TQ8 was successfull
echo "Upload Successful - ".$filename_for_saving."<br>";
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id);
$this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success");
// Mark QSOs as Sent
foreach ($qso_id_array as $qso_number) {

View File

@@ -18,7 +18,7 @@ $lang['lotw_date_created'] = 'Date Created';
$lang['lotw_date_expires'] = 'Date Expires';
$lang['lotw_qso_start_date'] = 'QSO Start Date';
$lang['lotw_qso_end_date'] = 'QSO End Date';
$lang['lotw_status'] = 'Status / Last upload';
$lang['lotw_status'] = 'Status';
$lang['lotw_options'] = 'Options';
$lang['lotw_valid'] = 'Valid';
$lang['lotw_expired'] = 'Expired';

View File

@@ -18,7 +18,7 @@ $lang['lotw_date_created'] = 'Date Created';
$lang['lotw_date_expires'] = 'Date Expires';
$lang['lotw_qso_start_date'] = 'QSO Start Date';
$lang['lotw_qso_end_date'] = 'QSO End Date';
$lang['lotw_status'] = 'Status / Last upload';
$lang['lotw_status'] = 'Status';
$lang['lotw_options'] = 'Options';
$lang['lotw_valid'] = 'Valid';
$lang['lotw_expired'] = 'Expired';
@@ -60,7 +60,7 @@ $lang['lotw_cert_expired'] = 'At least one of your LoTW certificates is expired!
// Lotw User
$lang['lotw_user'] = 'This station uses LoTW.';
$lang['lotw_last_upload'] = 'Last upload';
$lang['lotw_last_upload'] = 'Last Upload';
// Upload folder permissions
$lang['lotw_upload_folder_permissions'] = 'Upload folder is not writable. Please contact your admin.';

View File

@@ -18,7 +18,7 @@ $lang['lotw_date_created'] = 'Päivä jolloin luotu';
$lang['lotw_date_expires'] = 'Päivä joloin vanhenee';
$lang['lotw_qso_start_date'] = 'QSO aloituspäivä';
$lang['lotw_qso_end_date'] = 'QSO lopetuspäivä';
$lang['lotw_status'] = 'Status / Last upload';
$lang['lotw_status'] = 'Status';
$lang['lotw_options'] = 'Lisävaihtoehdot';
$lang['lotw_valid'] = 'Voimassa';
$lang['lotw_expired'] = 'Vanhentunut';

View File

@@ -18,7 +18,7 @@ $lang['lotw_date_created'] = 'Ausstellungsdatum';
$lang['lotw_date_expires'] = 'Ablaufdatum';
$lang['lotw_qso_start_date'] = 'QSO Startdatum';
$lang['lotw_qso_end_date'] = 'QSO Enddatum';
$lang['lotw_status'] = 'Status / Letzter Upload';
$lang['lotw_status'] = 'Status';
$lang['lotw_options'] = 'Optionen';
$lang['lotw_valid'] = 'Gültig';
$lang['lotw_expired'] = 'Abgelaufen';

View File

@@ -18,7 +18,7 @@ $lang['lotw_date_created'] = 'Ημερομηνία Δημιουργίας';
$lang['lotw_date_expires'] = 'Ημερομηνία Λήξης ';
$lang['lotw_qso_start_date'] = 'Ημερομηνία έναρξης QSO';
$lang['lotw_qso_end_date'] = 'Ημερομηνία λήξης QSO';
$lang['lotw_status'] = 'Κατάσταση / Τελευταία μεταφόρτωση';
$lang['lotw_status'] = 'Κατάσταση';
$lang['lotw_options'] = 'Επιλογές';
$lang['lotw_valid'] = 'Εγκυρος';
$lang['lotw_expired'] = 'Ληγμένο';
@@ -60,7 +60,7 @@ $lang['lotw_cert_expired'] = 'Τουλάχιστον ένα από τα πιστ
// Lotw User
$lang['lotw_user'] = 'This station uses LoTW.';
$lang['lotw_last_upload'] = 'Last upload';
$lang['lotw_last_upload'] = 'Τελευταία μεταφόρτωση';
// Upload folder permissions
$lang['lotw_upload_folder_permissions'] = 'Upload folder is not writable. Please contact your admin.';

View File

@@ -0,0 +1,35 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
// Adding a column to store status message about last LoTW upload
class Migration_add_lotw_upload_status_message extends CI_Migration
{
public function up()
{
if (!$this->db->field_exists('last_upload_fail', 'lotw_certs')) {
$fields = array(
'last_upload_fail DATETIME NULL DEFAULT NULL AFTER `last_upload`'
);
$this->dbforge->add_column('lotw_certs', $fields);
}
if (!$this->db->field_exists('last_upload_status', 'lotw_certs')) {
$fields = array(
'last_upload_status VARCHAR(50) NULL DEFAULT NULL AFTER `last_upload_fail`',
);
$this->dbforge->add_column('lotw_certs', $fields);
}
}
public function down()
{
if ($this->db->field_exists('last_upload_fail', 'lotw_certs')) {
$this->dbforge->drop_column('lotw_certs', 'last_upload_fail');
}
if ($this->db->field_exists('last_upload_status', 'lotw_certs')) {
$this->dbforge->drop_column('lotw_certs', 'last_upload_status');
}
}
}

View File

@@ -12,7 +12,7 @@ class LotwCert extends CI_Model {
*/
function lotw_certs($user_id) {
$this->db->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.callsign as callsign, dxcc_entities.name as cert_dxcc, dxcc_entities.end as cert_dxcc_end, lotw_certs.qso_start_date as qso_start_date, lotw_certs.qso_end_date as qso_end_date, lotw_certs.date_created as date_created, lotw_certs.date_expires as date_expires, lotw_certs.last_upload as last_upload');
$this->db->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.callsign as callsign, dxcc_entities.name as cert_dxcc, dxcc_entities.end as cert_dxcc_end, lotw_certs.qso_start_date as qso_start_date, lotw_certs.qso_end_date as qso_end_date, lotw_certs.date_created as date_created, lotw_certs.date_expires as date_expires, lotw_certs.last_upload as last_upload, lotw_certs.last_upload_fail as last_upload_fail, lotw_certs.last_upload_status as last_upload_status');
$this->db->where('user_id', $user_id);
$this->db->join('dxcc_entities','lotw_certs.cert_dxcc_id = dxcc_entities.adif','left');
$this->db->order_by('cert_dxcc', 'ASC');
@@ -77,19 +77,29 @@ class LotwCert extends CI_Model {
$this->db->delete('lotw_certs');
}
function last_upload($certID) {
function last_upload($certID, $message) {
$data = array(
'last_upload' => date("Y-m-d H:i:s"),
);
if ($message == "Success") {
$data = array(
'last_upload' => date("Y-m-d H:i:s"),
'last_upload_status' => $message,
);
$this->db->where('lotw_cert_id', $certID);
$this->db->update('lotw_certs', $data);
return "Updated";
}
else if ($message == "Upload failed") {
$data = array(
'last_upload_fail' => date("Y-m-d H:i:s"),
'last_upload_status' => $message,
);
$this->db->where('lotw_cert_id', $certID);
$this->db->update('lotw_certs', $data);
return "Updated";
}
$this->db->where('lotw_cert_id', $certID);
$this->db->update('lotw_certs', $data);
return "Updated";
}
}
function empty_table($table) {
$this->db->empty_table($table);

View File

@@ -40,6 +40,7 @@
<th scope="col"><?php echo lang('lotw_date_created'); ?></th>
<th scope="col"><?php echo lang('lotw_date_expires'); ?></th>
<th scope="col"><?php echo lang('lotw_status'); ?></th>
<th scope="col"><?php echo lang('lotw_last_upload'); ?></th>
<th scope="col"><?php echo lang('lotw_options'); ?></th>
</tr>
</thead>
@@ -90,10 +91,24 @@
<?php } else { ?>
<span class="badge text-bg-success"><?php echo lang('lotw_valid'); ?></span>
<?php } ?>
</td>
<td>
<?php if ($row->last_upload) {
$last_upload = date($this->config->item('qso_date_format').' H:i:s', strtotime( $row->last_upload )); ?>
<span class="badge text-bg-success"><?php echo $last_upload; ?></span>
$last_upload = date($this->config->item('qso_date_format').' H:i:s', strtotime( $row->last_upload ));
if ($row->last_upload_fail) {
$last_upload_fail = date($this->config->item('qso_date_format').' H:i:s', strtotime( $row->last_upload_fail ));
} else {
$last_upload_fail = null;
}
if ($last_upload_fail > $last_upload) { ?>
<span data-bs-toggle="tooltip" data-bs-original-title="<?php echo $row->last_upload_status;?>. Last success: <?php echo $last_upload; ?>" class="badge text-bg-danger"><?php echo $last_upload_fail; ?></span>
<?php } else {
if ($last_upload_fail && $row->last_upload_status) { ?>
<span data-bs-toggle="tooltip" data-bs-original-title="<?php echo $row->last_upload_status;?>. Last fail: <?php echo $last_upload_fail; ?>" class="badge text-bg-success"><?php echo $last_upload; ?></span>
<?php } else { ?>
<span class="badge text-bg-success"><?php echo $last_upload; ?></span>
<?php } ?>
<?php } ?>
<?php } else { ?>
<span class="badge text-bg-warning"><?php echo lang('lotw_not_synced'); ?></span>
<?php } ?>