Adding sortable columns to tables

This commit is contained in:
jacob 2010-03-30 21:59:04 +00:00
parent ac10772214
commit b632b6c932
8 changed files with 34 additions and 29 deletions

View File

@ -35,6 +35,7 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
?>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Purpose")?></th>
<th><?=i18n("Goal")?></th>
@ -42,6 +43,7 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Deadline")?></th>
</tr>
</thead>
<?
while($r=mysql_fetch_object($q)) {
//lookup all donations made towards this goal
@ -67,6 +69,7 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
<h3><?=i18n("Current Appeals")?></h3>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Name")?></th>
<th><?=i18n("Type")?></th>
@ -77,7 +80,7 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Purpose")?></th>
</tr>
</thead>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
@ -109,6 +112,7 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
?>
</tr>
</table>
<script type="text/javascript"> $('.tableview').tablesorter();</script>
<br />
<form id="thankyouform" method="post" action="fundraising.php">

View File

@ -78,6 +78,7 @@ switch($_GET['action']){
echo i18n("Select an appeal");
?>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Name")?></th>
<th><?=i18n("Type")?></th>
@ -88,7 +89,7 @@ switch($_GET['action']){
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Purpose")?></th>
</tr>
</thead>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
@ -119,6 +120,7 @@ switch($_GET['action']){
}
?>
</table>
<script type="text/javascript"> $('.tableview').tablesorter();</script>
<br />
<?
exit;

View File

@ -44,7 +44,7 @@ $action=$_GET['action'];
switch($action) {
case 'load_row':
$id = intval($_GET['id']);
$q = list_query($year, '', '', $id);
$q = list_query($year, '', $id);
$r = mysql_fetch_object($q);
print_row($r);
exit;
@ -337,22 +337,22 @@ $(document).ready(function() {
if($showstatus) $wherestatus="AND status='$showstatus' ";
else $wherestatus="";
$q = list_query($year, $wherestatus, $_GET['sort'], false);
$q = list_query($year, $wherestatus, false);
echo "<table id=\"registration_list\" class=\"tableview\">";
echo "<tr>";
echo "<thead><tr>";
if($showstatus) $stat="&showstatus=".$showstatus;
echo "<th><a href=\"registration_list.php?sort=status$stat\">".i18n("Status")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=email\">".i18n("Email Address")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=num$stat\">".i18n("Reg Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=projnum$stat\">".i18n("Proj Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=title$stat\">".i18n("Project Title")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=cat$stat\">".i18n("Age Category")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=div$stat\">".i18n("Division")."</a></th>";
echo "<th>".i18n("Status")."</th>";
echo "<th>".i18n("Email Address")."</th>";
echo "<th>".i18n("Reg Num")."</th>";
echo "<th>".i18n("Proj Num")."</th>";
echo "<th>".i18n("Project Title")."</th>";
echo "<th>".i18n("Age Category")."</th>";
echo "<th>".i18n("Division")."</th>";
echo "<th>".i18n("School(s)")."</th>";
echo "<th>".i18n("Student(s)")."</th>";
echo "<th>".i18n("Action")."</th>";
echo "</tr>";
echo "</tr></thead>";
while($r=mysql_fetch_object($q)) {
echo "<tr id=\"row_{$r->reg_id}\">";
@ -367,7 +367,7 @@ echo "<br/><br/>The statistics have moved here: <a href=\"registration_stats.php
send_footer();
/* Now some helper fucntions we call more than once */
function list_query($year, $wherestatus, $sort, $reg_id)
function list_query($year, $wherestatus, $reg_id)
{
global $auth_type;
@ -380,16 +380,6 @@ function list_query($year, $wherestatus, $sort, $reg_id)
$fair = "AND projects.fairs_id='{$_SESSION['fairs_id']}'";
}
switch($sort) {
case 'status': $ORDERBY="registrations.status DESC, projects.title"; break;
case 'num': $ORDERBY="registrations.num"; break;
case 'projnum': $ORDERBY="projects.projectsort, projects.projectnumber"; break;
case 'title': $ORDERBY="projects.title, registrations.status DESC"; break;
case 'cat': $ORDERBY="projects.projectcategories_id, projects.title"; break;
case 'div': $ORDERBY="projects.projectdivisions_id, projects.title"; break;
default: $ORDERBY="registrations.status DESC, projects.title"; break;
}
$q=mysql_query("SELECT registrations.id AS reg_id,
registrations.num AS reg_num,
registrations.status,
@ -407,7 +397,7 @@ function list_query($year, $wherestatus, $sort, $reg_id)
$wherestatus
$reg $fair
ORDER BY
$ORDERBY
registrations.status DESC, projects.title
");
echo mysql_error();
return $q;

View File

@ -95,13 +95,13 @@
echo "<form method=\"post\" action=\"registration_webconsent.php\">";
echo "<table class=\"tableview\">";
echo "<tr>";
echo "<thead><tr>";
echo " <th>".i18n("Proj #")."</th>";
echo " <th>".i18n("Student Name")."</th>";
echo " <th>".i18n("First")."</th>";
echo " <th>".i18n("Last")."</th>";
echo " <th>".i18n("Photo")."</th>";
echo "</tr>";
echo "</tr></thead>";
while($r=mysql_fetch_object($sq))
{
echo "<tr>";

View File

@ -328,7 +328,7 @@
echo "<a onclick=\"return confirmClick('".i18n("Are you sure you want to remove all access codes from all schools?")."')\" href=\"schools.php?action=clearaccesscodes\">".i18n("Remove Access Codes from all schools")."</a>\n";
echo "<br />";
echo "<table class=\"tableview\">";
echo "<tr>";
echo "<thead><tr>";
echo " <th>".i18n("School")."</th>";
echo " <th>".i18n("Address")."</th>";
echo " <th>".i18n("Phone")."</th>";
@ -337,7 +337,7 @@
echo " <th>".i18n("Reg Pass")."</th>";
echo " <th>".i18n("Access Code")."</th>";
echo " <th>".i18n("Action")."</th>";
echo "</tr>\n";
echo "</tr></thead>\n";
$q=mysql_query("SELECT * FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER BY school");
while($r=mysql_fetch_object($q))

View File

@ -210,6 +210,7 @@ function neweditor()
echo i18n("Listing %1 people total. See the bottom for breakdown of by complete status",array($num));
echo mysql_error();
echo "<thead>";
echo "<tr>";
echo " <th>".i18n("Name")."</th>";
echo " <th>".i18n("Email Address")."</th>";
@ -219,6 +220,7 @@ function neweditor()
echo " <th>".i18n("Complete")."</th>";
echo " <th>".i18n("Actions")."</th>";
echo "</tr>";
echo "</thead>";
$completeyes=0;
$completeno=0;
while($r=mysql_fetch_assoc($q))

View File

@ -393,6 +393,12 @@ function send_header($title="", $nav=null, $icon=null, $titletranslated=false)
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/sfiab.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/tablesorter/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.tableview').tablesorter();
});
</script>
<?
//if we're under /admin or /config we also want the translation editor
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")

View File

@ -41,6 +41,7 @@ input {
/*background-color: #1B86B7; */
background-color: #1B86B7;
padding: 3px;
cursor: pointer;
}