Interment list now has 50 items per page, and is sortable. Notes are displayed if you're logged in. Add/Update interments are working again

git-svn-id: https://rosehill.googlecode.com/svn/branches/php@27 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
inghamn 2010-01-06 16:16:21 +00:00
parent 31dad3a967
commit 83af615ad8
14 changed files with 249 additions and 98 deletions

View File

@ -1,41 +1,60 @@
<?php
/**
* @copyright 2009 City of Bloomington, Indiana
* @copyright 2009-2010 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 URL $this->return_url
*/
$return_url = isset($this->return_url) ? $this->return_url : BASE_URL.'/interments';
?>
<h1>Add Interment</h1>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<form method="post" action="<?php echo BASE_URL; ?>/interments/addInterment.php">
<fieldset><legend>Interment Info</legend>
<table>
<input type="hidden" name="return_url" value="<?php echo $return_url; ?>" />
<tr><td><label for="interment-section">Section</label></td>
<td><input name="interment[section]" id="interment-section"
size="5" maxlength="5" />
<table>
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
onchange="populateSections(this.options[this.selectedIndex].value)">
<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="interment-section_id">Section</label></td>
<td><select name="interment[section_id]" id="interment-section_id">
<option></option>
</select>
<label for="interment-lot">Lot</label>
<input name="interment[lot]" id="interment-lot"
size="5" maxlength="5" />
<input name="interment[lot]" id="interment-lot" size="5" maxlength="5" />
</td>
</tr>
<tr><td><label for="interment-book">Book</label></td>
<td><input name="interment[book]" id="interment-book"
size="4" maxlength="4" />
<td><input name="interment[book]" id="interment-book" size="4" maxlength="4" />
<label for="interment-pageNumber">Page</label>
<input name="interment[pageNumber]" id="interment-pageNumber"
size="5" maxlength="5" />
<input name="interment[pageNumber]" id="interment-pageNumber" size="5" maxlength="5" />
</td>
</tr>
<tr><td><label for="interment-firstname">Name</label></td>
<td><label for="interment-firstname">First</label>
<input name="interment[firstname]" id="interment-firstname" />
<label for="interment-middleInitial">MI</label>
<input name="interment[middleInitial]" id="interment-middleInitial" />
<label for="interment-lastname">Last</label>
<input name="interment[lastname]" id="interment-lastname" />
<tr><td><label for="interment-firstname">First</label></td>
<td><input name="interment[firstname]" id="interment-firstname" /></td>
</tr>
<tr><td><label for="interment-middleInitial">MI</label></td>
<td><input name="interment[middleInitial]" id="interment-middleInitial" size="1" maxlength="1" />
</td>
</tr>
<tr><td><label for="interment-lastname">Last</label></td>
<td><input name="interment[lastname]" id="interment-lastname" /></td>
</tr>
<tr><td><label for="interment-birthPlace">Place of Birth</label></td>
@ -60,33 +79,38 @@
</select>
</td>
</tr>
<tr><td><label for="interment-cemetery_id">Cemetery</label></td>
<td><select name="interment[cemetery_id]" id="interment-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>
<tr><td><label for="interment-notes">Notes</label></td>
<td><textarea name="interment[notes]" id="interment-notes" rows="3" cols="60"></textarea>
</td>
</tr>
</table>
<div><label for="interment-notes">Notes</label></div>
<div><textarea name="interment[notes]" id="interment-notes" rows="3" cols="60"></textarea></div>
<button type="submit" class="submit">Submit</button>
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/interments';">
<button type="button" class="cancel" onclick="document.location.href='<?php echo $return_url; ?>';">
Cancel
</button>
</fieldset>
</form>
<script type="text/javascript">
function populateSections(cemetery_id) {
var url = '<?php echo BASE_URL; ?>/cemeteries/viewCemetery.php?format=json;cemetery_id=' + cemetery_id;
YAHOO.util.Connect.asyncRequest('GET',url,{
success : function (o) {
var select = document.getElementById('interment-section_id');
select.innerHTML = '';
select.appendChild(document.createElement('option'));
var sections = YAHOO.lang.JSON.parse(o.responseText).sections
for (i in sections) {
var option = document.createElement('option');
option.setAttribute('value',sections[i].id);
option.appendChild(document.createTextNode(sections[i].code));
select.appendChild(option);
}
},
failure : function (o) {
}
});
}
</script>

