-#!/usr/bin/perl
-
package C4::ShelfBrowser;
# Copyright 2010 Catalyst IT
use strict;
use warnings;
-use C4::Biblio;
-use C4::Branch;
+use C4::Biblio qw( GetAuthorisedValueDesc GetMarcBiblio );
use C4::Context;
-use C4::Koha;
-
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+use C4::Koha qw( GetNormalizedUPC GetNormalizedOCLCNumber GetNormalizedISBN GetNormalizedEAN );
+use Koha::Biblios;
+use Koha::Libraries;
+our (@ISA, @EXPORT_OK);
BEGIN {
- $VERSION = 3.07.00.049;
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw(
- &GetNearbyItems
- );
+ require Exporter;
+ @ISA = qw(Exporter);
@EXPORT_OK = qw(
+ GetNearbyItems
);
}
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.
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);
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'})) {
my $marcflavour = C4::Context->preference("marcflavour");
my @valid_items;
for my $item ( @items ) {
- my $this_biblio = GetBibData($item->{biblionumber});
- next unless defined $this_biblio;
- $item->{'title'} = $this_biblio->{'title'};
- my $this_record = GetMarcBiblio($this_biblio->{'biblionumber'});
+ my $biblio = Koha::Biblios->find( $item->{biblionumber} );
+ next unless defined $biblio;
+
+ $item->{biblio_object} = $biblio;
+ $item->{biblionumber} = $biblio->biblionumber;
+ $item->{title} = $biblio->title;
+ $item->{subtitle} = $biblio->subtitle;
+ $item->{medium} = $biblio->medium;
+ $item->{part_number} = $biblio->part_number;
+ $item->{part_name} = $biblio->part_name;
+ my $this_record = GetMarcBiblio({ biblionumber => $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);
return @valid_items;
}
-# Fetches some basic biblio data needed by the shelf stuff
-sub GetBibData {
- my ($bibnum) = @_;
-
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT biblionumber, title FROM biblio WHERE biblionumber=?");
- $sth->execute($bibnum);
- my $bib = $sth->fetchrow_hashref();
- return $bib;
-}
-
1;