From 19b2b08eaca07e4538e4500fdaca638bff455f26 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 22 Mar 2025 15:49:35 -0400 Subject: [PATCH] Update locations filter to still include the a location that is not assigned to an entity if present in the url this fixes the issue where for example in client contact you select a location to filter only 1 contact is shown you goto edit the contacts location then submit it pushes you back with no results and all locations is present but in the uri the old location is still present --- assets.php | 4 ++-- contacts.php | 4 ++-- networks.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets.php b/assets.php index 4684cf0d..66cc5a59 100644 --- a/assets.php +++ b/assets.php @@ -53,7 +53,7 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) { } else { // Default - any $location_query = ''; - $location_filter = ''; + $location_filter = 0; } //Get Asset Counts @@ -216,7 +216,7 @@ if (mysqli_num_rows($os_sql) > 0) { LEFT JOIN assets ON asset_location_id = location_id WHERE location_client_id = $client_id AND location_archived_at IS NULL - AND asset_location_id != 0 + AND (asset_location_id != 0 OR location_id = $location_filter) ORDER BY location_name ASC "); while ($row = mysqli_fetch_array($sql_locations_filter)) { diff --git a/contacts.php b/contacts.php index 80cc817b..a16851cf 100644 --- a/contacts.php +++ b/contacts.php @@ -50,7 +50,7 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) { } else { // Default - any $location_query = ''; - $location_filter = ''; + $location_filter = 0; } $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS contacts.*, clients.*, locations.*, users.*, GROUP_CONCAT(tags.tag_name) FROM contacts @@ -152,7 +152,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); LEFT JOIN contacts ON contact_location_id = location_id WHERE location_client_id = $client_id AND location_archived_at IS NULL - AND contact_location_id != 0 + AND (contact_location_id != 0 OR location_id = $location_filter) ORDER BY location_name ASC "); while ($row = mysqli_fetch_array($sql_locations_filter)) { diff --git a/networks.php b/networks.php index 4b128f50..221c1b0c 100644 --- a/networks.php +++ b/networks.php @@ -37,7 +37,7 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) { } else { // Default - any $location_query = ''; - $location_filter = ''; + $location_filter = 0; } $sql = mysqli_query( @@ -104,7 +104,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); LEFT JOIN networks ON network_location_id = location_id WHERE location_client_id = $client_id AND location_archived_at IS NULL - AND network_location_id != 0 + AND (network_location_id != 0 OR location_id = $location_filter) ORDER BY location_name ASC "); while ($row = mysqli_fetch_array($sql_locations_filter)) {