Add QSO end date expiry to dashbaord banner as well

This commit is contained in:
phl0
2025-10-24 11:23:58 +02:00
parent eb268b0260
commit 2fda94357e
3 changed files with 36 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ class Dashboard extends CI_Controller {
$current_date = date('Y-m-d H:i:s');
$data['lotw_cert_expired'] = $this->Lotw_model->lotw_cert_expired($this->session->userdata('user_id'), $current_date);
$data['lotw_cert_expiring'] = $this->Lotw_model->lotw_cert_expiring($this->session->userdata('user_id'), $current_date);
$data['lotw_cert_qsoenddate_expired'] = $this->Lotw_model->lotw_cert_qsoenddate_expired($this->session->userdata('user_id'), $current_date);
$data['lotw_cert_qsoenddate_expiring'] = $this->Lotw_model->lotw_cert_qsoenddate_expiring($this->session->userdata('user_id'), $current_date);
$this->load->model('logbooks_model');

View File

@@ -127,5 +127,29 @@ class Lotw_model extends CI_Model {
}
}
function lotw_cert_qsoenddate_expired($user_id, $date) {
$array = array('user_id' => $user_id, 'qso_end_date <' => $date);
$this->db->where($array);
$query = $this->db->get('lotw_certs');
if ($query->num_rows() > 0) {
return true;
} else {
return false;
}
}
function lotw_cert_qsoenddate_expiring($user_id, $date) {
$array = array('user_id' => $user_id, 'DATE_SUB(qso_end_date, INTERVAL 30 DAY) <' => $date, 'qso_end_date >' => $date);
$this->db->where($array);
$query = $this->db->get('lotw_certs');
if ($query->num_rows() > 0) {
return true;
} else {
return false;
}
}
}
?>

View File

@@ -204,17 +204,20 @@ function getDistance($distance) {
<?php if ($this->session->userdata('user_id')) { ?>
<?php
if($lotw_cert_expired == true) { ?>
if($lotw_cert_expired == true || $lotw_cert_qsoenddate_expired == true) { ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<span class="badge text-bg-info"><?= __("Important"); ?></span> <i class="fas fa-hourglass-end"></i> <?= sprintf(_pgettext("LoTW Warning", "At least one of your %sLoTW certificates%s is expired!"), '<u><a href="' . site_url('lotw') . '">', "</a></u>"); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php } elseif($lotw_cert_expiring == true) { ?>
<?php } elseif($lotw_cert_expiring == true || $lotw_cert_qsoenddate_expiring == true) { ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<span class="badge text-bg-info"><?= __("Important"); ?></span> <i class="fas fa-hourglass-half"></i> <?= sprintf(_pgettext("LoTW Warning", "At least one of your %sLoTW certificates%s is about to expire!"), '<u><a href="' . site_url('lotw') . '">', "</a></u>"); ?>
<?php } ?>
<span class="badge text-bg-info"><?= __("Important"); ?></span> <i class="fas fa-hourglass-half"></i> <?= sprintf(_pgettext("LoTW Warning", "LoTW Warning: There is an issue with at least one of your %sLoTW certificates%s!"), '<u><a href="'.site_url('lotw').'">', "</a></u>"); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<ul style="margin-top: 0.5em; margin-bottom: 0.1em;">
<?php if ($lotw_cert_expired == true) { echo "<li>".__("At least one of your certificates is expired"); } ?>
<?php if ($lotw_cert_expiring == true) { echo "<li>".__("At least one of your certificates is expiring"); } ?>
<?php if ($lotw_cert_qsoenddate_expired == true) { echo "<li>".__("The QSO end date of at least one of your certificates was exceeded"); } ?>
<?php if ($lotw_cert_qsoenddate_expiring == true) { echo "<li>".__("The QSO end date of at least one of your certificates is about to be exceeded"); } ?>
</ul>
</div>
<?php } ?>
<?php } ?>
<?php } ?>