Added Deed searching

git-svn-id: https://rosehill.googlecode.com/svn/branches/php@4 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
inghamn 2009-12-18 15:01:46 +00:00
parent eb3c026375
commit cab10aa324
4 changed files with 56 additions and 20 deletions

View File

@ -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 <inghamn@bloomington.in.gov>
* @param DeedList $this->deedList
*/
?>
<div class="interfaceBox">

View File

@ -9,27 +9,21 @@
<fieldset><legend>Search Deeds</legend>
<table>
<tr><td><label for="section">Section</label></td>
<td><input name="section" id="section" size="3" />
<td><input name="section" id="section" size="3"
value="<?php echo isset($_GET['section']) ? View::escape($_GET['section']) : ''; ?>" />
<label for="lot">Lot</label>
<input name="lot" id="lot" size="3"
value="<?php echo isset($_GET['lot']) ? View::escape($_GET['lot']) : ''; ?>" />
</td>
</tr>
<tr><td><label for="lot">Lot</label></td>
<td><input name="lot" id="lot" size="3" />
</td>
</tr>
<tr><td><label for="lastname">Lastname</label></td>
<td><input name="lastname" id="lastname" />
</td>
</tr>
<tr><td><label for="firstname">Firstname</label></td>
<td><input name="firstname" id="firstname" />
</td>
</tr>
<tr><td><label for="middleInitial">Middle Initial</label></td>
<td><input name="middleInitial" id="middleInitial" />
<tr><td><label for="firstname">Owner</label></td>
<td><label for="firstname">Firstname</label>
<input name="firstname" id="firstname"
value="<?php echo isset($_GET['firstname']) ? View::escape($_GET['firstname']) : ''; ?>" />
<label for="lastname">Lastname</label>
<input name="lastname" id="lastname"
value="<?php echo isset($_GET['lastname']) ? View::escape($_GET['lastname']) : ''; ?>" />
</td>
</tr>
@ -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 "<option value=\"{$cemetery->getId()}\">$name</option>";
}
?>
@ -50,5 +47,8 @@
</table>
<button type="submit" class="search">Search</button>
<button type="button" onclick="document.location.href='<?php echo BASE_URL; ?>/deeds';">
Clear
</button>
</fieldset>
</form>

View File

@ -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,9 +59,27 @@ class DeedList extends ZendDbResultIterator
// Finding on fields from the deed table is handled here
if (count($fields)) {
foreach ($fields as $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

View File

@ -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();