Bug 8032: Sort lists by call number
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Mon, 5 Nov 2012 13:22:55 +0000 (14:22 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Fri, 30 Nov 2012 12:28:37 +0000 (07:28 -0500)
Precaution: Joining the items table makes that the table is sorted on
the item call number of the first item (in case there are more items).

Signed-off-by: Melia Meggs <melia@test.bywatersolutions.com>
Passed-QA-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/VirtualShelves.pm
C4/VirtualShelves/Page.pm
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt

index b7b0c77..0bb4b56 100644 (file)
@@ -266,11 +266,12 @@ sub GetShelfContents {
         ($sortfield) = $sth2->fetchrow_array;
     }
     my $query =
-       " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
+       " SELECT DISTINCT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
             biblio.*, biblioitems.itemtype, biblioitems.publicationyear as year, biblioitems.publishercode, biblioitems.place, biblioitems.size, biblioitems.pages
          FROM   virtualshelfcontents vc
          JOIN biblio      ON      vc.biblionumber =      biblio.biblionumber
          LEFT JOIN biblioitems ON  biblio.biblionumber = biblioitems.biblionumber
+         LEFT JOIN items ON items.biblionumber=vc.biblionumber
          LEFT JOIN itemtypes   ON biblioitems.itemtype = itemtypes.itemtype
          WHERE  vc.shelfnumber=? ";
     my @params = ($shelfnumber);
index 988244c..bf53563 100644 (file)
@@ -304,6 +304,7 @@ sub shelfpage {
                     viewshelf           => $shelfnumber,
                     authorsort          => $authorsort,
                     yearsort            => $yearsort,
+                    itemcallnumbersort  => $sortfield eq 'itemcallnumber',
                     manageshelf         => $manageshelf,
                     allowremovingitems  => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'delete'),
                     allowaddingitem     => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add'),
@@ -418,6 +419,8 @@ sub shelfpage {
                 $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;
index 0c71a41..20ae8ee 100644 (file)
@@ -210,6 +210,7 @@ function placeHold () {
                 <th>Title</th>
                 <th>Author</th>
                 <th>Date added</th>
+                <th>Call number</th>
                 <th>&nbsp;</th>
             </tr>
                [% FOREACH itemsloo IN itemsloop %]
@@ -238,6 +239,9 @@ function placeHold () {
                        <td>[% itemsloo.author %]</td>
                        <td>[% itemsloo.dateadded %]</td>
                        <td>
+                [% FOREACH result IN itemsloo.ITEM_RESULTS %][% result.itemcallnumber %][% UNLESS loop.last %], [% END %][% END %]
+            </td>
+            <td>
                        [% UNLESS ( itemsloo.notforloan ) %]
                        <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber %]">Holds</a>
                        [% END %]
@@ -299,6 +303,7 @@ function placeHold () {
                [% 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="category">Category: </label>
                        <select name="category" id="category">
@@ -322,6 +327,7 @@ function placeHold () {
                [% 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="category">Category: </label>
                        <select id="category" name="category">
@@ -386,7 +392,7 @@ function placeHold () {
                     [% IF ( shelveslooppri.toggle ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
         <td><a href="shelves.pl?[% IF ( shelveslooppri.showprivateshelves ) %]display=privateshelves&amp;[% END %]viewshelf=[% shelveslooppri.shelf %]&amp;shelfoff=[% shelfoff %]">[% shelveslooppri.shelfname |html %]</a></td>
         <td>[% shelveslooppri.count %] item(s)</td>
-        <td>[% IF ( shelveslooppri.authorsort ) %]Author[% ELSIF ( shelveslooppri.yearsort ) %]Year[% ELSE %]Title[% END %]</td>
+        <td>[% IF ( shelveslooppri.authorsort ) %]Author[% ELSIF ( shelveslooppri.yearsort ) %]Year[% ELSIF (shelveslooppri.itemcallnumbersort) %]Call number[% ELSE %]Title[% END %]</td>
         <td>[% IF ( shelveslooppri.viewcategory1 ) %]Private[% END %]
                        [% IF ( shelveslooppri.viewcategory2 ) %]Public[% END %]
                </td>
@@ -439,7 +445,7 @@ function placeHold () {
                <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[% ELSE %]Title[% END %]</td>
+        <td>[% IF ( shelvesloo.authorsort ) %]Author[% ELSIF ( shelvesloo.yearsort ) %]Year[% ELSIF (shelvesloo.itemcallnumbersort) %]Call number[% ELSE %]Title[% END %]</td>
         <td>[% IF ( shelvesloo.viewcategory1 ) %]Private[% END %]
                        [% IF ( shelvesloo.viewcategory2 ) %]Public[% END %]
                </td>
index 197ac5d..2e21d12 100644 (file)
@@ -488,6 +488,7 @@ $(function() {
                           [% 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 %]
                         </select>
                       </li>
                       <li>
@@ -677,6 +678,7 @@ $(function() {
                           [% 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 %]
                         </select>
                       </li>
                       <li>