Updated Deeds CRUD

This commit is contained in:
Cliff Ingham 2014-08-20 10:12:00 -04:00
parent c6d73b5671
commit 1e28115f63
22 changed files with 492 additions and 921 deletions

6
.gitmodules vendored
View File

@ -1,9 +1,9 @@
[submodule "html/js/yui3"]
path = html/js/yui3
url = https://github.com/yui/yui3.git
[submodule "libraries/phpCAS"] [submodule "libraries/phpCAS"]
path = libraries/phpCAS path = libraries/phpCAS
url = https://github.com/Jasig/phpCAS.git url = https://github.com/Jasig/phpCAS.git
[submodule "libraries/zf2"] [submodule "libraries/zf2"]
path = libraries/zf2 path = libraries/zf2
url = https://github.com/zendframework/zf2.git url = https://github.com/zendframework/zf2.git
[submodule "public/js/yui3"]
path = public/js/yui3
url = https://github.com/yui/yui3.git

View File

@ -0,0 +1,79 @@
<?php
/**
* @copyright 2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
namespace Application\Controllers;
use Application\Models\Deed;
use Application\Models\DeedsTable;
use Blossom\Classes\Controller;
use Blossom\Classes\Block;
class DeedsController extends Controller
{
public function index()
{
$table = new DeedsTable();
$knownFields = ['section_id','lot','cemetery_id','firstname','lastname','middleInitial'];
if (count(array_intersect(array_keys($_GET), $knownFields))) {
$list = $table->search($_GET, null, true);
}
else {
$list = $table->find(null, null, true);
}
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$list->setCurrentPageNumber($page);
$list->setItemCountPerPage(20);
$this->template->blocks[] = new Block('deeds/findForm.inc');
$this->template->blocks[] = new Block('deeds/list.inc', ['deeds' => $list]);
$this->template->blocks[] = new Block('pageNavigation.inc', ['paginator'=> $list]);
}
public function update()
{
if (!empty($_REQUEST['deed_id'])) {
try {
$deed = new Deed($_REQUEST['deed_id']);
}
catch (\Exception $e) {
$_SESSION['errorMessages'][] = $e;
}
}
else {
$deed = new Deed();
}
if (isset($_POST['deed_id'])) {
try {
$deed->handleUpdate($_POST);
$deed->save();
header('Location: '.BASE_URL.'/deeds');
exit();
}
catch (\Exception $e) {
$_SESSION['errorMessages'][] = $e;
}
}
$this->template->blocks[] = new Block('deeds/updateForm.inc', ['deed'=>$deed]);
}
public function delete()
{
$return_url = !empty($_GET['return_url']) ? $_GET['return_url'] : BASE_URL.'/deeds';
try {
$deed = new Deed($_GET['deed_id']);
$deed->delete();
}
catch (\Exception $e) {
$_SESSION['errorMessages'][] = $e;
}
header("Location: $return_url");
exit();
}
}

134
Models/Deed.php Normal file
View File

@ -0,0 +1,134 @@
<?php
/**
* @copyright 2009 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
namespace Application\Models;
use Blossom\Classes\ActiveRecord;
use Blossom\Classes\Database;
use Blossom\Classes\ExternalIdentity;
class Deed extends ActiveRecord
{
protected $tablename = 'deeds';
protected $section;
protected $cemetery;
/**
* 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|string|array $id (ID, email, username)
*/
public function __construct($id=null)
{
if ($id) {
if (is_array($id)) {
$this->exchangeArray($id);
}
else {
$zend_db = Database::getConnection();
$sql = 'select * from deeds where id=?';
$result = $zend_db->createStatement($sql)->execute([$id]);
if (count($result)) {
$this->exchangeArray($result->current());
}
else {
throw new \Exception('deeds/unknownDeed');
}
}
}
else {
// This is where the code goes to generate a new, empty instance.
// Set any default values for properties that need it here
}
}
public function validate() { }
public function save () { parent::save (); }
public function delete() { parent::delete(); }
//----------------------------------------------------------------
// Generic Getters and Setters
//----------------------------------------------------------------
public function getId() { return parent::get('id'); }
public function getLot() { return parent::get('lot'); }
public function getLot2() { return parent::get('lot2'); }
public function getLastname1() { return parent::get('lastname1'); }
public function getLastname2() { return parent::get('lastname2'); }
public function getFirstname1() { return parent::get('firstname1'); }
public function getFirstname2() { return parent::get('firstname2'); }
public function getMiddleInitial1() { return parent::get('middleInitial1'); }
public function getMiddleInitial2() { return parent::get('middleInitial2'); }
public function getNotes() { return parent::get('notes'); }
public function getSection_id() { return parent::get('section_id'); }
public function getCemetery_id() { return parent::get('cemetery_id'); }
public function getSection() { return parent::getForeignKeyObject(__namespace__.'\Section', 'section_id'); }
public function getCemetery() { return parent::getForeignKeyObject(__namespace__.'\Cemetery', 'cemetery_id'); }
public function getIssueDate($f=null) { return parent::getDateData('issueDate', $f); }
public function setLot ($s) { parent::set('lot', $s); }
public function setLot2 ($s) { parent::set('lot2', $s); }
public function setLastname1 ($s) { parent::set('lastname1', $s); }
public function setLastname2 ($s) { parent::set('lastname2', $s); }
public function setFirstname1 ($s) { parent::set('firstname1', $s); }
public function setFirstname2 ($s) { parent::set('firstname2', $s); }
public function setMiddleInitial1($s) { parent::set('middleInitial1', $s); }
public function setMiddleInitial2($s) { parent::set('middleInitial2', $s); }
public function setNotes ($s) { parent::set('notes', $s); }
public function setSection_id ($i) { parent::setForeignKeyField (__namespace__.'\Section', 'section_id', $i); }
public function setSection ($o) { parent::setForeignKeyObject(__namespace__.'\Section', 'section_id', $o); }
public function setCemetery_id($i) { parent::setForeignKeyField (__namespace__.'\Cemetery', 'cemetery_id', $i); }
public function setCemetery ($o) { parent::setForeignKeyObject(__namespace__.'\Cemetery', 'cemetery_id', $o); }
/**
* @param array $post
*/
public function handleUpdate($post)
{
$fields = [
'section_id', 'cemetery_id', 'lot', 'lot2',
'firstname1', 'firstname2', 'middleInitial1', 'middleInitial2',
'lastname1', 'lastname2', 'notes'
];
foreach ($fields as $f) {
$set = 'set'.ucfirst($f);
$this->$set($post[$f]);
}
}
//----------------------------------------------------------------
// Custom Functions
// We recommend adding all your custom code down here at the bottom
//----------------------------------------------------------------
/**
* @return string
*/
public function getUrl() { return BASE_URL.'/deeds/view?deed_id='.$this->getId(); }
public function getUri() { return BASE_URI.'/deeds/view?deed_id='.$this->getId(); }
/**
* Returns the full name of the owner
*
* @param int $number
* @return string
*/
public function getOwner($number=1)
{
$name = [];
$fields = ['firstname', 'middleInitial', 'lastname'];
foreach ($fields as $f) {
$get = 'get'.ucfirst($f).$number;
if ($this->$get()) { $name[] = $this->$get(); }
}
return implode(' ', $name);
}
}

59
Models/DeedsTable.php Normal file
View File

@ -0,0 +1,59 @@
<?php
/**
* @copyright 2009-2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
namespace Application\Models;
use Blossom\Classes\TableGateway;
use Zend\Db\Sql\Select;
use Zend\Db\Sql\Predicate\Like;
use Zend\Db\Sql\Predicate\PredicateSet;
class DeedsTable extends TableGateway
{
public function __construct() { parent::__construct('deeds', __namespace__.'\Deed'); }
private $columns = array(
'id','section_id','lot','lot2','cemetery_id',
'lastname1','firstname1','middleInitial1',
'lastname2','firstname2','middleInitial2',
'issueDate','notes'
);
/**
* @param array $fields
* @param string|array $order Multi-column sort should be given as an array
* @param bool $paginated Whether to return a paginator or a raw resultSet
* @param int $limit
*/
public function search($fields=null, $order='id', $paginated=false, $limit=null)
{
$select = new Select('deeds');
if (count($fields)) {
foreach ($fields as $key=>$value) {
if (!empty($value)) {
switch ($key) {
case 'lastname':
case 'firstname':
case 'middleInitial':
if (!empty($value)) {
$select->where(
new PredicateSet([
new Like("{$key}1", "$value%"),
new LIke("{$key}2", "$value%")
], PredicateSet::OP_OR)
);
}
break;
default:
$select->where([$key=>$value]);
}
}
}
}
return parent::performSelect($select, $order, $paginated, $limit);
}
}

View File

@ -34,8 +34,8 @@ $ZEND_ACL->allow(null,'login');
// Permissions for unauthenticated browsing // Permissions for unauthenticated browsing
$ZEND_ACL->allow(null, $ZEND_ACL->allow(null,
array('index'), ['index', 'deeds', 'interments'],
array('index')); ['index']);
// Allow Staff to do stuff // Allow Staff to do stuff
$ZEND_ACL->allow('Staff',['deeds', 'interments']); $ZEND_ACL->allow('Staff',['deeds', 'interments']);

View File

