Find form now autopopulates the section drop down after you choose the cemetery
git-svn-id: https://rosehill.googlecode.com/svn/branches/php@28 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
parent
83af615ad8
commit
4cb6876aed
|
@ -15,7 +15,7 @@ $return_url = isset($this->return_url) ? $this->return_url : BASE_URL.'/intermen
|
||||||
<table>
|
<table>
|
||||||
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
|
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
|
||||||
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
|
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
|
||||||
onchange="populateSections(this.options[this.selectedIndex].value)">
|
onchange="COB.populateSections(this.options[this.selectedIndex].value,'interment-section_id','<?php echo BASE_URL; ?>')">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php
|
<?php
|
||||||
$list = new CemeteryList();
|
$list = new CemeteryList();
|
||||||
|
@ -90,27 +90,3 @@ $return_url = isset($this->return_url) ? $this->return_url : BASE_URL.'/intermen
|
||||||
</button>
|
</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</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>
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?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
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
||||||
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
||||||
*/
|
*/
|
||||||
|
@ -18,31 +18,44 @@
|
||||||
value="<?php echo isset($_GET['firstname']) ? View::escape($_GET['firstname']) : ''; ?>" />
|
value="<?php echo isset($_GET['firstname']) ? View::escape($_GET['firstname']) : ''; ?>" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<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
|
<?php
|
||||||
$cemeteries = new CemeteryList();
|
$cemeteries = new CemeteryList();
|
||||||
$cemeteries->find();
|
$cemeteries->find();
|
||||||
foreach ($cemeteries as $cemetery) {
|
foreach ($cemeteries as $cemetery) {
|
||||||
$name = View::escape($cemetery->getName());
|
$name = View::escape($cemetery->getName());
|
||||||
$fieldname = 'sections_'.$cemetery->getId();
|
$selected = (isset($_GET['cemetery_id']) && $_GET['cemetery_id']==$cemetery->getId())
|
||||||
echo "
|
|
||||||
<tr><td><label for=\"\">$name Sections</label></td>
|
|
||||||
<td><select name=\"$fieldname\">
|
|
||||||
<option value=\"\">All</option>
|
|
||||||
";
|
|
||||||
foreach ($cemetery->getSections() as $section) {
|
|
||||||
$selected = (isset($_GET[$fieldname]) && $_GET[$fieldname]==$section->getId())
|
|
||||||
? 'selected="selected"'
|
? 'selected="selected"'
|
||||||
: '';
|
: '';
|
||||||
$name = View::escape($section);
|
echo "<option value=\"{$cemetery->getId()}\" $selected>$name</option>";
|
||||||
echo "<option value=\"{$section->getId()}\" $selected>$name</option>";
|
|
||||||
}
|
}
|
||||||
echo "
|
?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
<tr><td><label for="section_id">Section</label></td>
|
||||||
|
<td><select name="section_id" id="section_id">
|
||||||
|
<option></option>
|
||||||
|
<?php
|
||||||
|
if (isset($_GET['cemetery_id'])) {
|
||||||
|
$sections = new SectionList(array('cemetery_id'=>$_GET['cemetery_id']));
|
||||||
|
foreach ($sections as $section) {
|
||||||
|
$name = $section->getName()
|
||||||
|
? View::escape($section->getName())
|
||||||
|
: View::escape($section->getCode());
|
||||||
|
$selected = isset($_GET['section_id']) && $section->getId()==$_GET['section_id']
|
||||||
|
? 'selected="selected"'
|
||||||
|
: '';
|
||||||
|
echo "<option value=\"{$section->getId()}\" $selected>$name</option>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" class="search">Search</button>
|
<button type="submit" class="search">Search</button>
|
||||||
|
|
|
@ -16,7 +16,7 @@ $return_url = $this->return_url ? $this->return_url : BASE_URL.'/interments';
|
||||||
<table>
|
<table>
|
||||||
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
|
<tr><td><label for="interment-cemetery_id" class="required">Cemetery</label></td>
|
||||||
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
|
<td><select name="interment[cemetery_id]" id="interment-cemetery_id"
|
||||||
onchange="populateSections(this.options[this.selectedIndex].value)">
|
onchange="COB.populateSections(this.options[this.selectedIndex].value,'interment-section_id','<?php echo BASE_URL; ?>')">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php
|
<?php
|
||||||
$list = new CemeteryList();
|
$list = new CemeteryList();
|
||||||
|
@ -128,27 +128,3 @@ $return_url = $this->return_url ? $this->return_url : BASE_URL.'/interments';
|
||||||
</button>
|
</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</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>
|
|
||||||
|
|
|
@ -4,54 +4,47 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
||||||
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
||||||
*/
|
*/
|
||||||
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
$knownFields = array('lastname','firstname','cemetery_id','section_id');
|
||||||
|
|
||||||
$knownFields = array('lastname','firstname');
|
|
||||||
$cemeteries = new CemeteryList();
|
|
||||||
$cemeteries->find();
|
|
||||||
foreach ($cemeteries as $cemetery) {
|
|
||||||
$knownFields[] = 'section_'.$cemetery->getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$search = array();
|
$search = array();
|
||||||
foreach ($_GET as $field=>$value) {
|
foreach ($_GET as $field=>$value) {
|
||||||
if ($value) {
|
if ($value) {
|
||||||
if (false !== strpos($field,'section')) {
|
|
||||||
try {
|
|
||||||
$section = new Section($value);
|
|
||||||
$search['section_id'] = $section->getId();
|
|
||||||
}
|
|
||||||
catch (Exception $e) {
|
|
||||||
// Just ignore any unknown sections
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (in_array($field,$knownFields)) {
|
if (in_array($field,$knownFields)) {
|
||||||
$search[$field] = $value;
|
$search[$field] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (count($search)) {
|
|
||||||
$order = isset($_GET['sort']) ? $_GET['sort'] : null;
|
|
||||||
$intermentList = new IntermentList($search,$order,50,$currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$template = new Template();
|
|
||||||
|
// Only the HTML version will include the findForm, addForm, and about page.
|
||||||
|
$template = isset($_GET['format']) ? new Template('default',$_GET['format']) : new Template();
|
||||||
|
if ($template->outputFormat=='html') {
|
||||||
$template->blocks[] = new Block('interments/findForm.inc');
|
$template->blocks[] = new Block('interments/findForm.inc');
|
||||||
if (isset($intermentList)) {
|
|
||||||
$template->blocks[] = new Block('interments/intermentList.inc',
|
if (userIsAllowed('Interments') && !count($search)) {
|
||||||
array('intermentList'=>$intermentList));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (userIsAllowed('Interments')) {
|
|
||||||
$return_url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
|
$return_url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
|
||||||
$template->blocks[] = new Block('interments/addIntermentForm.inc',
|
$template->blocks[] = new Block('interments/addIntermentForm.inc',
|
||||||
array('return_url'=>$return_url));
|
array('return_url'=>$return_url));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$template->blocks['panel-one'][] = new Block('about.inc');
|
$template->blocks['panel-one'][] = new Block('about.inc');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// All output formats will include the list of interments
|
||||||
|
if (count($search)) {
|
||||||
|
$order = isset($_GET['sort']) ? $_GET['sort'] : null;
|
||||||
|
if ($template->outputFormat=='html') {
|
||||||
|
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||||
|
$intermentList = new IntermentList($search,$order,50,$currentPage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$intermentList = new IntermentList();
|
||||||
|
$intermentList->find();
|
||||||
|
}
|
||||||
|
$template->blocks[] = new Block('interments/intermentList.inc',
|
||||||
|
array('intermentList'=>$intermentList));
|
||||||
|
}
|
||||||
|
|
||||||
echo $template->render();
|
echo $template->render();
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* @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>
|
||||||
|
*/
|
||||||
|
var COB = {};
|
||||||
|
|
||||||
|
COB.populateSections = function(cemetery_id,select_id,BASE_URL) {
|
||||||
|
var url = BASE_URL + '/cemeteries/viewCemetery.php?format=json;cemetery_id=' + cemetery_id;
|
||||||
|
|
||||||
|
YAHOO.util.Connect.asyncRequest('GET',url,{
|
||||||
|
success : function (o) {
|
||||||
|
var select = document.getElementById(select_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) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -15,5 +15,7 @@
|
||||||
<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/connection/connection-min.js"></script>
|
||||||
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/datasource/datasource-min.js"></script>
|
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/datasource/datasource-min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="<?php echo BASE_URL; ?>/js/functions.js"></script>
|
||||||
|
|
||||||
<title>Cemeteries</title>
|
<title>Cemeteries</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue