From 07ed791e68053265ea75482bf657b49be8d2ea5d Mon Sep 17 00:00:00 2001 From: Adrian Fretwell Date: Wed, 22 May 2019 09:53:12 +0100 Subject: [PATCH] Update contacts.php default sort order Added a default sort order that can be set by the session, if unset defaults to last_mod_date descending. Added a secondary sort on contact_organization ascending. --- app/contacts/contacts.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/contacts/contacts.php b/app/contacts/contacts.php index a4ad2c5ef0..010599defb 100644 --- a/app/contacts/contacts.php +++ b/app/contacts/contacts.php @@ -178,12 +178,15 @@ $offset = $rows_per_page * $page; //get the list + $contact_default_sort_col = ($_SESSION['contacts']['default_sort_column']['text'] != '') ? $_SESSION['contacts']['default_sort_column']['text'] : "last_mod_date"; + $contact_default_sort_ord = ($_SESSION['contacts']['default_sort_order']['text'] != '') ? $_SESSION['contacts']['default_sort_order']['text'] : "desc"; + $sql = str_replace('count(*) as num_rows', '*, (select a.contact_attachment_uuid from v_contact_attachments as a where a.contact_uuid = c.contact_uuid and a.attachment_primary = 1) as contact_attachment_uuid', $sql); if (strlen($order_by) > 0) { - $sql .= "order by ".$order_by." ".$order." "; + $sql .= "order by ".$order_by." ".$order.", contact_organization asc "; } else { - $sql .= "order by last_mod_date desc "; + $sql .= "order by ".$contact_default_sort_col." ".$contact_default_sort_ord." "; if ($db_type == "pgsql") { $sql .= "nulls last "; }