From 35055489e5c5626c7868b830220d6821e26da07b Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 26 Sep 2023 15:24:31 -0400 Subject: [PATCH] Added Show Archived Button to contacts, setup logic to work in other List views as well --- client_contacts.php | 11 ++++++++++- pagination_head.php | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client_contacts.php b/client_contacts.php index a083081e..c894fbe7 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -11,7 +11,7 @@ $url_query_strings_sort = http_build_query($get_copy); $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM contacts LEFT JOIN locations ON location_id = contact_location_id - WHERE contact_archived_at IS NULL + WHERE contact_$archive_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%') AND contact_client_id = $client_id ORDER BY contact_primary DESC, contact_important DESC, $sort $order LIMIT $record_from, $record_to" @@ -47,6 +47,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
+
@@ -59,6 +60,14 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
diff --git a/pagination_head.php b/pagination_head.php index a0258d0b..58146f8f 100644 --- a/pagination_head.php +++ b/pagination_head.php @@ -98,3 +98,17 @@ if ($_GET['canned_date'] == "custom" && !empty($_GET['dtf'])) { $dtf = "NULL"; $dtt = date('Y-m-d'); } + + +// Archived + +$show_archived = 0; +if (isset($_GET['show_archived'])) { + $show_archived = intval($_GET['show_archived']); +} + +if($show_archived == 1){ + $archive_query = "archived_at IS NOT NULL"; +} else { + $archive_query = "archived_at IS NULL"; +} \ No newline at end of file