From 0b9f10985d762587f323f5c780132a3219759def Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 22 Mar 2025 13:50:03 -0400 Subject: [PATCH] Add Client Select Filters the remaining entities also when creating an entity auto select the client based off the the client selected in the client dropdown filter --- certificates.php | 39 ++++++++++++++++-- credentials.php | 50 +++++++++++------------ domains.php | 41 +++++++++++++++++-- locations.php | 40 +++++++++++++++++-- modals/asset_add_modal.php | 2 +- modals/certificate_add_modal.php | 2 +- modals/contact_add_modal.php | 2 +- modals/credential_add_modal.php | 2 +- modals/domain_add_modal.php | 2 +- modals/location_add_modal.php | 2 +- modals/network_add_modal.php | 6 +-- modals/service_add_modal.php | 2 +- modals/software_add_modal.php | 2 +- networks.php | 68 ++++++++++++++++++++++++++++++-- services.php | 38 +++++++++++++++++- software.php | 38 +++++++++++++++++- 16 files changed, 284 insertions(+), 52 deletions(-) diff --git a/certificates.php b/certificates.php index 4755ee93..697a2f41 100644 --- a/certificates.php +++ b/certificates.php @@ -18,8 +18,17 @@ if (isset($_GET['client_id'])) { // Perms enforceUserPermission('module_support'); -//Rebuild URL -$url_query_strings_sort = http_build_query($get_copy); +if (!$client_url) { + // Client Filter + if (isset($_GET['client']) & !empty($_GET['client'])) { + $client_query = 'AND (certificate_client_id = ' . intval($_GET['client']) . ')'; + $client = intval($_GET['client']); + } else { + // Default - any + $client_query = ''; + $client = ''; + } +} $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates LEFT JOIN clients ON client_id = certificate_client_id @@ -67,7 +76,31 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); -
+ +
+ +
+
+ +
+
+ + +
+ +
+
+ +
+ +
+
+
@@ -169,31 +194,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
-
- -
- -
-
-
-
-
+ +
+ +
+
+ +
+
+ + +
"> @@ -261,7 +294,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- +
+ +
+ +
+
+ +
+
+ + +
"> diff --git a/modals/asset_add_modal.php b/modals/asset_add_modal.php index 106afeb4..9746f59a 100644 --- a/modals/asset_add_modal.php +++ b/modals/asset_add_modal.php @@ -58,7 +58,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/certificate_add_modal.php b/modals/certificate_add_modal.php index 24bb2149..14bbcdfd 100644 --- a/modals/certificate_add_modal.php +++ b/modals/certificate_add_modal.php @@ -46,7 +46,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/contact_add_modal.php b/modals/contact_add_modal.php index d13be9f7..6ce2b8cf 100644 --- a/modals/contact_add_modal.php +++ b/modals/contact_add_modal.php @@ -49,7 +49,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/credential_add_modal.php b/modals/credential_add_modal.php index 85d83527..ce4274d5 100644 --- a/modals/credential_add_modal.php +++ b/modals/credential_add_modal.php @@ -49,7 +49,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/domain_add_modal.php b/modals/domain_add_modal.php index a420f9bd..ed5057a6 100644 --- a/modals/domain_add_modal.php +++ b/modals/domain_add_modal.php @@ -44,7 +44,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/location_add_modal.php b/modals/location_add_modal.php index 025f605d..fa770c52 100644 --- a/modals/location_add_modal.php +++ b/modals/location_add_modal.php @@ -51,7 +51,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/modals/network_add_modal.php b/modals/network_add_modal.php index d23f8609..12505a8d 100644 --- a/modals/network_add_modal.php +++ b/modals/network_add_modal.php @@ -49,7 +49,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + @@ -86,7 +86,7 @@
diff --git a/modals/software_add_modal.php b/modals/software_add_modal.php index 5be6bd11..ca46241f 100644 --- a/modals/software_add_modal.php +++ b/modals/software_add_modal.php @@ -54,7 +54,7 @@ while ($row = mysqli_fetch_array($sql)) { $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); ?> - + diff --git a/networks.php b/networks.php index 03c18a69..4ccd7c62 100644 --- a/networks.php +++ b/networks.php @@ -18,8 +18,27 @@ if (isset($_GET['client_id'])) { // Perms enforceUserPermission('module_support'); -//Rebuild URL -$url_query_strings_sb = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order))); +if (!$client_url) { + // Client Filter + if (isset($_GET['client']) & !empty($_GET['client'])) { + $client_query = 'AND (network_client_id = ' . intval($_GET['client']) . ')'; + $client = intval($_GET['client']); + } else { + // Default - any + $client_query = ''; + $client = ''; + } +} + +if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) { + // Location Filter + $location_query = 'AND (network_location_id = ' . intval($_GET['location']) . ')'; + $location_filter = intval($_GET['location']); +} else { + // Default - any + $location_query = ''; + $location_filter = ''; +} $sql = mysqli_query( $mysqli, @@ -29,6 +48,7 @@ $sql = mysqli_query( WHERE network_$archive_query AND (network_name LIKE '%$q%' OR network_description LIKE '%$q%' OR network_vlan LIKE '%$q%' OR network LIKE '%$q%' OR network_gateway LIKE '%$q%' OR network_subnet LIKE '%$q%' OR network_primary_dns LIKE '%$q%' OR network_secondary_dns LIKE '%$q%' OR network_dhcp_range LIKE '%$q%' OR location_name LIKE '%$q%' OR client_name LIKE '%$q%') $access_permission_query + $location_query $client_query ORDER BY $sort $order LIMIT $record_from, $record_to" ); @@ -71,7 +91,49 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
-
+ +
+ +
+
+ +
+
+ + +
diff --git a/software.php b/software.php index 8e3f63b2..f16c7fb8 100644 --- a/software.php +++ b/software.php @@ -18,6 +18,18 @@ if (isset($_GET['client_id'])) { // Perms enforceUserPermission('module_support'); +if (!$client_url) { + // Client Filter + if (isset($_GET['client']) & !empty($_GET['client'])) { + $client_query = 'AND (software_client_id = ' . intval($_GET['client']) . ')'; + $client = intval($_GET['client']); + } else { + // Default - any + $client_query = ''; + $client = ''; + } +} + $sql = mysqli_query( $mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM software @@ -74,7 +86,31 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-