Check certs for superseded status

This commit is contained in:
phl0
2025-11-20 13:00:25 +01:00
parent a207bcee51
commit 64d80ef4e5
3 changed files with 28 additions and 11 deletions

View File

@@ -46,6 +46,15 @@ class Lotw extends CI_Controller {
// Load required models for page generation
$this->load->model('Lotw_model');
// Check for superseded certificates
$certcheck = $this->Lotw_model->lotw_certs($this->session->userdata('user_id'));
foreach ($certcheck->result() as $row) {
$status = $this->lotw_cert_status($row->serial);
if ($status != 99 && $status != $row->status) {
$this->Lotw_model->update_cert_status($row->lotw_cert_id, $status);
}
}
// Get Array of the logged in users LoTW certs.
$data['lotw_cert_results'] = $this->Lotw_model->lotw_certs($this->session->userdata('user_id'));

View File

@@ -12,7 +12,7 @@ class Lotw_model extends CI_Model {
*/
function lotw_certs($user_id) {
$this->db->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.serial as serial, 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->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.serial as serial, lotw_certs.status as status, 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('callsign', 'ASC');
@@ -156,7 +156,11 @@ class Lotw_model extends CI_Model {
} else {
return false;
}
}
function update_cert_status($cert_id, $status) {
$sql = "UPDATE `lotw_certs` SET status = ? WHERE lotw_cert_id = ?;";
$query = $this->db->query($sql, array($status, $cert_id));
}
}

View File

@@ -92,17 +92,21 @@
} ?>
</td>
<td>
<?php if ($current_date > $row->date_expires) { ?>
<span class="badge text-bg-danger"><?= __("Certificate expired"); ?></span>
<?php } else if ($current_date <= $row->date_expires && $current_date > $cert_warning_date) { ?>
<span class="badge text-bg-warning"><?= __("Certificate expiring"); ?></span>
<?php if ($row->status == 1) { ?>
<span class="badge text-bg-danger"><?= __("Certificate superseded"); ?></span>
<?php } else { ?>
<span class="badge text-bg-success"><?= __("Certificate valid"); ?></span>
<?php } ?>
<?php if ($current_date > $row->qso_end_date) { ?>
<span class="badge text-bg-danger">QSO end date exceeded</span>
<?php } else if ($current_date <= $row->qso_end_date && $current_date > $qso_warning_date) { ?>
<span class="badge text-bg-warning"><?= __("QSO end date nearing"); ?></span>
<?php if ($current_date > $row->date_expires) { ?>
<span class="badge text-bg-danger"><?= __("Certificate expired"); ?></span>
<?php } else if ($current_date <= $row->date_expires && $current_date > $cert_warning_date) { ?>
<span class="badge text-bg-warning"><?= __("Certificate expiring"); ?></span>
<?php } else { ?>
<span class="badge text-bg-success"><?= __("Certificate valid"); ?></span>
<?php } ?>
<?php if ($current_date > $row->qso_end_date) { ?>
<span class="badge text-bg-danger">QSO end date exceeded</span>
<?php } else if ($current_date <= $row->qso_end_date && $current_date > $qso_warning_date) { ?>
<span class="badge text-bg-warning"><?= __("QSO end date nearing"); ?></span>
<?php } ?>
<?php } ?>
</td>
<td>