From: Iain Patterson Date: Mon, 13 May 2013 10:12:27 +0000 (-0400) Subject: Filter area and city searches. X-Git-Tag: 2013-05-13~4 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=b967de0fef7828e7cf314104ddd147394efb0060;p=readifood.git Filter area and city searches. Only show areas or city in dropdown for searches if there are contacts, hubs etc in that area or city. --- diff --git a/lib/area.php b/lib/area.php index 51f57d3..2aa5e2d 100644 --- a/lib/area.php +++ b/lib/area.php @@ -53,10 +53,17 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_areas($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + form("noprint standout"); echo "

Show areas in\n"; echo "\n"; diff --git a/lib/contact.php b/lib/contact.php index c457f4b..b33c97a 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -129,9 +129,16 @@ return; } + $candidates = array(); + foreach ($areas as $area) { + if (! count(get_area_contacts($area->getId()))) continue; + $candidates[] = $area; + } + if (! count($candidates)) return; + echo "

Show contacts in area\n"; echo "\n"; @@ -147,9 +154,16 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_contacts($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + echo "

Show contacts in city\n"; echo "\n"; diff --git a/lib/donation.php b/lib/donation.php index e9c75da..be3710c 100644 --- a/lib/donation.php +++ b/lib/donation.php @@ -127,9 +127,17 @@ return; } + form("noprint standout"); + $candidates = array(); + foreach ($areas as $area) { + if (! count(get_area_hubs($area->getId()))) continue; + $candidates[] = $area; + } + if (! count($candidates)) return; + echo "

Show donations in area\n"; echo "\n"; @@ -145,9 +153,16 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_hubs($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + echo "

Show donations in city\n"; echo "\n"; diff --git a/lib/hub.php b/lib/hub.php index 79051f8..4e34c17 100644 --- a/lib/hub.php +++ b/lib/hub.php @@ -108,9 +108,16 @@ return; } + $candidates = array(); + foreach ($areas as $area) { + if (! count(get_area_hubs($area->getId()))) continue; + $candidates[] = $area; + } + if (! count($candidates)) return; + echo "

Show hubs in area\n"; echo "\n"; @@ -126,9 +133,16 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_hubs($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + echo "

Show hubs in city\n"; echo "\n"; diff --git a/lib/order.php b/lib/order.php index 2eae9e0..d48f214 100644 --- a/lib/order.php +++ b/lib/order.php @@ -167,9 +167,16 @@ return; } + $candidates = array(); + foreach ($areas as $area) { + if (! count(get_area_contacts($area->getId()))) continue; + $candidates[] = $area; + } + if (! count($candidates)) return; + echo "

Show orders in area\n"; echo "\n"; @@ -185,9 +192,16 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_contacts($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + echo "

Show orders in city\n"; echo "\n";