From: Iain Patterson
Date: Sun, 16 Jun 2013 11:49:34 +0000 (-0400)
Subject: Extend contact search to address.
X-Git-Tag: 2013-06-25~4
X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=e72f4914ec908eb1af63129346d32d3cbd45b4e0;p=readifood.git
Extend contact search to address.
Find contacts whose address matches the search string as well as those
whose name matches.
---
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) {