From e72f4914ec908eb1af63129346d32d3cbd45b4e0 Mon Sep 17 00:00:00 2001
From: Iain Patterson
Date: Sun, 16 Jun 2013 07:49:34 -0400
Subject: [PATCH] Extend contact search to address.
Find contacts whose address matches the search string as well as those
whose name matches.
---
lib/contact.php | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lib/contact.php b/lib/contact.php
index 25aab58..56327de 100644
--- a/lib/contact.php
+++ b/lib/contact.php
@@ -85,6 +85,23 @@
}
else echo "none";
echo "
\n";
+
+ $address_ids = array();
+ $q = new AddressQuery;
+ $addresses = $q->filterByLine("%$search%")->find();
+ foreach ($addresses as $address) $address_ids[] = $address->getId();
+ $q = new AddressQuery;
+ $addresses = $q->filterByPostcode("%$search%")->find();
+ foreach ($addresses as $address) $address_ids[] = $address->getId();
+
+ $q = new ContactQuery;
+ $contacts = $q->filterByAddressId($address_ids)->find();
+ echo "Contacts in address '" . htmlspecialchars($search) . "':";
+ if (count($contacts)) {
+ foreach ($contacts as $contact) show_contact_summary($contact);
+ }
+ else echo "none";
+ echo "
\n";
}
function show_city_contacts($offset, $per_page, $city_name, $city_id = null) {
--
2.20.1