UI Improvement to Domains, Certificates and Licenses listing: Updated Expire to show TimeAgo as well and to highlight table rows red if expiring within 14 Days, yellow for 90 days and gray if expired also updated side badges to refelect the badge color as well

This commit is contained in:
johnnyq 2024-09-13 13:31:18 -04:00
parent 208e56e784
commit 6bb56f7c51
5 changed files with 115 additions and 14 deletions

View File

@ -102,8 +102,27 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$certificate_expire = nullable_htmlentities($row['certificate_expire']);
$certificate_created_at = nullable_htmlentities($row['certificate_created_at']);
$certificate_expire_ago = timeAgo($certificate_expire);
// Convert the expiry date to a timestamp
$certificate_expire_timestamp = strtotime($row['certificate_expire']);
$current_timestamp = time(); // Get current timestamp
// Calculate the difference in days
$days_until_expiry = ($certificate_expire_timestamp - $current_timestamp) / (60 * 60 * 24);
// Determine the class based on the number of days until expiry
if ($days_until_expiry <= 0) {
$tr_class = "table-secondary";
} elseif ($days_until_expiry <= 14) {
$tr_class = "table-danger";
} elseif ($days_until_expiry <= 90) {
$tr_class = "table-warning";
} else {
$tr_class = '';
}
?>
<tr>
<tr class="<?php echo $tr_class; ?>">
<td class="pr-0">
<div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="certificate_ids[]" value="<?php echo $certificate_id ?>">
@ -125,7 +144,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<td><?php echo $certificate_issued_by; ?></td>
<td><?php echo $certificate_expire; ?></td>
<td>
<div><?php echo $certificate_expire; ?></div>
<div><small><?php echo $certificate_expire_ago; ?></small></div>
</td>
<td>
<div class="dropdown dropleft text-center">

View File

