The interment list is now sortable

git-svn-id: https://rosehill.googlecode.com/svn/branches/php@26 100bd78a-fc82-11de-b5bc-ffd2847a4b57
This commit is contained in:
inghamn 2010-01-06 15:34:36 +00:00
parent 4f5971b522
commit 31dad3a967
4 changed files with 32 additions and 10 deletions

View File

@ -4,7 +4,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov> * @author Cliff Ingham <inghamn@bloomington.in.gov>
* @param IntermentList $this->intermentList * @param IntermentList $this->intermentList
* @param GET sort
*/ */
$previousSort = isset($_GET['sort']) ? $_GET['sort'] : 'deceasedDate';
$url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
?> ?>
<div class="interfaceBox"> <div class="interfaceBox">
<h1> <h1>
@ -22,9 +25,21 @@
<table> <table>
<thead> <thead>
<tr><th></th> <tr><th></th>
<th>Last Name</th> <th><?php
<th>First Name</th> $url->sort = $previousSort=='lastname' ? 'lastname desc' : 'lastname';
<th>Date of Death</th> echo "<a href=\"$url\" class=\"sorting\">Last Name</a>";
?>
</th>
<th><?php
$url->sort = $previousSort=='firstname' ? 'firstname desc' : 'firstname';
echo "<a href=\"$url\" class=\"sorting\">First Name</a>";
?>
</th>
<th><?php
$url->sort = $previousSort=='deceasedDate' ? 'deceasedDate desc' : 'deceasedDate';
echo "<a href=\"$url\" class=\"sorting\">Date of Death</a>";
?>
</th>
<th>Cemetery</th> <th>Cemetery</th>
<th>Section &amp; Lot</th> <th>Section &amp; Lot</th>
</tr> </tr>

View File

@ -28,11 +28,16 @@ class IntermentList extends ZendDbResultIterator
* @param int $itemsPerPage Turns on Pagination * @param int $itemsPerPage Turns on Pagination
* @param int $currentPage * @param int $currentPage
*/ */
public function __construct($fields=null,$itemsPerPage=null,$currentPage=null) public function __construct($fields=null,$order=null,$itemsPerPage=null,$currentPage=null)
{ {
parent::__construct($itemsPerPage,$currentPage); parent::__construct($itemsPerPage,$currentPage);
if (is_array($fields)) { if (is_array($fields)) {
$this->find($fields); if ($order) {
$this->find($fields,$order);
}
else {
$this->find($fields);
}
} }
} }
@ -44,7 +49,7 @@ class IntermentList extends ZendDbResultIterator
* @param int $limit * @param int $limit
* @param string|array $groupBy Multi-column group by should be given as an array * @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) public function find($fields=null,$order='deceasedDate',$limit=null,$groupBy=null)
{ {
$this->select->from('interments'); $this->select->from('interments');

View File

@ -35,7 +35,8 @@ foreach ($_GET as $field=>$value) {
} }
if (count($search)) { if (count($search)) {
$intermentList = new IntermentList($search,20,$currentPage); $order = isset($_GET['sort']) ? $_GET['sort'] : null;
$intermentList = new IntermentList($search,$order,20,$currentPage);
} }

View File

@ -14,8 +14,7 @@
.pageNavigation ul{ display:inline; } .pageNavigation ul{ display:inline; }
.pageNavigation li { padding-left:5px; } .pageNavigation li { padding-left:5px; }
.searchInterment th { text-align:left; width:75px; }
.searchInterment th {text-align:left; width:75px; }
table { margin:8px 0; overflow:auto; } table { margin:8px 0; overflow:auto; }
tr { } tr { }
@ -30,4 +29,6 @@ tbody th {
height:8pt; padding:4px 4px 2px 2px; height:8pt; padding:4px 4px 2px 2px;
} }
th a:link,th a:visited { color:#3366cc; background-color:inherit; } th a:link,th a:visited { color:#3366cc; background-color:inherit; }
form table { border:none; } form table { border:none; }
a.sorting { }