View File

@ -8,13 +8,16 @@
*/
$previousSort = isset($_GET['sort']) ? $_GET['sort'] : 'deceasedDate';
$url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$return_url = $url->__toString();
?>
<div class="interfaceBox">
<h1>
<?php
if (userIsAllowed('Interments')) {
$addURL = new URL(BASE_URL.'/interments/addInterment.php');
$addURL->return_url = $return_url;
echo "
<button type=\"button\" class=\"add\" onclick=\"document.location.href='".BASE_URL."/interments/addInterment.php';\">
<button type=\"button\" class=\"add\" onclick=\"document.location.href='$addURL';\">
Add
</button>
";
@ -49,10 +52,11 @@ $url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
foreach ($this->intermentList as $interment) {
$editButton = '';
if (userIsAllowed('Interments')) {
$url = new URL(BASE_URL.'/interments/updateInterment.php');
$url->interment_id = $interment->getId();
$editURL = new URL(BASE_URL.'/interments/updateInterment.php');
$editURL->interment_id = $interment->getId();
$editURL->return_url = $return_url;
$editButton = "
<button type=\"button\" class=\"edit\" onclick=\"document.location.href='$url';\">
<button type=\"button\" class=\"edit\" onclick=\"document.location.href='$editURL';\">
Edit
</button>
";

View File

@ -34,6 +34,7 @@ if ($zoomed_map) {
}
else {
echo "
<h2>Close-up of Section</h2>
<p>
We do not have information for this burial or we do not have the section currently mapped.
</p>

View File

@ -4,18 +4,50 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param Interment $this->interment
* @param string $this->return_url
*/
$return_url = $this->return_url ? $this->return_url : BASE_URL.'/interments';
?>
<h1>Update Interment</h1>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<form method="post" action="<?php echo BASE_URL; ?>/interments/updateInterment.php">
<fieldset><legend>Interment Info</legend>
<input name="interment_id" type="hidden" value="<?php echo $this->interment->getId(); ?>" />
<input name="return_url" type="hidden" value="<?php echo $return_url; ?>" />
<table>
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
onchange="populateSections(this.options[this.selectedIndex].value)">
<option></option>
<?php
$list = new CemeteryList();
$list->find();
foreach ($list as $cemetery) {
$name = View::escape($cemetery->getName());
$selected = $this->interment->getCemetery_id()==$cemetery->getId()
? 'selected="selected"'
: '';
echo "<option value=\"{$cemetery->getId()}\" $selected>$name</option>";
}
?>
</select>
</td>
</tr>
<tr><td><label for="interment-section">Section</label></td>
<td><input name="interment[section]" id="interment-section"
size="5" maxlength="5"
value="<?php echo View::escape($this->interment->getSection()); ?>" />
<tr><td><label for="interment-section_id">Section</label></td>
<td><select name="interment[section_id]" id="interment-section_id">
<option></option>
<?php
if ($this->interment->getSection_id()) {
foreach ($this->interment->getCemetery()->getSections() as $section) {
$name = $section->getName() ? View::escape($section->getName()) : View::escape($section->getCode());
$selected = $section->getId()==$this->interment->getSection_id()
? 'selected="selected"'
: '';
echo "<option value=\"{$section->getId()}\" $selected>$name</option>";
}
}
?>
</select>
<label for="interment-lot">Lot</label>
<input name="interment[lot]" id="interment-lot"
size="5" maxlength="5"
@ -33,15 +65,20 @@
value="<?php echo View::escape($this->interment->getPageNumber()); ?>" />
</td>
</tr>
<tr><td><label for="interment-firstname">Name</label></td>
<td><label for="interment-firstname">First</label>
<input name="interment[firstname]" id="interment-firstname"
<tr><td><label for="interment-firstname">First</label></td>
<td><input name="interment[firstname]" id="interment-firstname"
value="<?php echo View::escape($this->interment->getFirstname()); ?>" />
<label for="interment-middleInitial">MI</label>
<input name="interment[middleInitial]" id="interment-middleInitial"
</td>
</tr>
<tr><td><label for="interment-middleInitial">MI</label></td>
<td><input name="interment[middleInitial]" id="interment-middleInitial"
size="1" maxlength="1"
value="<?php echo View::escape($this->interment->getMiddleInitial()); ?>" />
<label for="interment-lastname">Last</label>
<input name="interment[lastname]" id="interment-lastname"
</td>
</tr>
<tr><td><label for="interment-lastname">Last</label></td>
<td><input name="interment[lastname]" id="interment-lastname"
value="<?php echo View::escape($this->interment->getLastname()); ?>" />
</td>
</tr>
@ -78,35 +115,40 @@
</select>
</td>
</tr>
<tr><td><label for="interment-cemetery_id">Cemetery</label></td>
<td><select name="interment[cemetery_id]" id="interment-cemetery_id">
<option></option>
<?php
$list = new CemeteryList();
$list->find();
foreach ($list as $cemetery) {
$name = View::escape($cemetery->getName());
$selected = $this->interment->getCemetery_id()==$cemetery->getId()
? 'selected="selected"'
: '';
echo "<option value=\"{$cemetery->getId()}\" $selected>$name</option>";
}
?>
</select>
</td>
</tr>
<tr><td><label for="interment-notes">Notes</label></td>
<td><textarea name="interment[notes]" id="interment-notes" rows="3" cols="60"><?php echo View::escape($this->interment->getNotes()); ?></textarea>
</td>
</tr>
</table>
<div><label for="interment-notes">Notes</label></div>
<div>
<textarea name="interment[notes]" id="interment-notes" rows="3" cols="60"><?php echo View::escape($this->interment->getNotes()); ?></textarea>
</div>
<button type="submit" class="submit">Submit</button>
<button type="button" class="cancel" onclick="document.location.href='<?php echo BASE_URL; ?>/interments';">
<button type="button" class="cancel" onclick="document.location.href='<?php echo $return_url; ?>';">
Cancel
</button>
</fieldset>
</form>
<script type="text/javascript">
function populateSections(cemetery_id) {
var url = '<?php echo BASE_URL; ?>/cemeteries/viewCemetery.php?format=json;cemetery_id=' + cemetery_id;
YAHOO.util.Connect.asyncRequest('GET',url,{
success : function (o) {
var select = document.getElementById('interment-section_id');
select.innerHTML = '';
select.appendChild(document.createElement('option'));
var sections = YAHOO.lang.JSON.parse(o.responseText).sections
for (i in sections) {
var option = document.createElement('option');
option.setAttribute('value',sections[i].id);
option.appendChild(document.createTextNode(sections[i].code));
select.appendChild(option);
}
},
failure : function (o) {
}
});
}
</script>

View File

@ -0,0 +1,22 @@
<?php
/**
* @copyright 2010 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
*/
$sections = array();
foreach ($this->cemetery->getSections() as $section) {
$code = addslashes($section->getCode());
$name = addslashes($section->getName());
$sections[] = "{\"id\":{$section->getId()},\"code\":\"$code\",\"name\":\"$name\"}";
}
$sections = implode(',',$sections);
$name = addslashes($this->cemetery->getName());
echo "
{ \"id\":{$this->cemetery->getId()},
\"name\":\"$name\",
\"sections\":[$sections]
}
";

View File

@ -0,0 +1,27 @@
<?php
/**
* @copyright 2010 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
*/
$name = View::escape($this->cemetery->getName());
echo "
<cemetery id=\"{$this->cemetery->getId()}\">
<name>$name</name>
<sections>
";
foreach ($this->cemetery->getSections() as $section) {
$code = View::escape($section->getCode());
$name = View::escape($section->getName());
echo "
<section id=\"{$section->getId()}\">
<code>$code</code>
<name>$name</name>
</section>
";
}
echo "
</sections>
</cemetery>
";

View File

@ -77,9 +77,10 @@ class Interment
public function validate()
{
// Check for required fields here. Throw an exception if anything is missing.
if (!$this->cemetery_id) {
throw new Exception('missingRequiredFields');
}
}
/**
* Saves this record back to the database
*/
@ -100,7 +101,7 @@ class Interment
$data['lastResidence'] = $this->lastResidence ? $this->lastResidence : null;
$data['age'] = $this->age ? $this->age : null;
$data['sex'] = $this->sex ? $this->sex : null;
$data['cemetery_id'] = $this->cemetery_id ? $this->cemetery_id : null;
$data['cemetery_id'] = $this->cemetery_id;
$data['notes'] = $this->notes ? $this->notes : null;
$data['lot2'] = $this->lot2 ? $this->lot2 : null;

View File

@ -18,6 +18,13 @@ catch (Exception $e) {
exit();
}
$template = new Template();
if (isset($_GET['format'])) {
$template = new Template('default',$_GET['format']);
}
else {
$template = new Template();
}
$template->blocks[] = new Block('cemeteries/cemeteryInfo.inc',array('cemetery'=>$cemetery));
echo $template->render();

View File

@ -3,14 +3,16 @@
* @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 REQUEST return_url
*/
if (!userIsAllowed('Interments')) {
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
header('Location: '.BASE_URL.'/interments');
exit();
}
$return_url = isset($_REQUEST['return_url']) ? $_REQUEST['return_url'] : BASE_URL.'/interments';
if (isset($_POST['interment'])) {
$interment = new Interment();
foreach ($_POST['interment'] as $field=>$value) {
@ -20,7 +22,7 @@ if (isset($_POST['interment'])) {
try {
$interment->save();
header('Location: '.BASE_URL.'/interments');
header("Location: $return_url");
exit();
}
catch(Exception $e) {
@ -29,5 +31,6 @@ if (isset($_POST['interment'])) {
}
$template = new Template();
$template->blocks[] = new Block('interments/addIntermentForm.inc');
$template->blocks[] = new Block('interments/addIntermentForm.inc',
array('return_url'=>$return_url));
echo $template->render();

View File

@ -36,7 +36,7 @@ foreach ($_GET as $field=>$value) {
if (count($search)) {
$order = isset($_GET['sort']) ? $_GET['sort'] : null;
$intermentList = new IntermentList($search,$order,20,$currentPage);
$intermentList = new IntermentList($search,$order,50,$currentPage);
}
@ -46,5 +46,12 @@ if (isset($intermentList)) {
$template->blocks[] = new Block('interments/intermentList.inc',
array('intermentList'=>$intermentList));
}
else {
if (userIsAllowed('Interments')) {
$return_url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$template->blocks[] = new Block('interments/addIntermentForm.inc',
array('return_url'=>$return_url));
}
}
$template->blocks['panel-one'][] = new Block('about.inc');
echo $template->render();

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 REQUEST return_url
*/
if (!userIsAllowed('Interments')) {
$_SESSION['errorMessages'][] = new Exception('noAccessAllowed');
@ -10,6 +11,8 @@ if (!userIsAllowed('Interments')) {
exit();
}
$return_url = isset($_REQUEST['return_url']) ? $_REQUEST['return_url'] : BASE_URL.'/interments';
$interment = new Interment($_REQUEST['interment_id']);
if (isset($_POST['interment'])) {
foreach ($_POST['interment'] as $field=>$value) {
@ -19,7 +22,7 @@ if (isset($_POST['interment'])) {
try {
$interment->save();
header('Location: '.BASE_URL.'/interments');
header("Location: $return_url");
exit();
}
catch (Exception $e) {
@ -28,5 +31,6 @@ if (isset($_POST['interment'])) {
}
$template = new Template();
$template->blocks[] = new Block('interments/updateIntermentForm.inc',array('interment'=>$interment));
$template->blocks[] = new Block('interments/updateIntermentForm.inc',
array('interment'=>$interment,'return_url'=>$return_url));
echo $template->render();

View File

@ -9,7 +9,11 @@
@import url('/skins/origin-external/screen.css');
@import url('<?php echo BASE_URL; ?>/skins/local/screen.css');
</style>
<script type="text/javascript" src="<?php echo BASE_URL; ?>/js/functions.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/event/event-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/json/json-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/connection/connection-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/datasource/datasource-min.js"></script>
<title>New Application</title>
<title>Cemeteries</title>
</head>

View File

@ -0,0 +1,2 @@
<?php
echo $this->includeBlocks();

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<?php
echo $this->includeBlocks();