@ -126,6 +126,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$domain_name = nullable_htmlentities($row['domain_name']);
$domain_description = nullable_htmlentities($row['domain_description']);
$domain_expire = nullable_htmlentities($row['domain_expire']);
$domain_expire_ago = timeAgo($domain_expire);
// Convert the expiry date to a timestamp
$domain_expire_timestamp = strtotime($row['domain_expire']);
$current_timestamp = time(); // Get current timestamp
// Calculate the difference in days
$days_until_expiry = ($domain_expire_timestamp - $current_timestamp) / (60 * 60 * 24);
// Determine the class based on the number of days until expiry
if ($days_until_expiry <= 0) {
$tr_class = "table-secondary";
} elseif ($days_until_expiry <= 14) {
$tr_class = "table-danger";
} elseif ($days_until_expiry <= 90) {
$tr_class = "table-warning";
} else {
$tr_class = '';
}
$domain_registrar_name = nullable_htmlentities($row['registrar_name']);
if($domain_registrar_name) {
$domain_registrar_name_display = $domain_registrar_name;
@ -144,7 +162,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$domain_mailhost_name_display = $domain_mailhost_name ? $domain_mailhost_name : "-";
?>
<tr>
<tr class="<?php echo $tr_class; ?>">
<td class="pr-0">
<div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="domain_ids[]" value="<?php echo $domain_id ?>">
@ -165,7 +183,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<td><?php echo $domain_webhost_name_display; ?></td>
<td><?php echo $domain_dnshost_name_display; ?></td>
<td><?php echo $domain_mailhost_name_display; ?></td>
<td><?php echo $domain_expire; ?></td>
<td>
<div><?php echo $domain_expire; ?></div>
<div><small><?php echo $domain_expire_ago; ?></small></div>
</td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">

View File

@ -136,7 +136,7 @@
Licenses
<?php
if ($num_software > 0) { ?>
<span class="right badge text-light"><?php echo $num_software; ?></span>
<span class="right badge <?php if ($num_software_expiring > 0) { ?> badge-warning text-dark <?php } ?> <?php if ($num_software_expired > 0) { ?> badge-danger <?php } ?> text-white"><?php echo $num_software; ?></span>
<?php } ?>
</p>
</a>
@ -189,7 +189,7 @@
<?php
if ($num_certificates > 0) { ?>
<span class="right badge <?php if ($num_certs_expiring > 0) { ?> badge-warning text-dark <?php } ?> text-light"><?php echo $num_certificates; ?></span>
<span class="right badge <?php if ($num_certificates_expiring > 0) { ?> badge-warning text-dark <?php } ?> <?php if ($num_certificates_expired > 0) { ?> badge-danger <?php } ?> text-white"><?php echo $num_certificates; ?></span>
<?php } ?>
</p>
</a>

View File

@ -101,6 +101,25 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$software_notes = nullable_htmlentities($row['software_notes']);
$software_created_at = nullable_htmlentities($row['software_created_at']);
$software_expire_ago = timeAgo($software_expire);
// Convert the expiry date to a timestamp
$software_expire_timestamp = strtotime($row['software_expire']);
$current_timestamp = time(); // Get current timestamp
// Calculate the difference in days
$days_until_expiry = ($software_expire_timestamp - $current_timestamp) / (60 * 60 * 24);
// Determine the class based on the number of days until expiry
if ($days_until_expiry <= 0) {
$tr_class = "table-secondary";
} elseif ($days_until_expiry <= 14) {
$tr_class = "table-danger";
} elseif ($days_until_expiry <= 90) {
$tr_class = "table-warning";
} else {
$tr_class = '';
}
$seat_count = 0;
// Asset Licenses
@ -124,7 +143,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
?>
<tr>
<tr class="<?php echo $tr_class; ?>">
<td>
<a class="text-dark" href="#" data-toggle="modal" data-target="#editSoftwareModal<?php echo $software_id; ?>">
<div class="media">

View File

@ -212,18 +212,18 @@ if (isset($_GET['client_id'])) {
// Expiring Items
// Count Domains Expiring within 30 Days
// Count Domains Expiring within 90 Days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('domain_id') AS num FROM domains
WHERE domain_client_id = $client_id
AND domain_expire IS NOT NULL
AND domain_expire < CURRENT_DATE + INTERVAL 30 DAY
AND domain_expire < CURRENT_DATE + INTERVAL 90 DAY
AND domain_archived_at IS NULL"
));
$num_domains_expiring = intval($row['num']);
// Count Domains Expired or within 5 days
// Count Domains Expired or within 14 days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('domain_id') AS num FROM domains
@ -231,22 +231,61 @@ if (isset($_GET['client_id'])) {
AND domain_expire IS NOT NULL
AND (
domain_expire < CURRENT_DATE
OR domain_expire < CURRENT_DATE + INTERVAL 5 DAY
OR domain_expire < CURRENT_DATE + INTERVAL 14 DAY
)
AND domain_archived_at IS NULL"
));
$num_domains_expired = intval($row['num']);
// Count Certificates Expiring within 30 Days
// Count Certificates Expiring within 90 Days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('certificate_id') AS num FROM certificates
WHERE certificate_client_id = $client_id
AND certificate_expire IS NOT NULL
AND certificate_expire < CURRENT_DATE + INTERVAL 30 DAY
AND certificate_expire < CURRENT_DATE + INTERVAL 90 DAY
AND certificate_archived_at IS NULL"
));
$num_certs_expiring = intval($row['num']);
$num_certificates_expiring = intval($row['num']);
// Count Certificates Expired or within 14 days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('certificate_id') AS num FROM certificates
WHERE certificate_client_id = $client_id
AND certificate_expire IS NOT NULL
AND (
certificate_expire < CURRENT_DATE
OR certificate_expire < CURRENT_DATE + INTERVAL 14 DAY
)
AND certificate_archived_at IS NULL"
));
$num_certificates_expired = intval($row['num']);
// Count Software Expiring within 90 Days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('software_id') AS num FROM software
WHERE software_client_id = $client_id
AND software_expire IS NOT NULL
AND software_expire < CURRENT_DATE + INTERVAL 90 DAY
AND software_archived_at IS NULL"
));
$num_software_expiring = intval($row['num']);
// Count Software Expired or within 14 days
$row = mysqli_fetch_assoc(mysqli_query(
$mysqli,
"SELECT COUNT('software_id') AS num FROM software
WHERE software_client_id = $client_id
AND software_expire IS NOT NULL
AND (
software_expire < CURRENT_DATE
OR software_expire < CURRENT_DATE + INTERVAL 14 DAY
)
AND software_archived_at IS NULL"
));
$num_software_expired = intval($row['num']);
}
}