Add Empty state messages in client portal instead of just showing an empty table with the table header

This commit is contained in:
johnnyq
2026-08-28 15:26:43 -04:00
parent c10d4eb736
commit 194841e7f8
13 changed files with 60 additions and 3 deletions

View File

@@ -25,6 +25,9 @@ $assets_sql = mysqli_query($mysqli, "SELECT asset_description, asset_id, asset_m
<div class="col-md-12">
<?php if (mysqli_num_rows($assets_sql) == 0) { ?>
<?= portalEmptyState('There are no assets on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -84,6 +87,7 @@ $assets_sql = mysqli_query($mysqli, "SELECT asset_description, asset_id, asset_m
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -18,6 +18,9 @@ $certificates_sql = mysqli_query($mysqli, "SELECT certificate_id, certificate_na
<div class="col-md-10">
<?php if (mysqli_num_rows($certificates_sql) == 0) { ?>
<?= portalEmptyState('There are no web certificates on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -49,6 +52,7 @@ $certificates_sql = mysqli_query($mysqli, "SELECT certificate_id, certificate_na
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -26,6 +26,9 @@ $contacts_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_
<div class="col-md-10">
<?php if (mysqli_num_rows($contacts_sql) == 0) { ?>
<?= portalEmptyState('There are no contacts on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -68,6 +71,7 @@ $contacts_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -31,6 +31,9 @@ $documents_sql = mysqli_query($mysqli, "SELECT document_id, document_name, docum
<div class="row mt-3">
<div class="col-md-12">
<?php if (mysqli_num_rows($documents_sql) == 0) { ?>
<?= portalEmptyState('There are no documents shared with you yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -73,6 +76,7 @@ $documents_sql = mysqli_query($mysqli, "SELECT document_id, document_name, docum
</tbody>
</table>
<?php } ?>
</div>
</div>

View File

@@ -18,6 +18,9 @@ $domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name, domain_expi
<div class="col-md-10">
<?php if (mysqli_num_rows($domains_sql) == 0) { ?>
<?= portalEmptyState('There are no domains on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -43,6 +46,7 @@ $domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name, domain_expi
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -72,6 +72,21 @@ function enforceContactCan($capability) {
}
}
/*
* The empty state for the portal's list pages.
*
* Every list page here renders a header row and then a while loop, so a client
* with no assets, no quotes or no documents used to get a table with nothing
* under it - indistinguishable from a page that failed to load. This says so
* instead.
*
* Default is neutral, for a list that simply has nothing in it yet. Pass
* 'success' where empty is genuinely good news (nothing owed, nothing unpaid).
*/
function portalEmptyState($message, $icon = 'fa-inbox', $type = 'secondary') {
return '<div class="alert alert-' . $type . '"><i class="fa fa-fw ' . $icon . ' me-2"></i>' . $message . '</div>';
}
/*
* Returns appropriate FontAwesome icon for file extension
*/

View File

@@ -20,6 +20,9 @@ $invoices_sql = mysqli_query($mysqli, "SELECT invoice_amount, invoice_date, invo
<div class="col-md-10">
<?php if (mysqli_num_rows($invoices_sql) == 0) { ?>
<?= portalEmptyState('There are no invoices on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -89,6 +92,7 @@ $invoices_sql = mysqli_query($mysqli, "SELECT invoice_amount, invoice_date, invo
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -19,6 +19,9 @@ $quotes_sql = mysqli_query($mysqli, "SELECT quote_amount, quote_date, quote_id,
<div class="col-md-10">
<?php if (mysqli_num_rows($quotes_sql) == 0) { ?>
<?= portalEmptyState('There are no quotes on this account yet.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -80,6 +83,7 @@ $quotes_sql = mysqli_query($mysqli, "SELECT quote_amount, quote_date, quote_id,
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -35,6 +35,9 @@ $payment_provider_threshold = floatval($row['payment_provider_threshold']);
<div class="col-md-10">
<?php if (mysqli_num_rows($recurring_invoices_sql) == 0) { ?>
<?= portalEmptyState('There are no recurring invoices set up on this account.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -105,6 +108,7 @@ $payment_provider_threshold = floatval($row['payment_provider_threshold']);
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -60,9 +60,7 @@ $statement_total = 0;
<?php if ($statement_count == 0) { ?>
<div class="alert alert-success">
<i class="fa fa-fw fa-check me-2"></i>There is nothing outstanding on this account.
</div>
<?= portalEmptyState('There is nothing outstanding on this account.', 'fa-check', 'success') ?>
<?php } else { ?>

View File

@@ -41,6 +41,9 @@ $all_tickets = mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_nu
</form>
</div>
</div>
<?php if (mysqli_num_rows($all_tickets) == 0) { ?>
<?= portalEmptyState('There are no tickets for this account.') ?>
<?php } else { ?>
<table class="table">
<thead>
<tr>
@@ -71,6 +74,7 @@ $all_tickets = mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_nu
?>
</tbody>
</table>
<?php } ?>
</div>
<?php

View File

@@ -47,6 +47,9 @@ $total_tickets = intval($row['total_tickets']);
<div class="col-md-10">
<?php if (mysqli_num_rows($contact_tickets) == 0) { ?>
<?= portalEmptyState($status === '%' ? 'You have no tickets.' : 'You have no ' . strtolower($status) . ' tickets.') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -80,6 +83,7 @@ $total_tickets = intval($row['total_tickets']);
?>
</tbody>
</table>
<?php } ?>
</div>

View File

@@ -80,6 +80,9 @@ $balance = $invoice_amounts - $amount_paid;
<div class="col-md-10">
<?php if (mysqli_num_rows($invoices_sql) == 0) { ?>
<?= portalEmptyState('There is nothing unpaid on this account.', 'fa-check', 'success') ?>
<?php } else { ?>
<table class="table table-bordered border border-dark">
<thead class="table-dark">
<tr>
@@ -197,6 +200,7 @@ $balance = $invoice_amounts - $amount_paid;
</tbody>
</table>
<?php } ?>
</div>