Bug 18736: (follow-up) Fix missing rounding and bad formatting
[koha.git] / C4 / ShelfBrowser.pm
index 555ad05..ee551d2 100644 (file)
@@ -6,31 +6,30 @@ package C4::ShelfBrowser;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
 
 use C4::Biblio;
-use C4::Branch;
 use C4::Context;
 use C4::Koha;
+use Koha::Libraries;
 
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+use vars qw(@ISA @EXPORT @EXPORT_OK);
 
 BEGIN {
-    $VERSION = 3.07.00.049;
        require Exporter;
        @ISA    = qw(Exporter);
        @EXPORT = qw(
@@ -73,6 +72,7 @@ to take into account.
          print $_->{browser_normalized_upc};
          print $_->{browser_normalized_oclc};
          print $_->{browser_normalized_isbn};
+      print $_->{browser_normalized_ean};
   }
 
   # This is the information required to scroll the browser to the next left
@@ -102,7 +102,7 @@ C<ShelfBrowserUsesCcode>.
 The option C<$num_each_side> value determines how many items will be fetched
 each side of the supplied item. Note that the item itself is the first entry
 in the 'next' set, and counts towards this limit (this is to keep the
-behaviour consistant with the code that this is a refactor of.) Default is
+behaviour consistent with the code that this is a refactor of.) Default is
 3.
 
 This will throw an exception if something went wrong.
@@ -117,7 +117,6 @@ sub GetNearbyItems {
         if $gap <= $num_each_side;
 
     my $dbh         = C4::Context->dbh;
-    my $branches = GetBranches();
 
     my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
     $sth_get_item_details->execute($itemnumber);
@@ -129,7 +128,7 @@ sub GetNearbyItems {
     if (C4::Context->preference('ShelfBrowserUsesHomeBranch') && 
        defined($item_details_result->{'homebranch'})) {
         $start_homebranch->{code} = $item_details_result->{'homebranch'};
-        $start_homebranch->{description} = $branches->{$item_details_result->{'homebranch'}}{branchname};
+        $start_homebranch->{description} = Koha::Libraries->find($item_details_result->{'homebranch'})->branchname;
     }
     if (C4::Context->preference('ShelfBrowserUsesLocation') && 
        defined($item_details_result->{'location'})) {
@@ -171,7 +170,7 @@ sub GetNearbyItems {
 
     my @prev_items = @{
         $dbh->selectall_arrayref(
-            $prev_query . $query_cond . ' ORDER BY cn_sort DESC, itemnumber LIMIT ?',
+            $prev_query . $query_cond . ' ORDER BY cn_sort DESC, itemnumber DESC LIMIT ?',
             { Slice => {} },
             ( @params, $gap )
         )
@@ -224,10 +223,12 @@ sub GetShelfInfo {
         my $this_biblio = GetBibData($item->{biblionumber});
         next unless defined $this_biblio;
         $item->{'title'} = $this_biblio->{'title'};
-        my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
+        my $this_record = GetMarcBiblio({ biblionumber => $this_biblio->{'biblionumber'} });
         $item->{'browser_normalized_upc'} = GetNormalizedUPC($this_record,$marcflavour);
         $item->{'browser_normalized_oclc'} = GetNormalizedOCLCNumber($this_record,$marcflavour);
         $item->{'browser_normalized_isbn'} = GetNormalizedISBN(undef,$this_record,$marcflavour);
+        $item->{'browser_normalized_ean'} = GetNormalizedEAN($this_record,$marcflavour);
+        $item->{'subtitle'} = GetRecordValue('subtitle', $this_record, GetFrameworkCode( $item->{biblionumber} ));
         push @valid_items, $item;
     }
     return @valid_items;