my $member = GetMember( 'borrowernumber' => $owner );
my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
$edit = 1;
- $sortfield='' unless $sortfield;
$template->param(
edit => 1,
display => $displaymode,
ownername => $ownername,
"category$category" => 1,
category => $category,
- "sort_$sortfield" => 1,
+ sortfield => $sortfield,
allow_add => $allow_add,
allow_delete_own => $allow_delete_own,
allow_delete_other => $allow_delete_other,
#check that the user can view the shelf
if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
my $items;
- my $authorsort;
- my $yearsort;
my $tag_quantity;
my $sortfield = ( $sorton ? $sorton : 'title' );
- if ( $sortfield eq 'author' ) {
- $authorsort = 'author';
- }
- if ( $sortfield eq 'year' ) {
- $yearsort = 'year';
- }
- ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield eq 'year' ? 'copyrightdate' : $sortfield );
+ ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield );
for my $this_item (@$items) {
my $biblionumber = $this_item->{'biblionumber'};
my $record = GetMarcBiblio($biblionumber);
shelfname => $shelfname,
shelfnumber => $shelfnumber,
viewshelf => $shelfnumber,
- authorsort => $authorsort,
- yearsort => $yearsort,
- itemcallnumbersort => $sortfield eq 'itemcallnumber',
+ sortfield => $sortfield,
manageshelf => $manageshelf,
allowremovingitems => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'delete'),
allowaddingitem => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add'),
my $category = $shelflist->{$element}->{'category'};
my $owner = $shelflist->{$element}->{'owner'}||0;
my $canmanage = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
- my $sortfield = $shelflist->{$element}->{'sortfield'};
- if ( $sortfield ){
- if ( $sortfield eq 'author' ) {
- $shelflist->{$element}->{"authorsort"} = 'author';
- } elsif ( $sortfield eq 'year' ) {
- $shelflist->{$element}->{"yearsort"} = 'year';
- } elsif ( $sortfield eq 'itemcallnumber' ) {
- $shelflist->{$element}->{"itemcallnumbersort"} = 'itemcallnumber';
- }
- }
$shelflist->{$element}->{"viewcategory$category"} = 1;
$shelflist->{$element}->{manageshelf} = $canmanage;
if($canmanage || ($loggedinuser && $owner==$loggedinuser)) {
SetVersion($DBversion);
}
+$DBversion = "3.11.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do(q{
+ UPDATE virtualshelves SET sortfield="copyrightdate" where sortfield="year";
+ });
+ print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)
<ol>
<li><label class="required" for="addshelf">List name:</label><input id="addshelf" type="text" name="addshelf" size="25" /></li>
<li><span class="label">Owner: </span><input type="hidden" name="owner" id="owner" value="[% loggedinuser %]" />[% loggedinusername %]</li>
- <li><label for="sortfield" >Sort this list by: </label>
- <select name="sortfield" id="sortfield">
- [% IF ( sort_title ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
- [% IF ( sort_author ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
- [% IF ( sort_copyrightdate ) %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
- [% IF ( sort_itemcallnumber ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
- </select></li>
+ <li><label for="sortfield" >Sort this list by: </label>
+ <select name="sortfield" id="sortfield">
+ <option value="title">Title</option>
+ <option value="author">Author</option>
+ <option value="copyrightdate">Copyrightdate</option>
+ <option value="itemcallnumber">Call number</option>
+ </select></li>
<li><label for="category">Category: </label>
- <select name="category" id="category">
+ <select name="category" id="category">
<option value="1">Private</option>
<option value="2">Public</option>
</select></li>
<li><label for="owner">Owner: </label><input type="hidden" id="owner" name="owner" value="[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]" />[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]</li>
<li><label for="sortfield" >Sort this list by: </label>
<select name="sortfield">
- [% IF ( sort_title ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
- [% IF ( sort_author ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
- [% IF ( sort_copyrightdate ) %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
- [% IF ( sort_itemcallnumber ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
+ [% IF ( sortfield == "title" ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
+ [% IF ( sortfield == "author" ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
+ [% IF ( sortfield == "copyrightdate" ) %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
+ [% IF ( sortfield == "itemcallnumber" ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
</select></li>
<li><label for="category">Category: </label>
<select id="category" name="category">
[% IF ( shelveslooppri.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
<td><a href="shelves.pl?[% IF ( shelveslooppri.showprivateshelves ) %]display=privateshelves&[% END %]viewshelf=[% shelveslooppri.shelf %]&shelfoff=[% shelfoff %]">[% shelveslooppri.shelfname |html %]</a></td>
<td>[% shelveslooppri.count %] item(s)</td>
- <td>[% IF ( shelveslooppri.authorsort ) %]Author[% ELSIF ( shelveslooppri.yearsort ) %]Year[% ELSIF (shelveslooppri.itemcallnumbersort) %]Call number[% ELSE %]Title[% END %]</td>
+ <td>[% IF ( shelveslooppri.sortfield == "author" ) %]Author[% ELSIF ( shelveslooppri.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelveslooppri.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
<td>[% IF ( shelveslooppri.viewcategory1 ) %]Private[% END %]
[% IF ( shelveslooppri.viewcategory2 ) %]Public[% END %]
</td>
<td><a href="shelves.pl?viewshelf=[% shelvesloo.shelf %]">[% shelvesloo.shelfname |html %]</a></td>
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% shelvesloo.owner %]">[% shelvesloo.ownername %]</td>
<td>[% shelvesloo.count %] item(s)</td>
- <td>[% IF ( shelvesloo.authorsort ) %]Author[% ELSIF ( shelvesloo.yearsort ) %]Year[% ELSIF (shelvesloo.itemcallnumbersort) %]Call number[% ELSE %]Title[% END %]</td>
+ <td>[% IF ( shelvesloo.sortfield == "author" ) %]Author[% ELSIF ( shelvesloo.sortfield == "copyrightdate" ) %]Year[% ELSIF (shelvesloo.sortfield == "itemcallnumber") %]Call number[% ELSE %]Title[% END %]</td>
<td>[% IF ( shelvesloo.viewcategory1 ) %]Private[% END %]
[% IF ( shelvesloo.viewcategory2 ) %]Public[% END %]
</td>
<li>
<label for="sortfield" >Sort this list by: </label>
<select name="sortfield" id="sortfield">
- [% IF ( sort_title ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
- [% IF ( sort_author ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
- [% IF ( sort_year ) %]<option value="year" selected="selected">Year</option>[% ELSE %]<option value="year">Year</option>[% END %]
- [% IF ( sort_itemcallnumber ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
+ [% IF ( sortfield == "title" ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
+ [% IF ( sortfield == "author" ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
+ [% IF ( sortfield == "copyrightdate" ) %]<option value="copyrightdate" selected="selected">Year</option>[% ELSE %]<option value="copyrightdate">Year</option>[% END %]
+ [% IF ( sortfield == "itemcallnumber" ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
</select>
</li>
<li>
<li>
<label for="sortfield" >Sort this list by: </label>
<select name="sortfield" id="sortfield">
- [% IF ( sort_title ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
- [% IF ( sort_author ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
- [% IF ( sort_year ) %]<option value="year" selected="selected">Year</option>[% ELSE %]<option value="year">Year</option>[% END %]
- [% IF ( sort_itemcallnumber ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
+ <option value="title">Title</option>
+ <option value="author">Author</option>
+ <option value="copyrightdate">Year</option>
+ <option value="itemcallnumber">Call number</option>
</select>
</li>
<li>