@ -1,78 +0,0 @@
<?php
/**
* @copyright 2009-2010 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
?>
<h2>Add Deed</h2>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<fieldset><legend>Deed Info</legend>
<table>
<tr><td><label for="deed-cemetery_id">Cemetery</label></td>
<td><select name="deed[cemetery_id]" id="deed-cemetery_id"
onchange="COB.populateSections(this.options[this.selectedIndex].value,'deed-section_id','<?php echo BASE_URL; ?>')">
<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>
<tr><td><label for="deed-section_id">Section</label></td>
<td><select name="deed[section_id]" id="deed-section_id">
<option></option>
</select>
<label for="deed-lot">Lot</label>
<input name="deed[lot]" id="deed-lot" />
</td>
</tr>
<tr><td><label for="deed-issueDate">Date Issued</label></td>
<td><input name="deed[issueDate]" size="10" value="<?php echo date('n/j/Y'); ?>" />
</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>
</table>
</fieldset>
<fieldset><legend>Owner 1</legend>
<table>
<tr><td><label for="deed-firstname1">First</label></td>
<td><input name="deed[firstname1]" id="deed-firstname1" /></td>
</tr>
<tr><td><label for="deed-middleInitial1">MI</label></td>
<td><input name="deed[middleInitial1]" id="deed-middleInitial1" />
</td>
</tr>
<tr><td><label for="deed-lastname1">Last</label></td>
<td><input name="deed[lastname1]" id="deed-lastname1" /></td>
</tr>
</table>
</fieldset>
<fieldset><legend>Owner 2</legend>
<table>
<tr><td><label for="deed-firstname2">First</label></td>
<td><input name="deed[firstname2]" id="deed-firstname2" /></td>
</tr>
<tr><td><label for="deed-middleInitial2">MI</label></td>
<td><input name="deed[middleInitial2]" id="deed-middleInitial2" />
</td>
</tr>
<tr><td><label for="deed-lastname2">Last</label></td>
<td><input name="deed[lastname2]" id="deed-lastname2" /></td>
</tr>
</table>
<button type="submit" class="submit">Submit</button>
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/deeds';">
Cancel
</button>
</fieldset>
</form>

View File

@ -1,80 +0,0 @@
<?php
/**
* @copyright 2009 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param DeedList $this->deedList
*/
?>
<div class="interfaceBox">
<h2>
<?php
if (userIsAllowed('Deeds')) {
echo "
<button type=\"button\" class=\"add\" onclick=\"document.location.href='".BASE_URL."/deeds/addDeed.php';\">
Add
</button>
";
}
?>
Deeds
</h2>
<table>
<thead>
<tr><th></th>
<th>Section, Lot</th>
<th>Owner 1</th>
<th>Owner 2</th>
<th>Issue Date</th>
<th>Cemetery</th>
</tr>
</thead>
<tbody>
<?php
foreach ($this->deedList as $deed) {
$editButton = '';
if (userIsAllowed('Deeds')) {
$url = new URL(BASE_URL.'/deeds/updateDeed.php');
$url->deed_id = $deed->getId();
$editButton = "
<button type=\"button\" class=\"edit\" onclick=\"document.location.href='$url';\">
Edit
</button>
";
$url = new URL(BASE_URL.'/deeds/deleteDeed.php');
$url->deed_id = $deed->getId();
$url->return_url = "http://$_SERVER[SERVER_NAME]$_SERVER[REQUEST_URI]";
$deleteButton = "
<button type=\"button\" class=\"delete\" onclick=\"COB.deleteConfirmation('$url');\">
Delete
</button>
";
}
$section = View::escape($deed->getSection());
$lot = View::escape($deed->getLot());
$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 $deleteButton</td>
<td>{$deed->getSection()}, {$deed->getLot()}</td>
<td>$owner1</td>
<td>$owner2</td>
<td>$date</td>
<td>$cemetery</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<?php
if ($this->deedList->getPaginator()) {
$pageNavigation = new Block('pageNavigation.inc',
array('pages'=>$this->deedList->getPaginator()->getPages()));
echo $pageNavigation->render('html');
}
?>

View File

@ -1,11 +1,11 @@
<?php <?php
/** /**
* @copyright 2009-2010 City of Bloomington, Indiana * @copyright 2009-2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov> * @author Cliff Ingham <inghamn@bloomington.in.gov>
*/ */
?> ?>
<form method="get" action="<?php echo BASE_URL; ?>/deeds"> <form method="get" action="<?php echo BASE_URI; ?>/deeds">
<?php <?php
// Whether you're searching for deeds or interments, the fields // Whether you're searching for deeds or interments, the fields
// the user enters are the same // the user enters are the same
@ -14,4 +14,4 @@
<div> <div>
<button type="submit" class="search">Search</button> <button type="submit" class="search">Search</button>
</div> </div>
</form> </form>

View File

@ -0,0 +1,76 @@
<?php
/**
* @copyright 2009-2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param DeedList $this->deeds
*/
use Application\Models\Person;
use Blossom\Classes\View;
?>
<div>
<h2><?php
echo $this->translate(['deed', 'deeds', 2]);
if (Person::isAllowed('deeds', 'edit')) {
$helper = $this->template->getHelper('buttonLink');
echo $helper->buttonLink(
BASE_URI.'/deeds/update',
$this->translate('add'),
'add'
);
}
?>
</h2>
<table>
<thead>
<tr><th></th>
<th><?php echo $this->translate(['section', 'sections', 1]); ?>,
<?php echo $this->translate('lot'); ?>
</th>
<th><?php echo $this->translate('owner'); ?> 1</th>
<th><?php echo $this->translate('owner'); ?> 2</th>
<th><?php echo $this->translate('issue_date'); ?></th>
<th><?php echo $this->translate(['cemetery', 'cemeteries', 1]); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach ($this->deeds as $deed) {
$editButton = '';
$deleteButton = '';
if (Person::isAllowed('deeds', 'edit')) {
$editButton = $helper->buttonLink(
BASE_URI.'/deeds/update?deed_id='.$deed->getId(),
$this->translate('edit'),
'edit'
);
$return_url = "https://$_SERVER[SERVER_NAME]$_SERVER[REQUEST_URI]";
$deleteButton = $helper->buttonLink(
BASE_URI."/deeds/delete?deed_id={$deed->getId()};return_url=$return_url",
$this->translate('delete'),
'delete'
);
}
$section = View::escape($deed->getSection());
$lot = View::escape($deed->getLot());
$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>$section, $lot</td>
<td>$owner1</td>
<td>$owner2</td>
<td>$date</td>
<td>$cemetery</td>
<td>$deleteButton</td>
</tr>
";
}
?>
</tbody>
</table>
</div>

View File

@ -1,104 +0,0 @@
<?php
/**
* @copyright 2009-2010 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
@param Deed $this->deed
*/
?>
<h2>Update Deed</h2>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<fieldset><legend>Deed Info</legend>
<input name="deed_id" type="hidden" value="<?php echo $this->deed->getId(); ?>" />
<table>
<tr><td><label for="deed-cemetery_id">Cemetery</label></td>
<td><select name="deed[cemetery_id]" id="deed-cemetery_id"
onchange="COB.populateSections(this.options[this.selectedIndex].value,'deed-section_id','<?php echo BASE_URL; ?>')">
<option></option>
<?php
$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()}\" $selected>$name</option>";
}
?>
</select>
</td>
</tr>
<tr><td><label for="deed-section_id">Section</label></td>
<td><select name="deed[section_id]" id="deed-section_id">
<option></option>
<?php
if ($this->deed->getSection_id()) {
foreach ($this->deed->getCemetery()->getSections() as $section) {
$name = View::escape($section->getCode());
$selected = $section->getId()==$this->deed->getSection_id()
? 'selected="selected"'
: '';
echo "<option value=\"{$section->getId()}\" $selected>$name</option>";
}
}
?>
</select>
<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-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-notes">notes</label></td>
<td><textarea name="deed[notes]" id="deed-notes" rows="3" cols="60"><?php echo View::escape($this->deed->getNotes()); ?></textarea>
</td>
</tr>
</table>
</fieldset>
<fieldset><legend>Owner 1</legend>
<table>
<tr><td><label for="deed-firstname1">First</label></td>
<td><input name="deed[firstname1]" id="deed-firstname1"
value="<?php echo View::escape($this->deed->getFirstname1()); ?>" />
</td>
</tr>
<tr><td><label for="deed-middleInitial1">MI</label></td>
<td><input name="deed[middleInitial1]" id="deed-middleInitial1"
value="<?php echo View::escape($this->deed->getMiddleInitial1()); ?>" />
</td>
</tr>
<tr><td><label for="deed-lastname1">Last</label></td>
<td><input name="deed[lastname1]" id="deed-lastname1"
value="<?php echo View::escape($this->deed->getLastname1()); ?>" />
</td>
</tr>
</table>
</fieldset>
<fieldset><legend>Owner 2</legend>
<table>
<tr><td><label for="deed-firstname2">First</label></td>
<td><input name="deed[firstname2]" id="deed-firstname2"
value="<?php echo View::escape($this->deed->getFirstname2()); ?>" />
</td>
</tr>
<tr><td><label for="deed-middleInitial2">MI</label></td>
<td><input name="deed[middleInitial2]" id="deed-middleInitial2"
value="<?php echo View::escape($this->deed->getMiddleInitial2()); ?>" />
</td>
</tr>
<tr><td><label for="deed-lastname2">Last</label></td>
<td><input name="deed[lastname2]" id="deed-lastname2"
value="<?php echo View::escape($this->deed->getLastname2()); ?>" />
</td>
</tr>
</table>
<button type="submit" class="submit">Submit</button>
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/deeds';">
Cancel
</button>
</fieldset>
</form>

View File

@ -0,0 +1,108 @@
<?php
/**
* @copyright 2009-2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
@param Deed $this->deed
*/
use Application\Models\CemeteriesTable;
use Blossom\Classes\View;
$this->template->addToAsset('scripts', YUI.'/yui/yui-min.js');
$this->template->addToAsset('scripts', BASE_URI.'/js/functions.js');
$fields = [
'cemetery_id', 'section_id', 'lot',
'firstname1', 'firstname2', 'middleInitial1', 'middleInitial2', 'lastname1', 'lastname2',
'notes'
];
foreach ($fields as $f) {
$get = 'get'.ucfirst($f);
$$f = View::escape($this->deed->$get());
}
$title = $this->deed->getId() ? $this->translate('edit_deed') : $this->translate('add_deed');
?>
<h2><?php echo $title; ?></h2>
<form method="post" action="<?php echo BASE_URI; ?>/deeds/update">
<fieldset><legend><?php echo $this->translate('info_deed'); ?></legend>
<input name="deed_id" type="hidden" value="<?php echo $this->deed->getId(); ?>" />
<table>
<tr><td><label for="cemetery_id">Cemetery</label></td>
<td><select name="cemetery_id" id="cemetery_id"
onchange="COB.populateSections(this.options[this.selectedIndex].value,'section_id','<?php echo BASE_URL; ?>')">
<option></option>
<?php
$table = new CemeteriesTable();
$list = $table->find();
foreach ($list as $cemetery) {
$name = View::escape($cemetery->getName());
$selected = $cemetery->getId()==$cemetery_id
? 'selected="selected"'
: '';
echo "<option value=\"{$cemetery->getId()}\" $selected>$name</option>";
}
?>
</select>
</td>
</tr>
<tr><td><label for="section_id">Section</label></td>
<td><select name="section_id" id="section_id">
<option></option>
<?php
if ($this->deed->getSection_id()) {
foreach ($this->deed->getCemetery()->getSections() as $section) {
$name = View::escape($section->getCode());
$selected = $section->getId()==$section_id
? 'selected="selected"'
: '';
echo "<option value=\"{$section->getId()}\" $selected>$name</option>";
}
}
?>
</select>
<label for="lot">Lot</label>
<input name="lot" id="deed-lot" size="3" value="<?php echo $lot; ?>" />
</td>
</tr>
<tr><td><label for="issueDate">Date Issued</label></td>
<td><input name="issueDate" size="10" value="<?php echo $this->deed->getIssueDate('n/j/Y'); ?>" /></td>
</tr>
<tr><td><label for="notes">notes</label></td>
<td><textarea name="notes" id="notes" rows="3" cols="60"><?php echo $notes; ?></textarea>
</td>
</tr>
</table>
</fieldset>
<fieldset><legend>Owner 1</legend>
<table>
<tr><td><label for="firstname1">First</label></td>
<td><input name="firstname1" id="firstname1" value="<?php echo $firstname1; ?>" /></td>
</tr>
<tr><td><label for="middleInitial1">MI</label></td>
<td><input name="middleInitial1" id="middleInitial1" value="<?php echo $middleInitial1; ?>" /></td>
</tr>
<tr><td><label for="lastname1">Last</label></td>
<td><input name="lastname1" id="lastname1" value="<?php echo $lastname1; ?>" /></td>
</tr>
</table>
</fieldset>
<fieldset><legend>Owner 2</legend>
<table>
<tr><td><label for="firstname2">First</label></td>
<td><input name="firstname2" id="firstname2" value="<?php echo $firstname2; ?>" /></td>
</tr>
<tr><td><label for="middleInitial2">MI</label></td>
<td><input name="middleInitial2" id="middleInitial2" value="<?php echo $middleInitial2; ?>" /></td>
</tr>
<tr><td><label for="lastname2">Last</label></td>
<td><input name="lastname2" id="lastname2" value="<?php echo $lastname2; ?>" /></td>
</tr>
</table>
<?php
$h = $this->template->getHelper('saveAndCancelButtons');
echo $h->saveAndCancelButtons(BASE_URI.'/deeds');
?>
</fieldset>
</form>

