From cab10aa324c026433014fb6d4b651d65fc1cc296 Mon Sep 17 00:00:00 2001 From: inghamn Date: Fri, 18 Dec 2009 15:01:46 +0000 Subject: [PATCH] Added Deed searching git-svn-id: https://rosehill.googlecode.com/svn/branches/php@4 100bd78a-fc82-11de-b5bc-ffd2847a4b57 --- blocks/html/deeds/deedList.inc | 1 + blocks/html/deeds/findForm.inc | 36 +++++++++++++++++----------------- classes/DeedList.php | 27 ++++++++++++++++++++++++- html/deeds/home.php | 12 +++++++++++- 4 files changed, 56 insertions(+), 20 deletions(-) diff --git a/blocks/html/deeds/deedList.inc b/blocks/html/deeds/deedList.inc index fba6417..0216b87 100644 --- a/blocks/html/deeds/deedList.inc +++ b/blocks/html/deeds/deedList.inc @@ -3,6 +3,7 @@ * @copyright 2009 City of Bloomington, Indiana * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt * @author Cliff Ingham + * @param DeedList $this->deedList */ ?>
diff --git a/blocks/html/deeds/findForm.inc b/blocks/html/deeds/findForm.inc index f26a170..8629806 100644 --- a/blocks/html/deeds/findForm.inc +++ b/blocks/html/deeds/findForm.inc @@ -9,27 +9,21 @@
Search Deeds - - - - - - - - - - - - - - - + @@ -41,6 +35,9 @@ $list->find(); foreach ($list as $cemetery) { $name = View::escape($cemetery->getName()); + $selected = (isset($_GET['cemetery']) && $_GET['cemetery']==$name) + ? 'selected="selected"' + : ''; echo ""; } ?> @@ -50,5 +47,8 @@
+ + +
-
-
-
+
+ + +
+
\ No newline at end of file diff --git a/classes/DeedList.php b/classes/DeedList.php index 984d2a3..430d767 100644 --- a/classes/DeedList.php +++ b/classes/DeedList.php @@ -18,6 +18,13 @@ */ class DeedList extends ZendDbResultIterator { + private $columns = array( + 'id','section','lot','lot2','cemetery_id', + 'lastname1','firstname1','middleInitial1', + 'lastname2','firstname2','middleInitial2', + 'issueDate','notes' + ); + /** * Creates a basic select statement for the collection. * @@ -52,10 +59,28 @@ class DeedList extends ZendDbResultIterator // Finding on fields from the deed table is handled here if (count($fields)) { foreach ($fields as $key=>$value) { - $this->select->where("$key=?",$value); + if ($value) { + if (in_array($key,$this->columns)) { + $this->select->where("$key=?",$value); + } + } + } + + if (isset($fields['lastname']) && $fields['lastname']) { + $this->select->where("(lastname1 like ? or lastname2 like ?)", + array("$fields[lastname]%")); + } + if (isset($fields['firstname']) && $fields['firstname']) { + $this->select->where("(firstname1 like ? or firstname2 like ?)", + array("$fields[firstname]%")); + } + if (isset($fields['middleInitial']) && $fields['middleInitial']) { + $this->select->where("(middleInitial1 like ? or middleInitial2 like ?)", + array("$fields[middleInitial]%")); } } + // Finding on fields from other tables requires joining those tables. // You can handle fields from other tables by adding the joins here // If you add more joins you probably want to make sure that the diff --git a/html/deeds/home.php b/html/deeds/home.php index 5fe1e9b..c9facea 100644 --- a/html/deeds/home.php +++ b/html/deeds/home.php @@ -7,8 +7,18 @@ $currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1; $deedList = new DeedList(null,20,$currentPage); -$deedList->find(); + + +$knownFields = array('section','lot','cemetery_id','firstname','lastname','middleInitial'); +if (count(array_intersect(array_keys($_GET),$knownFields))) { + $deedList->find($_GET); +} +else { + $deedList->find(); +} + $template = new Template(); +$template->blocks[] = new Block('deeds/findForm.inc'); $template->blocks[] = new Block('deeds/deedList.inc',array('deedList'=>$deedList)); echo $template->render(); \ No newline at end of file