--- loncom/cgi/quotacheck.pl 2014/07/31 15:57:24 1.5
+++ loncom/cgi/quotacheck.pl 2014/08/05 19:32:19 1.6
@@ -6,7 +6,7 @@ $|=1;
# requested domain, or current server should belong to requested
# domain.
#
-# $Id: quotacheck.pl,v 1.5 2014/07/31 15:57:24 musolffc Exp $
+# $Id: quotacheck.pl,v 1.6 2014/08/05 19:32:19 musolffc Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -101,6 +101,7 @@ sub main {
$crstype = $params{'type'};
}
if ($params{'fixeddom'}) { $reqdom = $params{'fixeddom'} }
+ unless ($params{'sortby'}) { $params{'sortby'} = 'cdesc'; }
}
if (($reqdom eq '') && ($ENV{'QUERY_STRING'})) {
&LONCAPA::loncgi::cgi_getitems($ENV{'QUERY_STRING'},\%gets);
@@ -246,26 +247,57 @@ sub print_usage {
}
if (@showcourses) {
- print(&Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row()
- .'
'
- .&Apache::lonlocal::mt('Course Type')
- .' ▼ | '
- .''
- .&Apache::lonlocal::mt('Course Title')
- .' ▼ | '
- .''
- .&Apache::lonlocal::mt('Institutional Code')
- .' ▼ | '
- .''
- .&Apache::lonlocal::mt('Quota (MB)')
- .' ▼ | '
- .''
- .&Apache::lonlocal::mt('Usage (MB)')
- .' ▼ | '
- .''
- .&Apache::lonlocal::mt('Percent usage')
- .' ▼ | '
+ # Order in which columns are displayed from left to right
+ my @order = ('quotatype','cdesc','instcode','quota',
+ 'current_disk_usage','percent');
+
+ # Up and down arrows to indicate sort order
+ my @arrows = (' ▲',' ▼','');
+
+ # Default sort order and column title
+ my %columns = (
+ quotatype => {
+ order => 'ascending',
+ text => &Apache::lonlocal::mt('Course Type'),
+ },
+ cdesc => {
+ order => 'ascending',
+ text => &Apache::lonlocal::mt('Course Title'),
+ },
+ instcode => {
+ order => 'ascending',
+ text => &Apache::lonlocal::mt('Institutional Code'),
+ },
+ quota => {
+ order => 'descending',
+ text => &Apache::lonlocal::mt('Quota (MB)'),
+ },
+ current_disk_usage => {
+ order => 'descending',
+ text => &Apache::lonlocal::mt('Usage (MB)'),
+ },
+ percent => {
+ order => 'descending',
+ text => &Apache::lonlocal::mt('Percent usage'),
+ },
+ );
+
+ # Print column headers
+ my $output = '';
+ foreach my $key (@order) {
+ my $idx;
+ # Append an up or down arrow to sorted column
+ if ($sortby eq $key) {
+ $idx = ($columns{$key}{order} eq 'ascending') ? 0:1;
+ if ($sortorder eq 'rev') { $idx ++; }
+ $idx = $idx%2;
+ } else { $idx = 2; } # No arrow if column not sorted
+ $output .= ''.$columns{$key}{text}
+ .$arrows[$idx].' | ';
+ }
+ print(&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row().$output
.&Apache::loncommon::end_data_table_header_row());
my $usagehash = {}; # Sortable hash of courses