Merge branch 'bug_9458' into 3.12-master

This commit is contained in:
Jared Camins-Esakov 2013-03-13 09:07:22 -04:00
commit bbbc5db799
4 changed files with 97 additions and 8 deletions

View file

@ -255,7 +255,7 @@ from C4::Circulation.
=cut
sub GetShelfContents {
my ($shelfnumber, $row_count, $offset, $sortfield) = @_;
my ($shelfnumber, $row_count, $offset, $sortfield, $sort_direction ) = @_;
my $dbh=C4::Context->dbh();
my $sth1 = $dbh->prepare("SELECT count(*) FROM virtualshelfcontents WHERE shelfnumber = ?");
$sth1->execute($shelfnumber);
@ -276,8 +276,8 @@ sub GetShelfContents {
WHERE vc.shelfnumber=? ";
my @params = ($shelfnumber);
if($sortfield) {
$query .= " ORDER BY " . $sortfield;
$query .= " DESC " if ($sortfield eq 'copyrightdate');
$query .= " ORDER BY " . $dbh->quote_identifier( $sortfield );
$query .= " DESC " if ( $sort_direction eq 'desc' );
}
if($row_count){
$query .= " LIMIT ?, ? ";

View file

@ -249,7 +249,13 @@ sub shelfpage {
my $items;
my $tag_quantity;
my $sortfield = ( $sorton ? $sorton : 'title' );
( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield );
$sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
my $direction = $query->param('direction') || 'asc';
$template->param(
sort => $sortfield,
direction => $direction,
);
( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
for my $this_item (@$items) {
my $biblionumber = $this_item->{'biblionumber'};
my $record = GetMarcBiblio($biblionumber);
@ -419,7 +425,7 @@ sub shelfpage {
my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl";
my %qhash = ();
foreach (qw(display viewshelf sortfield)) {
foreach (qw(display viewshelf sortfield sort direction)) {
$qhash{$_} = $query->param($_) if $query->param($_);
}
( scalar keys %qhash ) and $url .= '?' . join '&', map { "$_=$qhash{$_}" } keys %qhash;

View file

@ -204,15 +204,44 @@ function placeHold () {
<span class="clearall"></span></p>
[% END %]
[% IF direction == 'asc' %]
[% SET new_direction = 'desc' %]
[% ELSE %]
[% SET direction = 'desc' %]
[% SET new_direction = 'asc' %]
[% END %]
<div class="pages">[% pagination_bar %]</div>
<table>
<tr>
[% IF ( itemsloop ) %]<th class="checkall">&nbsp;</th>[% END %]
[% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
<th>Title</th>
<th>Author</th>
<th>
<a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=title&direction=[% IF sort != 'title' %]asc[% ELSE %][% new_direction %][% END %]">Title</a>
[% IF sort == 'title' %]
<img src="/intranet-tmpl/prog/img/[% direction %].gif" />
[% ELSE %]
<img src="/intranet-tmpl/prog/img/ascdesc.gif" />
[% END %]
</th>
<th>
<a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=author&direction=[% IF sort != 'author' %]asc[% ELSE %][% new_direction %][% END %]">Author</a>
[% IF sort == 'author' %]
<img src="/intranet-tmpl/prog/img/[% direction %].gif" />
[% ELSE %]
<img src="/intranet-tmpl/prog/img/ascdesc.gif" />
[% END %]
</th>
<th>Date added</th>
<th>Call number</th>
<th>
<a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&sort=itemcallnumber&direction=[% IF sort != 'itemcallnumber' %]asc[% ELSE %][% new_direction %][% END %]">Call number</a>
[% IF sort == 'itemcallnumber' %]
<img src="/intranet-tmpl/prog/img/[% direction %].gif" />
[% ELSE %]
<img src="/intranet-tmpl/prog/img/ascdesc.gif" />
[% END %]
</th>
<th>&nbsp;</th>
</tr>
[% FOREACH itemsloo IN itemsloop %]

View file

@ -188,6 +188,11 @@ $(function() {
alert(alertString2);
}
}
$(document).ready(function() {
$('#sort-submit').hide();
});
//]]>
</script>
</head>
@ -287,6 +292,55 @@ $(function() {
<a class="print" href="opac-shelves.pl" onclick="print(); return false;">Print list</a>
<form action="/cgi-bin/koha/opac-shelves.pl" id="sorting-form">
<input type="hidden" name="viewshelf" value="[% shelfnumber %]" />
<label for="sort">Sort by: </label>
<select name="sort" onchange="$('#sorting-form').submit()">
<option value="">Default sorting</option>
[% IF sort == 'author' %]
<option value="author" selected="selected">Author</option>
[% ELSE %]
<option value="author">Author</option>
[% END %]
[% IF sort == 'title' %]
<option value="title" selected="selected">Title</option>
[% ELSE %]
<option value="title">Title</option>
[% END %]
[% IF sort == 'itemcallnumber' %]
<option value="itemcallnumber" selected="selected">Call number</option>
[% ELSE %]
<option value="itemcallnumber">Call number</option>
[% END %]
[% IF sort == 'copyrightdate' %]
<option value="copyrightdate" selected="selected">Copyright date</option>
[% ELSE %]
<option value="copyrightdate">Copyright date</option>
[% END %]
</select>
<select name="direction" onchange="$('#sorting-form').submit()">
[% IF direction == 'asc' %]
<option value="asc" selected="selected">Ascending</option>
[% ELSE %]
<option value="asc">Ascending</option>
[% END %]
[% IF direction == 'desc' %]
<option value="desc" selected="selected">Descending</option>
[% ELSE %]
<option value="desc">Descending</option>
[% END %]
</select>
<input type="submit" id="sort-submit" value="Resort list" />
</form>
[% IF ( manageshelf ) %] <span class="sep">|</span> <form method="get" action="opac-shelves.pl"><input type="hidden" name="op" value="modif" />
<input type="hidden" name="display" value="viewshelf" />
<input type="hidden" name="shelfnumber" value="[% shelfnumber %]" /> <input type="submit" class="editshelf" value="Edit list" /></form>