View File

@ -1,28 +1,31 @@
<?php <?php
/** /**
* @copyright 2010 City of Bloomington, Indiana * @copyright 2010-2014 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov> * @author Cliff Ingham <inghamn@bloomington.in.gov>
*/ */
use Application\Models\CemeteriesTable;
use Application\Models\SectionsTable;
use Blossom\Classes\View;
$lastname = isset($_GET['lastname']) ? View::escape($_GET['lastname']) : '';
$firstname = isset($_GET['firstname']) ? View::escape($_GET['firstname']) : '';
$lot = isset($_GET['lot']) ? View::escape($_GET['lot']) : '';
?> ?>
<table> <table>
<tr><td><label for="lastname">Last Name</label></td> <tr><td><label for="lastname">Last Name</label></td>
<td><input name="lastname" id="lastname" <td><input name="lastname" id="lastname" value="<?php echo $lastname; ?>" /></td>
value="<?php echo isset($_GET['lastname']) ? View::escape($_GET['lastname']) : ''; ?>" />
</td>
</tr> </tr>
<tr><td><label for="firstname">First Name</label></td> <tr><td><label for="firstname">First Name</label></td>
<td><input name="firstname" id="firstname" <td><input name="firstname" id="firstname" value="<?php echo $firstname; ?>" /></td>
value="<?php echo isset($_GET['firstname']) ? View::escape($_GET['firstname']) : ''; ?>" />
</td>
</tr> </tr>
<tr><td><label for="cemetery_id">Cemetery</label></td> <tr><td><label for="cemetery_id">Cemetery</label></td>
<td><select name="cemetery_id" id="cemetery_id" <td><select name="cemetery_id" id="cemetery_id"
onchange="COB.populateSections(this.options[this.selectedIndex].value,'section_id','<?php echo BASE_URL; ?>')"> onchange="COB.populateSections(this.options[this.selectedIndex].value,'section_id','<?php echo BASE_URL; ?>')">
<option value="">Any Cemetery</option> <option value="">Any Cemetery</option>
<?php <?php
$cemeteries = new CemeteryList(); $table = new CemeteriesTable();
$cemeteries->find(); $cemeteries = $table->find();
foreach ($cemeteries as $cemetery) { foreach ($cemeteries as $cemetery) {
$name = View::escape($cemetery->getName()); $name = View::escape($cemetery->getName());
$selected = (isset($_GET['cemetery_id']) && $_GET['cemetery_id']==$cemetery->getId()) $selected = (isset($_GET['cemetery_id']) && $_GET['cemetery_id']==$cemetery->getId())
@ -39,7 +42,8 @@
<option value="">Any Section</option> <option value="">Any Section</option>
<?php <?php
if (isset($_GET['cemetery_id'])) { if (isset($_GET['cemetery_id'])) {
$sections = new SectionList(array('cemetery_id'=>$_GET['cemetery_id'])); $table = new SectionsTable();
$sections = $table->find(['cemetery_id'=>$_GET['cemetery_id']]);
foreach ($sections as $section) { foreach ($sections as $section) {
$name = $section->getName() $name = $section->getName()
? View::escape($section->getName()) ? View::escape($section->getName())
@ -53,7 +57,7 @@
?> ?>
</select> </select>
<label for="lot">Lot</label> <label for="lot">Lot</label>
<input name="lot" id="lot" size="3" value="<?php echo isset($_GET['lot']) ? View::escape($_GET['lot']) : ''; ?>" /> <input name="lot" id="lot" size="3" value="<?php echo $lot; ?>" />
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -5,6 +5,7 @@
.git/ .git/
.git* .git*
configuration.inc configuration.inc
site_config.inc
/data/sessions/* /data/sessions/*
/scripts/backup.cnf /scripts/backup.cnf
/html/js/yui3/src/ /public/js/yui3/src/

View File

@ -1,438 +0,0 @@
<?php
/**
* @copyright 2009 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
class Deed
{
private $id;
private $section_id;
private $lot;
private $lastname1;
private $firstname1;
private $middleInitial1;
private $lastname2;
private $firstname2;
private $middleInitial2;
private $issueDate;
private $notes;
private $lot2;
private $cemetery_id;
private $section;
private $cemetery;
/**
* 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();
$sql = 'select * from deeds where id=?';
$result = $zend_db->fetchRow($sql,array($id));
}
if ($result) {
foreach ($result as $field=>$value) {
if ($value) {
if ($field == 'issueDate') {
$value = (false === strpos($value,'0000')) ? new Date($value) : null;
}
$this->$field = $value;
}
}
}
else {
throw new Exception('deeds/unknownDeed');
}
}
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.
}
/**
* Saves this record back to the database
*/
public function save()
{
$this->validate();
$data = array();
$data['section_id'] = $this->section_id ? $this->section_id : null;
$data['lot'] = $this->lot ? $this->lot : null;
$data['lastname1'] = $this->lastname1 ? $this->lastname1 : null;
$data['firstname1'] = $this->firstname1 ? $this->firstname1 : null;
$data['middleInitial1'] = $this->middleInitial1 ? $this->middleInitial1 : null;
$data['lastname2'] = $this->lastname2 ? $this->lastname2 : null;
$data['firstname2'] = $this->firstname2 ? $this->firstname2 : null;
$data['middleInitial2'] = $this->middleInitial2 ? $this->middleInitial2 : null;
$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['cemetery_id'] = $this->cemetery_id ? $this->cemetery_id : null;
if ($this->id) {
$this->update($data);
}
else {
$this->insert($data);
}
}
private function update($data)
{
$zend_db = Database::getConnection();
$zend_db->update('deeds',$data,"id='{$this->id}'");
}
private function insert($data)
{
$zend_db = Database::getConnection();
$zend_db->insert('deeds',$data);
$this->id = $zend_db->lastInsertId('deeds','id');
}
public function delete()
{
if ($this->id) {
$zend_db = Database::getConnection();
$zend_db->delete('deeds','id='.$this->id);
}
}
//----------------------------------------------------------------
// Generic Getters
//----------------------------------------------------------------
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return int
*/
public function getSection_id()
{
return $this->section_id;
}
/**
* @return Section
*/
public function getSection()
{
if ($this->section_id) {
if (!$this->section) {
$this->section = new Section($this->section_id);
}
return $this->section;
}
return null;
}
/**
* @return string
*/
public function getLot()
{
return $this->lot;
}
/**
* @return string
*/
public function getLastname1()
{
return $this->lastname1;
}
/**
* @return string
*/
public function getFirstname1()
{
return $this->firstname1;
}
/**
* @return char
*/
public function getMiddleInitial1()
{
return $this->middleInitial1;
}
/**
* @return string
*/
public function getLastname2()
{
return $this->lastname2;
}
/**
* @return string
*/
public function getFirstname2()
{
return $this->firstname2;
}
/**
* @return char
*/
public function getMiddleInitial2()
{
return $this->middleInitial2;
}
/**
* Returns the date/time in the desired format
*
* Format is specified using PHP's date() syntax
* http://www.php.net/manual/en/function.date.php
* If no format is given, the Date object is returned
*
* @param string $format
* @return string|DateTime
*/
public function getIssueDate($format=null)
{
if ($format && $this->issueDate) {
return $this->issueDate->format($format);
}
else {
return $this->issueDate;
}
}
/**
* @return text
*/
public function getNotes()
{
return $this->notes;
}
/**
* @return char
*/
public function getLot2()
{
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
//----------------------------------------------------------------
/**
* @param int $int
*/
public function setSection_id($int)
{
$this->section = new Section($int);
$this->section_id = $int;
}
/**
* @param Section $section
*/
public function setSection($section)
{
$this->section_id = $section->getId();
$this->section = $section;
}
/**
* @param string $string
*/
public function setLot($string)
{
$this->lot = trim($string);
}
/**
* @param string $string
*/
public function setLastname1($string)
{
$this->lastname1 = trim($string);
}
/**
* @param string $string
*/
public function setFirstname1($string)
{
$this->firstname1 = trim($string);
}
/**
* @param string $string
*/
public function setMiddleInitial1($string)
{
$this->middleInitial1 = trim($string);
}
/**
* @param string $string
*/
public function setLastname2($string)
{
$this->lastname2 = trim($string);
}
/**
* @param string $string
*/
public function setFirstname2($string)
{
$this->firstname2 = trim($string);
}
/**
* @param string $string
*/
public function setMiddleInitial2($string)
{
$this->middleInitial2 = trim($string);
}
/**
* Sets the date
*
* Date arrays should match arrays produced by getdate()
*
* Date string formats should be in something strtotime() understands
* http://www.php.net/manual/en/function.strtotime.php
*
* @param int|string|array $date
*/
public function setIssueDate($date)
{
if ($date) {
$this->issueDate = new Date($date);
}
else {
$this->issueDate = null;
}
}
/**
* @param text $text
*/
public function setNotes($text)
{
$this->notes = $text;
}
/**
* @param char $char
*/
public function setLot2($char)
{
$this->lot2 = $char;
}
/**
* @param int $int
*/
public function setCemetery_id($int)
{
$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
// We recommend adding all your custom code down here at the bottom
//----------------------------------------------------------------
/**
* Returns the full name of the owner
*
* @return string
*/
public function getOwner($number=1)
{
$first = "firstname$number";
$middle = "middleInitial$number";
$last = "lastname$number";
$name = array();
if ($this->$first) {
$name[] = $this->$first;
}
if ($this->$middle) {
$name[] = $this->$middle;
}
if ($this->$last) {
$name[] = $this->$last;
}
return implode(' ',$name);
}
}

View File

@ -1,112 +0,0 @@
<?php
/**
* A collection class for Deed 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 Deed 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/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
*/
class DeedList extends ZendDbResultIterator
{
private $columns = array(
'id','section_id','lot','lot2','cemetery_id',
'lastname1','firstname1','middleInitial1',
'lastname2','firstname2','middleInitial2',
'issueDate','notes'
);
/**
* 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='id',$limit=null,$groupBy=null)
{
$this->select->from('deeds');
// 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
// If you add more joins you probably want to make sure that the
// above foreach only handles fields from the deed table.
$this->select->order($order);
if ($limit) {
$this->select->limit($limit);
}
if ($groupBy) {
$this->select->group($groupBy);
}
$this->populateList();
}
/**
* Hydrates all the Deed 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 Deed
*/
protected function loadResult($key)
{
return new Deed($this->result[$key]);
}
}

@ -1 +0,0 @@
Subproject commit 10d1cd5e1e2266ce2ff660620bfaba2340b400a1

View File

@ -1,43 +0,0 @@
<?php
/**
* @copyright 2009 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param REQUEST cemetery_id
*/
if (!userIsAllowed('Sections')) {
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
header('Location: '.BASE_URL.'/sections');
exit();
}
$cemetery = new Cemetery($_REQUEST['cemetery_id']);
if (isset($_POST['code'])) {
$section = new Section();
$section->setCemetery($cemetery);
$section->setCode($_POST['code']);
$section->setName($_POST['name']);
try {
$section->save();
if (isset($_FILES)) {
if (isset($_FILES['highlight_map']) && $_FILES['highlight_map']['tmp_name']) {
$section->saveMap($_FILES['highlight_map'],'highlight');
}
if (isset($_FILES['zoom_map']) && $_FILES['zoom_map']['tmp_name']) {
$section->saveMap($_FILES['zoom_map'],'zoom');
}
}
header('Location: '.$cemetery->getURL());
exit();
}
catch (Exception $e) {
$_SESSION['errorMessages'][] = $e;
}
}
$template = new Template();
$template->blocks[] = new Block('sections/addSectionForm.inc',array('cemetery'=>$cemetery));
echo $template->render();

View File

@ -1,40 +0,0 @@
<?php
/**
* @copyright 2010 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param GET section_id
*/
if (!userIsAllowed('Sections')) {
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
header('Location: '.BASE_URL.'/sections');
exit();
}
$section = new Section($_REQUEST['section_id']);
if (isset($_POST['section_id'])) {
$section->setCode($_POST['code']);
$section->setName($_POST['name']);
try {
$section->save();
if (isset($_FILES)) {
if (isset($_FILES['highlight_map']) && $_FILES['highlight_map']['tmp_name']) {
$section->saveMap($_FILES['highlight_map'],'highlight');
}
if (isset($_FILES['zoom_map']) && $_FILES['zoom_map']['tmp_name']) {
$section->saveMap($_FILES['zoom_map'],'zoom');
}
}
header('Location: '.$section->getCemetery()->getURL());
exit();
}
catch (Exception $e) {
$_SESSION['errorMessages'][] = $e;
}
}
$template = new Template();
$template->blocks[] = new Block('sections/updateSectionForm.inc',array('section'=>$section));
echo $template->render();

View File

@ -1,7 +1,7 @@
/** /**
* Basic HTML element styles * Basic HTML element styles
*/ */
body { font-family:sans-serif; } body { font-family:sans-serif; font-size:0.75em; }
h2 { font-size:131%; margin:15px 0; color:#036; border-bottom:1px solid #bdbdbd} h2 { font-size:131%; margin:15px 0; color:#036; border-bottom:1px solid #bdbdbd}
h3 { font-size:123.1%; font-weight:bold; margin:.5em 0 .25em 0; } h3 { font-size:123.1%; font-weight:bold; margin:.5em 0 .25em 0; }

View File

@ -6,7 +6,7 @@
*/ */
var COB = { var COB = {
populateSections: function (cemetery_id, select_id, BASE_URL) { populateSections: function (cemetery_id, select_id, BASE_URL) {
var url = BASE_URL + '/cemeteries/viewCemetery.php?format=json;cemetery_id=' + cemetery_id; var url = BASE_URL + '/cemeteries/view?format=json;cemetery_id=' + cemetery_id;
YUI().use('io', 'json', function (Y) { YUI().use('io', 'json', function (Y) {
Y.io(url, { Y.io(url, {

1
public/js/yui3 Submodule

@ -0,0 +1 @@
Subproject commit 94b6faedb488358a92960b12168c32f5608ca55b

View File

@ -10,5 +10,10 @@
?> ?>
</p> </p>
</div> </div>
<script type="text/javascript" src="<?php echo YUI; ?>/yui/yui-min.js"></script> <?php
<script type="text/javascript" src="<?php echo BASE_URI; ?>/js/functions.js"></script> if (isset($this->assets['scripts'])) {
foreach ($this->assets['scripts'] as $url) {
echo "<script type=\"text/javascript\" src=\"$url\"></script>\n";
}
}
?>