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