Added cemeteries and deeds
git-svn-id: https://rosehill.googlecode.com/svn/branches/php@3 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
parent
eb914b54f9
commit
eb3c026375
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
?>
|
||||
<h1>Add Cemetery</h1>
|
||||
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
|
||||
<fieldset><legend>Cemetery Info</legend>
|
||||
<table>
|
||||
|
||||
<tr><td><label for="cemetery-name" class="required">Name</label></td>
|
||||
<td><input name="cemetery[name]" id="cemetery-name" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<button type="submit" class="submit">Submit</button>
|
||||
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/cemeterys';">
|
||||
Cancel
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
?>
|
||||
<div class="interfaceBox">
|
||||
<h1>
|
||||
<?php
|
||||
if (userIsAllowed('Cemeteries')) {
|
||||
echo "
|
||||
<button type=\"button\" class=\"add\" onclick=\"document.location.href='".BASE_URL."/cemeteries/addCemetery.php';\">
|
||||
Add
|
||||
</button>
|
||||
";
|
||||
}
|
||||
?>
|
||||
Cemeteries
|
||||
</h1>
|
||||
<ul><?php
|
||||
foreach ($this->cemeteryList as $cemetery) {
|
||||
$editButton = '';
|
||||
if (userIsAllowed('Cemeteries')) {
|
||||
$url = new URL(BASE_URL.'/cemeteries/updateCemetery.php');
|
||||
$url->cemetery_id = $cemetery->getId();
|
||||
$editButton = "
|
||||
<button type=\"button\" class=\"edit\" onclick=\"document.location.href='$url';\">
|
||||
Edit
|
||||
</button>
|
||||
";
|
||||
}
|
||||
$name = View::escape($cemetery->getName());
|
||||
echo "<li>$editButton $name</li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* @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 Cemetery $this->cemetery
|
||||
*/
|
||||
?>
|
||||
<h1>Update Cemetery</h1>
|
||||
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
|
||||
<fieldset><legend>Cemetery Info</legend>
|
||||
<input name="cemetery_id" type="hidden" value="<?php echo $this->cemetery->getId(); ?>" />
|
||||
<table>
|
||||
|
||||
<tr><td><label for="cemetery-name" class="required">Name</label></td>
|
||||
<td><input name="cemetery[name]" id="cemetery-name"
|
||||
value="<?php echo View::escape($this->cemetery->getName()); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<button type="submit" class="submit">Submit</button>
|
||||
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/cemeterys';">
|
||||
Cancel
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -10,84 +10,60 @@
|
|||
<fieldset><legend>Deed Info</legend>
|
||||
<table>
|
||||
|
||||
<tr><td><label for="deed-section">section</label></td>
|
||||
<td><input name="deed[section]" id="deed-section" />
|
||||
<tr><td><label for="deed-section">Section</label></td>
|
||||
<td><input name="deed[section]" id="deed-section" size="3" />
|
||||
<label for="deed-lot">Lot</label>
|
||||
<input name="deed[lot]" id="deed-lot" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lot">lot</label></td>
|
||||
<td><input name="deed[lot]" id="deed-lot" />
|
||||
|
||||
|
||||
<tr><td><label for="deed-firstname1">Owner 1</label></td>
|
||||
<td><label for="deed-firstname1">First</label>
|
||||
<input name="deed[firstname1]" id="deed-firstname1" />
|
||||
<label for="deed-middleInitial1">MI</label>
|
||||
<input name="deed[middleInitial1]" id="deed-middleInitial1" size="1" maxlength="1" />
|
||||
<label for="deed-lastname1">Last</label>
|
||||
<input name="deed[lastname1]" id="deed-lastname1" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lastname1">lastname1</label></td>
|
||||
<td><input name="deed[lastname1]" id="deed-lastname1" />
|
||||
|
||||
<tr><td><label for="deed-firstname2">Owner 2</label></td>
|
||||
<td><label for="deed-firstname2">First</label>
|
||||
<input name="deed[firstname2]" id="deed-firstname2" />
|
||||
<label for="deed-middleInitial2">MI</label>
|
||||
<input name="deed[middleInitial2]" id="deed-middleInitial2" size="1" maxlength="1" />
|
||||
<label for="deed-lastname2">Last</label>
|
||||
<input name="deed[lastname2]" id="deed-lastname2" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-firstname1">firstname1</label></td>
|
||||
<td><input name="deed[firstname1]" id="deed-firstname1" />
|
||||
</td>
|
||||
|
||||
<tr><td><label for="deed-issueDate">Date Issued</label></td>
|
||||
<td><input name="deed[issueDate]" size="10" /></td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-middleInitial1">middleInitial1</label></td>
|
||||
<td><input name="deed[middleInitial1]" id="deed-middleInitial1" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lastname2">lastname2</label></td>
|
||||
<td><input name="deed[lastname2]" id="deed-lastname2" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-firstname2">firstname2</label></td>
|
||||
<td><input name="deed[firstname2]" id="deed-firstname2" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-middleInitial2">middleInitial2</label></td>
|
||||
<td><input name="deed[middleInitial2]" id="deed-middleInitial2" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-issueDate-mon">issueDate</label></td>
|
||||
<td><select name="deed[issueDate][mon]" id="deed-issueDate-mon">
|
||||
|
||||
<tr><td><label for="deed-cemetery_id">Cemetery</label></td>
|
||||
<td><select name="deed[cemetery_id]" id="deed-cemetery_id">
|
||||
<option></option>
|
||||
<?php
|
||||
$now = getdate();
|
||||
for ($i=1; $i<=12; $i++) {
|
||||
$selected = ($i==$now['mon']) ? 'selected="selected"' : '';
|
||||
echo "<option $selected>$i</option>";
|
||||
$list = new CemeteryList();
|
||||
$list->find();
|
||||
foreach ($list as $cemetery) {
|
||||
$name = View::escape($cemetery->getName());
|
||||
echo "<option value=\"{$cemetery->getId()}\">$name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="deed[issueDate][mday]">
|
||||
<option></option>
|
||||
<?php
|
||||
for ($i=1; $i<=31; $i++) {
|
||||
$selected = ($i==$now['mday']) ? 'selected="selected"' : '';
|
||||
echo "<option $selected>$i</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input name="deed[issueDate][year]" id="deed-issueDate-year" size="4" maxlength="4" value="<?php echo $now['year']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-notes">notes</label></td>
|
||||
<td><textarea name="deed[notes]" id="deed-notes" rows="3" cols="60"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lot2">lot2</label></td>
|
||||
<td><input name="deed[lot2]" id="deed-lot2" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-whiteoak">whiteoak</label></td>
|
||||
<td><input name="deed[whiteoak]" id="deed-whiteoak" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<button type="submit" class="submit">Submit</button>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
$editButton = '';
|
||||
if (userIsAllowed('Deeds')) {
|
||||
$url = new URL(BASE_URL.'/deeds/updateDeed.php');
|
||||
$url->id = $deed->getId();
|
||||
$url->deed_id = $deed->getId();
|
||||
$editButton = "
|
||||
<button type=\"button\" class=\"edit\" onclick=\"document.location.href='$url';\">
|
||||
Edit
|
||||
|
@ -46,13 +46,25 @@
|
|||
$owner1 = View::escape($deed->getOwner(1));
|
||||
$owner2 = View::escape($deed->getOwner(2));
|
||||
$date = $deed->getIssueDate('n/j/Y');
|
||||
$cemetery = $deed->getCemetery() ? View::escape($deed->getCemetery()->getName()) : '';
|
||||
echo "
|
||||
<tr><td>$editButton</td>
|
||||
<td>{$deed->getSection()}, {$deed->getLot()}</td>
|
||||
<td>
|
||||
<td>$owner1</td>
|
||||
<td>$owner2</td>
|
||||
<td>$date</td>
|
||||
<td>$cemetery</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ($this->deedList->getPaginator()) {
|
||||
$pageNavigation = new Block('pageNavigation.inc',
|
||||
array('pages'=>$this->deedList->getPaginator()->getPages()));
|
||||
echo $pageNavigation->render('html');
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
?>
|
||||
<form method="get" action="<?php echo BASE_URL; ?>/deeds">
|
||||
<fieldset><legend>Search Deeds</legend>
|
||||
<table>
|
||||
<tr><td><label for="section">Section</label></td>
|
||||
<td><input name="section" id="section" size="3" />
|
||||
</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" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="cemetery_id">Cemetery</label></td>
|
||||
<td><select name="cemetery_id" id="cemetery_id">
|
||||
<option></option>
|
||||
<?php
|
||||
$list = new CemeteryList();
|
||||
$list->find();
|
||||
foreach ($list as $cemetery) {
|
||||
$name = View::escape($cemetery->getName());
|
||||
echo "<option value=\"{$cemetery->getId()}\">$name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button type="submit" class="search">Search</button>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -3,92 +3,80 @@
|
|||
* @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 Deed $this->deed
|
||||
*/
|
||||
?>
|
||||
<h1>Update Deed</h1>
|
||||
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
|
||||
<fieldset><legend>Deed Info</legend>
|
||||
<input name="id" type="hidden" value="<?php echo $this->deed->getId(); ?>" />
|
||||
<input name="deed_id" type="hidden" value="<?php echo $this->deed->getId(); ?>" />
|
||||
<table>
|
||||
|
||||
<tr><td><label for="deed-section">section</label></td>
|
||||
<td><input name="deed[section]" id="deed-section" value="<?php echo $this->deed->getSection(); ?>" />
|
||||
<tr><td><label for="deed-section">Section</label></td>
|
||||
<td><input name="deed[section]" id="deed-section" size="3"
|
||||
value="<?php echo View::escape($this->deed->getSection()); ?>" />
|
||||
<label for="deed-lot">Lot</label>
|
||||
<input name="deed[lot]" id="deed-lot" size="3"
|
||||
value="<?php echo View::escape($this->deed->getLot()); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lot">lot</label></td>
|
||||
<td><input name="deed[lot]" id="deed-lot" value="<?php echo $this->deed->getLot(); ?>" />
|
||||
|
||||
|
||||
<tr><td><label for="deed-firstname1">Owner 1</label></td>
|
||||
<td><label for="deed-firstname1">First</label>
|
||||
<input name="deed[firstname1]" id="deed-firstname1"
|
||||
value="<?php echo View::escape($this->deed->getFirstname1()); ?>" />
|
||||
<label for="deed-middleInitial1">MI</label>
|
||||
<input name="deed[middleInitial1]" id="deed-middleInitial1"
|
||||
size="1" maxlength="1"
|
||||
value="<?php echo View::escape($this->deed->getMiddleInitial1()); ?>" />
|
||||
<label for="deed-lastname1">Last</label>
|
||||
<input name="deed[lastname1]" id="deed-lastname1"
|
||||
value="<?php echo View::escape($this->deed->getLastname1()); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lastname1">lastname1</label></td>
|
||||
<td><input name="deed[lastname1]" id="deed-lastname1" value="<?php echo $this->deed->getLastname1(); ?>" />
|
||||
|
||||
<tr><td><label for="deed-firstname2">Owner 2</label></td>
|
||||
<td><label for="deed-firstname2">First</label>
|
||||
<input name="deed[firstname2]" id="deed-firstname2"
|
||||
value="<?php echo View::escape($this->deed->getFirstname2()); ?>" />
|
||||
<label for="deed-middleInitial2">MI</label>
|
||||
<input name="deed[middleInitial2]" id="deed-middleInitial2"
|
||||
size="1" maxlength="1"
|
||||
value="<?php echo View::escape($this->deed->getMiddleInitial2()); ?>" />
|
||||
<label for="deed-lastname2">Last</label>
|
||||
<input name="deed[lastname2]" id="deed-lastname2"
|
||||
value="<?php echo View::escape($this->deed->getLastname2()); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-firstname1">firstname1</label></td>
|
||||
<td><input name="deed[firstname1]" id="deed-firstname1" value="<?php echo $this->deed->getFirstname1(); ?>" />
|
||||
</td>
|
||||
|
||||
<tr><td><label for="deed-issueDate">Date Issued</label></td>
|
||||
<td><input name="deed[issueDate]" size="10" value="<?php echo $this->deed->getIssueDate('n/j/Y'); ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-middleInitial1">middleInitial1</label></td>
|
||||
<td><input name="deed[middleInitial1]" id="deed-middleInitial1" value="<?php echo $this->deed->getMiddleInitial1(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lastname2">lastname2</label></td>
|
||||
<td><input name="deed[lastname2]" id="deed-lastname2" value="<?php echo $this->deed->getLastname2(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-firstname2">firstname2</label></td>
|
||||
<td><input name="deed[firstname2]" id="deed-firstname2" value="<?php echo $this->deed->getFirstname2(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-middleInitial2">middleInitial2</label></td>
|
||||
<td><input name="deed[middleInitial2]" id="deed-middleInitial2" value="<?php echo $this->deed->getMiddleInitial2(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-issueDate-mon">issueDate</label></td>
|
||||
<td><select name="deed[issueDate][mon]" id="deed-issueDate-mon">
|
||||
|
||||
<tr><td><label for="deed-cemetery_id">Cemetery</label></td>
|
||||
<td><select name="deed[cemetery_id]" id="deed-cemetery_id">
|
||||
<option></option>
|
||||
<?php
|
||||
$issueDate = $this->deed->dateStringToArray($this->deed->getIssueDate());
|
||||
for ($i=1; $i<=12; $i++) {
|
||||
$selected = ($i==$issueDate['mon']) ? 'selected="selected"' : '';
|
||||
echo "<option $selected>$i</option>";
|
||||
$list = new CemeteryList();
|
||||
$list->find();
|
||||
foreach ($list as $cemetery) {
|
||||
$name = View::escape($cemetery->getName());
|
||||
$selected = $this->deed->getCemetery_id()==$cemetery->getId()
|
||||
? 'selected="selected"'
|
||||
: '';
|
||||
echo "<option value=\"{$cemetery->getId()}\">$name</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="deed[issueDate][mday]">
|
||||
<option></option>
|
||||
<?php
|
||||
for ($i=1; $i<=31; $i++) {
|
||||
$selected = ($i==$issueDate['mday']) ? 'selected="selected"' : '';
|
||||
echo "<option $selected>$i</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input name="deed[issueDate][year]" id="deed-issueDate-year" size="4" maxlength="4" value="<?php echo $issueDate['year']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-notes">notes</label></td>
|
||||
<td><textarea name="deed[notes]" id="deed-notes" rows="3" cols="60"><?php echo $this->deed->getNotes(); ?></textarea>
|
||||
<td><textarea name="deed[notes]" id="deed-notes" rows="3" cols="60"><?php echo View::escape($this->deed->getNotes()); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-lot2">lot2</label></td>
|
||||
<td><input name="deed[lot2]" id="deed-lot2" value="<?php echo $this->deed->getLot2(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><label for="deed-whiteoak">whiteoak</label></td>
|
||||
<td><input name="deed[whiteoak]" id="deed-whiteoak" value="<?php echo $this->deed->getWhiteoak(); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<button type="submit" class="submit">Submit</button>
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
class Cemetery
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Populates the object with data
|
||||
*
|
||||
* Passing in an associative array of data will populate this object without
|
||||
* hitting the database.
|
||||
*
|
||||
* Passing in a scalar will load the data from the database.
|
||||
* This will load all fields in the table as properties of this class.
|
||||
* You may want to replace this with, or add your own extra, custom loading
|
||||
*
|
||||
* @param int|array $id
|
||||
*/
|
||||
public function __construct($id=null)
|
||||
{
|
||||
if ($id) {
|
||||
if (is_array($id)) {
|
||||
$result = $id;
|
||||
}
|
||||
else {
|
||||
$zend_db = Database::getConnection();
|
||||
if (ctype_digit($id)) {
|
||||
$sql = 'select * from cemeteries where id=?';
|
||||
}
|
||||
else {
|
||||
$sql = 'select * from cemeteries where name=?';
|
||||
}
|
||||
$result = $zend_db->fetchRow($sql,array($id));
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
foreach ($result as $field=>$value) {
|
||||
if ($value) {
|
||||
$this->$field = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Exception('cemeteries/unknownCemetery');
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This is where the code goes to generate a new, empty instance.
|
||||
// Set any default values for properties that need it here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception if anything's wrong
|
||||
* @throws Exception $e
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
// Check for required fields here. Throw an exception if anything is missing.
|
||||
if (!$this->name) {
|
||||
throw new Exception('missingName');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this record back to the database
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$data = array();
|
||||
$data['name'] = $this->name;
|
||||
|
||||
if ($this->id) {
|
||||
$this->update($data);
|
||||
}
|
||||
else {
|
||||
$this->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
private function update($data)
|
||||
{
|
||||
$zend_db = Database::getConnection();
|
||||
$zend_db->update('cemeteries',$data,"id='{$this->id}'");
|
||||
}
|
||||
|
||||
private function insert($data)
|
||||
{
|
||||
$zend_db = Database::getConnection();
|
||||
$zend_db->insert('cemeteries',$data);
|
||||
$this->id = $zend_db->lastInsertId('cemeteries','id');
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Generic Getters
|
||||
//----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Generic Setters
|
||||
//----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*/
|
||||
public function setName($string)
|
||||
{
|
||||
$this->name = trim($string);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Custom Functions
|
||||
// We recommend adding all your custom code down here at the bottom
|
||||
//----------------------------------------------------------------
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* A collection class for Cemetery objects
|
||||
*
|
||||
* This class creates a zend_db select statement.
|
||||
* ZendDbResultIterator handles iterating and paginating those results.
|
||||
* As the results are iterated over, ZendDbResultIterator will pass each desired
|
||||
* row back to this class's loadResult() which will be responsible for hydrating
|
||||
* each Cemetery object
|
||||
*
|
||||
* Beyond the basic $fields handled, you will need to write your own handling
|
||||
* of whatever extra $fields you need
|
||||
*/
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
class CemeteryList extends ZendDbResultIterator
|
||||
{
|
||||
/**
|
||||
* Creates a basic select statement for the collection.
|
||||
*
|
||||
* Populates the collection if you pass in $fields
|
||||
* Setting itemsPerPage turns on pagination mode
|
||||
* In pagination mode, this will only load the results for one page
|
||||
*
|
||||
* @param array $fields
|
||||
* @param int $itemsPerPage Turns on Pagination
|
||||
* @param int $currentPage
|
||||
*/
|
||||
public function __construct($fields=null,$itemsPerPage=null,$currentPage=null)
|
||||
{
|
||||
parent::__construct($itemsPerPage,$currentPage);
|
||||
if (is_array($fields)) {
|
||||
$this->find($fields);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the collection
|
||||
*
|
||||
* @param array $fields
|
||||
* @param string|array $order Multi-column sort should be given as an array
|
||||
* @param int $limit
|
||||
* @param string|array $groupBy Multi-column group by should be given as an array
|
||||
*/
|
||||
public function find($fields=null,$order='name',$limit=null,$groupBy=null)
|
||||
{
|
||||
$this->select->from('cemeteries');
|
||||
|
||||
// Finding on fields from the cemeteries table is handled here
|
||||
if (count($fields)) {
|
||||
foreach ($fields as $key=>$value) {
|
||||
$this->select->where("$key=?",$value);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// above foreach only handles fields from the cemeteries table.
|
||||
|
||||
$this->select->order($order);
|
||||
if ($limit) {
|
||||
$this->select->limit($limit);
|
||||
}
|
||||
if ($groupBy) {
|
||||
$this->select->group($groupBy);
|
||||
}
|
||||
$this->populateList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrates all the Cemetery objects from a database result set
|
||||
*
|
||||
* This is a callback function, called from ZendDbResultIterator. It is
|
||||
* called once per row of the result.
|
||||
*
|
||||
* @param int $key The index of the result row to load
|
||||
* @return Cemetery
|
||||
*/
|
||||
protected function loadResult($key)
|
||||
{
|
||||
return new Cemetery($this->result[$key]);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,9 @@ class Deed
|
|||
private $issueDate;
|
||||
private $notes;
|
||||
private $lot2;
|
||||
private $whiteoak;
|
||||
private $cemetery_id;
|
||||
|
||||
private $cemetery;
|
||||
|
||||
/**
|
||||
* Populates the object with data
|
||||
|
@ -93,7 +95,7 @@ class Deed
|
|||
$data['issueDate'] = $this->issueDate ? $this->issueDate->format('Y-m-d') : null;
|
||||
$data['notes'] = $this->notes ? $this->notes : null;
|
||||
$data['lot2'] = $this->lot2 ? $this->lot2 : null;
|
||||
$data['whiteoak'] = $this->whiteoak ? $this->whiteoak : null;
|
||||
$data['cemetery_id'] = $this->cemetery_id ? $this->cemetery_id : null;
|
||||
|
||||
if ($this->id) {
|
||||
$this->update($data);
|
||||
|
@ -229,11 +231,25 @@ class Deed
|
|||
}
|
||||
|
||||
/**
|
||||
* @return char
|
||||
* @return int
|
||||
*/
|
||||
public function getWhiteoak()
|
||||
public function getCemetery_id()
|
||||
{
|
||||
return $this->whiteoak;
|
||||
return $this->cemetery_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cemetery
|
||||
*/
|
||||
public function getCemetery()
|
||||
{
|
||||
if ($this->cemetery_id) {
|
||||
if (!$this->cemetery) {
|
||||
$this->cemetery = new Cemetery($this->cemetery_id);
|
||||
}
|
||||
return $this->cemetery;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -341,13 +357,22 @@ class Deed
|
|||
}
|
||||
|
||||
/**
|
||||
* @param char $char
|
||||
* @param int $int
|
||||
*/
|
||||
public function setWhiteoak($char)
|
||||
public function setCemetery_id($int)
|
||||
{
|
||||
$this->whiteoak = $char;
|
||||
$this->cemetery = new Cemetery($int);
|
||||
$this->cemetery_id = $int;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cemetery $cemetery
|
||||
*/
|
||||
public function setCemetery($cemetery)
|
||||
{
|
||||
$this->cemetery_id = $cemetery->getId();
|
||||
$this->cemetery = $cemetery;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Custom Functions
|
||||
|
|
|
@ -19,10 +19,12 @@ class Internment
|
|||
private $lastResidence;
|
||||
private $age;
|
||||
private $sex;
|
||||
private $whiteoak;
|
||||
private $cemetery_id;
|
||||
private $notes;
|
||||
private $lot2;
|
||||
|
||||
private $cemetery;
|
||||
|
||||
/**
|
||||
* Populates the object with data
|
||||
*
|
||||
|
@ -97,7 +99,7 @@ class Internment
|
|||
$data['lastResidence'] = $this->lastResidence ? $this->lastResidence : null;
|
||||
$data['age'] = $this->age ? $this->age : null;
|
||||
$data['sex'] = $this->sex ? $this->sex : null;
|
||||
$data['whiteoak'] = $this->whiteoak ? $this->whiteoak : null;
|
||||
$data['cemetery_id'] = $this->cemetery_id ? $this->cemetery_id : null;
|
||||
$data['notes'] = $this->notes ? $this->notes : null;
|
||||
$data['lot2'] = $this->lot2 ? $this->lot2 : null;
|
||||
|
||||
|
@ -242,14 +244,6 @@ class Internment
|
|||
return $this->sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return char
|
||||
*/
|
||||
public function getWhiteoak()
|
||||
{
|
||||
return $this->whiteoak;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return text
|
||||
*/
|
||||
|
@ -266,6 +260,27 @@ class Internment
|
|||
return $this->lot2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCemetery_id()
|
||||
{
|
||||
return $this->cemetery_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cemetery
|
||||
*/
|
||||
public function getCemetery()
|
||||
{
|
||||
if ($this->cemetery_id) {
|
||||
if (!$this->cemetery) {
|
||||
$this->cemetery = new Cemetery($this->cemetery_id);
|
||||
}
|
||||
return $this->cemetery;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
// Generic Setters
|
||||
//----------------------------------------------------------------
|
||||
|
@ -379,11 +394,21 @@ class Internment
|
|||
}
|
||||
|
||||
/**
|
||||
* @param char $char
|
||||
* @param int $int
|
||||
*/
|
||||
public function setWhiteoak($char)
|
||||
public function setCemetery_id($int)
|
||||
{
|
||||
$this->whiteoak = $char;
|
||||
$this->cemetery = new Cemetery($int);
|
||||
$this->cemetery_id = $int;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cemetery $cemetery
|
||||
*/
|
||||
public function setCemetery($cemetery)
|
||||
{
|
||||
$this->cemetery_id = $cemetery->getId();
|
||||
$this->cemetery = $cemetery;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ class InternmentList extends ZendDbResultIterator
|
|||
{
|
||||
$this->select->from('internments');
|
||||
|
||||
// Finding on fields from the internment table is handled here
|
||||
// Finding on fields from the internments table is handled here
|
||||
if (count($fields)) {
|
||||
foreach ($fields as $key=>$value) {
|
||||
$this->select->where("$key=?",$value);
|
||||
|
@ -59,7 +59,7 @@ class InternmentList extends ZendDbResultIterator
|
|||
// 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
|
||||
// above foreach only handles fields from the internment table.
|
||||
// above foreach only handles fields from the internments table.
|
||||
|
||||
$this->select->order($order);
|
||||
if ($limit) {
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
if (!userIsAllowed('Cemeteries')) {
|
||||
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
|
||||
header('Location: '.BASE_URL.'/cemeteries');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_POST['cemetery'])) {
|
||||
$cemetery = new Cemetery();
|
||||
foreach ($_POST['cemetery'] as $field=>$value) {
|
||||
$set = 'set'.ucfirst($field);
|
||||
$cemetery->$set($value);
|
||||
}
|
||||
|
||||
try {
|
||||
$cemetery->save();
|
||||
header('Location: '.BASE_URL.'/cemeteries');
|
||||
exit();
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$_SESSION['errorMessages'][] = $e;
|
||||
}
|
||||
}
|
||||
|
||||
$template = new Template();
|
||||
$template->blocks[] = new Block('cemeteries/addCemeteryForm.inc');
|
||||
echo $template->render();
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
|
||||
$cemeteryList = new CemeteryList();
|
||||
$cemeteryList->find();
|
||||
|
||||
$template = new Template();
|
||||
$template->blocks[] = new Block('cemeteries/cemeteryList.inc',array('cemeteryList'=>$cemeteryList));
|
||||
echo $template->render();
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
if (!userIsAllowed('Cemeteries')) {
|
||||
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
|
||||
header('Location: '.BASE_URL.'/cemeteries');
|
||||
exit();
|
||||
}
|
||||
|
||||
$cemetery = new Cemetery($_REQUEST['cemetery_id']);
|
||||
if (isset($_POST['cemetery'])) {
|
||||
foreach ($_POST['cemetery'] as $field=>$value) {
|
||||
$set = 'set'.ucfirst($field);
|
||||
$cemetery->$set($value);
|
||||
}
|
||||
|
||||
try {
|
||||
$cemetery->save();
|
||||
header('Location: '.BASE_URL.'/cemeteries');
|
||||
exit();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$_SESSION['errorMessages'][] = $e;
|
||||
}
|
||||
}
|
||||
|
||||
$template = new Template();
|
||||
$template->blocks[] = new Block('cemeteries/updateCemeteryForm.inc',array('cemetery'=>$cemetery));
|
||||
echo $template->render();
|
|
@ -4,8 +4,9 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
||||
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
||||
*/
|
||||
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
|
||||
$deedList = new DeedList();
|
||||
$deedList = new DeedList(null,20,$currentPage);
|
||||
$deedList->find();
|
||||
|
||||
$template = new Template();
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
insert deeds (id,section,lot,lastname1,firstname1,middleInitial1,
|
||||
lastname2,firstname2,middleInitial2,issueDate,notes,lot2,cemetery_id)
|
||||
select r.ID,r.SEC,r.LOT,r.LNAME1,r.FNAME1,r.MI1,
|
||||
r.LNAME2,r.FNAME2,r.MI2,r.DATE_ISSUE,r.NOTES,r.lot2,c.id
|
||||
from rosehill.DEED r
|
||||
left join cemeteries c on r.whiteoak=substr(c.name,1,1);
|
|
@ -1,7 +1,11 @@
|
|||
<div id="panel-one">
|
||||
<?php
|
||||
if (userIsAllowed('Users')) {
|
||||
include APPLICATION_HOME.'/templates/html/partials/panel-widgets/Users.inc';
|
||||
}
|
||||
?>
|
||||
<ul><li><a href="<?php echo BASE_URL; ?>/cemeteries">Cemeteries</a></li>
|
||||
<li><a href="<?php echo BASE_URL; ?>/deeds">Deeds</a></li>
|
||||
<li><a href="<?php echo BASE_URL; ?>/internments">Internments</a></li>
|
||||
</ul>
|
||||
<?php
|
||||
if (userIsAllowed('Users')) {
|
||||
include APPLICATION_HOME.'/templates/html/partials/panel-widgets/Users.inc';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue