From e637da615ee224c4a390d69c23909654b06cbd6a Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 26 Aug 2026 15:12:16 -0400 Subject: [PATCH] Added More Meaningful nothing matches filters or no records exist --- admin/saved_payment_methods.php | 2 +- agent/ticket_list.php | 2 +- includes/filter_footer.php | 14 +++--- includes/inc_empty_state.php | 76 +++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 includes/inc_empty_state.php diff --git a/admin/saved_payment_methods.php b/admin/saved_payment_methods.php index ed94db509..ebd9c50c0 100644 --- a/admin/saved_payment_methods.php +++ b/admin/saved_payment_methods.php @@ -63,7 +63,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- "> + ">
diff --git a/agent/ticket_list.php b/agent/ticket_list.php index 63eaeb1e1..d7a780121 100644 --- a/agent/ticket_list.php +++ b/agent/ticket_list.php @@ -142,7 +142,7 @@ if ($tickets) {
- + "> at zero rows. Handled here rather than in + * each of the 48 listing pages because this file is the one thing they all + * include, and it already has $num_rows. + */ +require __DIR__ . '/inc_empty_state.php'; + $total_found_rows = $num_rows[0]; $total_pages = ceil($total_found_rows / $user_config_records_per_page); @@ -119,9 +127,3 @@ if ($total_found_rows > 5) {

No Results

"; -} - -?> diff --git a/includes/inc_empty_state.php b/includes/inc_empty_state.php new file mode 100644 index 000000000..78d60843c --- /dev/null +++ b/includes/inc_empty_state.php @@ -0,0 +1,76 @@ + when $num_rows[0] is 0, so an empty + * result was rendering as a card with a filter bar and nothing under it. This + * fills that gap and, more usefully, distinguishes the two reasons a list can + * be empty: + * + * - nothing has been created yet -> say so plainly + * - the filters exclude everything -> say THAT, and offer a way out + * + * The second is the one worth getting right: a filtered-to-nothing list looks + * identical to an empty install, and the fix (clear the filters) is invisible. + * + * $page_title is set from the script name by includes/page_title.php, which + * every listing page pulls in via inc_all / inc_all_client / inc_all_admin, + * so the label is already correct per page ("Clients", "Recurring Invoices") + * with nothing to maintain. + */ + +if (!isset($num_rows) || intval($num_rows[0]) > 0) { + return; +} + +/* + * Which GET keys are page furniture rather than a filter the user chose. + * canned_date is here because filter_header.php WRITES it on every request + * when absent, so its presence says nothing; the dates it resolves to are + * what count, and those arrive as dtf/dtt. + * + * client_id is scope, not a filter - 33 of these pages run inside a client via + * inc_all_client.php. Counting it would tell someone their empty client has + * "no invoices matching the current filters" and offer a Clear filters link + * that quietly drops them out of the client entirely. + */ +$empty_state_ignored_params = array('page', 'sort', 'order', 'canned_date', 'show_column', 'client_id'); + +$empty_state_filtered = false; +foreach ($_GET as $empty_state_key => $empty_state_value) { + if (in_array($empty_state_key, $empty_state_ignored_params, true)) { + continue; + } + if (is_array($empty_state_value) ? count($empty_state_value) : strlen(trim((string)$empty_state_value))) { + $empty_state_filtered = true; + break; + } +} + +$empty_state_thing = strtolower($page_title ?? 'records'); + +?> + +
+ + + +
No match the current filters.
+

Try widening the date range or clearing the search.

+ + + Clear filters + + + + + +

No yet.

+
Anything you add will show up here.
+ + +
diff --git a/includes/filter_footer.php b/includes/filter_footer.php index a97f84671..32dd6cead 100644 --- a/includes/filter_footer.php +++ b/includes/filter_footer.php @@ -7,6 +7,14 @@ * Relies upon the $num_rows variable being set correctly */ +/* + * Nothing to paginate means nothing rendered below the filter bar at all - the + * tables already hide their