From 02445811fa887eb74c51b2c3cc503b6bcee4bcd9 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 7 Jun 2024 20:40:35 -0400 Subject: [PATCH] Added locaiton drop down filter to contacts --- client_contacts.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/client_contacts.php b/client_contacts.php index 727cdc0c..cd17c53b 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -22,6 +22,16 @@ if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) { $tag_query = ''; } +// Location Filter +if (isset($_GET['location']) & !empty($_GET['location'])) { + $location_query = 'AND (contact_location_id = ' . intval($_GET['location']) . ')'; + $location = intval($_GET['location']); +} else { + // Default - any + $location_query = ''; + $location = ''; +} + //Rebuild URL $url_query_strings_sort = http_build_query($get_copy); @@ -33,6 +43,7 @@ $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS contacts.*, locations.* $tag_query AND (contact_name LIKE '%$q%' OR contact_title LIKE '%$q%' OR location_name LIKE '%$q%' OR contact_email LIKE '%$q%' OR contact_department LIKE '%$q%' OR contact_phone LIKE '%$phone_query%' OR contact_extension LIKE '%$q%' OR contact_mobile LIKE '%$phone_query%' OR tag_name LIKE '%$q%') AND contact_client_id = $client_id + $location_query GROUP BY contact_id ORDER BY contact_primary DESC, contact_important DESC, $sort $order LIMIT $record_from, $record_to" ); @@ -95,7 +106,27 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); -
+
+
+ +
+
+ +