Added Deed searching
git-svn-id: https://rosehill.googlecode.com/svn/branches/php@4 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
parent
eb3c026375
commit
cab10aa324
|
@ -3,6 +3,7 @@
|
||||||
* @copyright 2009 City of Bloomington, Indiana
|
* @copyright 2009 City of Bloomington, Indiana
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
||||||
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
||||||
|
* @param DeedList $this->deedList
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="interfaceBox">
|
<div class="interfaceBox">
|
||||||
|
|
|
@ -9,27 +9,21 @@
|
||||||
<fieldset><legend>Search Deeds</legend>
|
<fieldset><legend>Search Deeds</legend>
|
||||||
<table>
|
<table>
|
||||||
<tr><td><label for="section">Section</label></td>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr><td><label for="lot">Lot</label></td>
|
<tr><td><label for="firstname">Owner</label></td>
|
||||||
<td><input name="lot" id="lot" size="3" />
|
<td><label for="firstname">Firstname</label>
|
||||||
</td>
|
<input name="firstname" id="firstname"
|
||||||
</tr>
|
value="<?php echo isset($_GET['firstname']) ? View::escape($_GET['firstname']) : ''; ?>" />
|
||||||
|
<label for="lastname">Lastname</label>
|
||||||
<tr><td><label for="lastname">Lastname</label></td>
|
<input name="lastname" id="lastname"
|
||||||
<td><input name="lastname" id="lastname" />
|
value="<?php echo isset($_GET['lastname']) ? View::escape($_GET['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" />
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -41,6 +35,9 @@
|
||||||
$list->find();
|
$list->find();
|
||||||
foreach ($list as $cemetery) {
|
foreach ($list as $cemetery) {
|
||||||
$name = View::escape($cemetery->getName());
|
$name = View::escape($cemetery->getName());
|
||||||
|
$selected = (isset($_GET['cemetery']) && $_GET['cemetery']==$name)
|
||||||
|
? 'selected="selected"'
|
||||||
|
: '';
|
||||||
echo "<option value=\"{$cemetery->getId()}\">$name</option>";
|
echo "<option value=\"{$cemetery->getId()}\">$name</option>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -50,5 +47,8 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<button type="submit" class="search">Search</button>
|
<button type="submit" class="search">Search</button>
|
||||||
|
<button type="button" onclick="document.location.href='<?php echo BASE_URL; ?>/deeds';">
|
||||||
|
Clear
|
||||||
|
</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
|
@ -18,6 +18,13 @@
|
||||||
*/
|
*/
|
||||||
class DeedList extends ZendDbResultIterator
|
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.
|
* 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
|
// Finding on fields from the deed table is handled here
|
||||||
if (count($fields)) {
|
if (count($fields)) {
|
||||||
foreach ($fields as $key=>$value) {
|
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.
|
// Finding on fields from other tables requires joining those tables.
|
||||||
// You can handle fields from other tables by adding the joins here
|
// 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
|
// If you add more joins you probably want to make sure that the
|
||||||
|
|
|
@ -7,8 +7,18 @@
|
||||||
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||||
|
|
||||||
$deedList = new DeedList(null,20,$currentPage);
|
$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 = new Template();
|
||||||
|
$template->blocks[] = new Block('deeds/findForm.inc');
|
||||||
$template->blocks[] = new Block('deeds/deedList.inc',array('deedList'=>$deedList));
|
$template->blocks[] = new Block('deeds/deedList.inc',array('deedList'=>$deedList));
|
||||||
echo $template->render();
|
echo $template->render();
|
Loading…
Reference in New Issue