From 9e7c94bf96b9029187dfdd957457b13c9dbed718 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Jan 2008 12:36:21 -0600 Subject: [PATCH] item rework: moved GetItem Moved from C4::Biblio to C4::Items. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 34 ---------------------------------- C4/Items.pm | 36 ++++++++++++++++++++++++++++++++++++ C4/Reserves.pm | 1 + opac/opac-reserve.pl | 1 + opac/opac-user.pl | 1 + opac/sco/sco-main.pl | 1 + reserve/placerequest.pl | 1 + virtualshelves/shelves.pl | 1 + 8 files changed, 42 insertions(+), 34 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 2c7ee4f704..d637cf792a 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -52,7 +52,6 @@ push @EXPORT, qw( &GetBiblioItemByBiblioNumber &GetBiblioFromItemNumber - &GetItem &GetItemInfosOf &GetItemStatus &GetItemLocation @@ -1311,39 +1310,6 @@ sub GetBiblio { return ( $count, @results ); } # sub GetBiblio -=head2 GetItem - -=over 4 - -$data = &GetItem($itemnumber,$barcode); - -return Item information, for a given itemnumber or barcode - -=back - -=cut - -sub GetItem { - my ($itemnumber,$barcode) = @_; - my $dbh = C4::Context->dbh; - if ($itemnumber) { - my $sth = $dbh->prepare(" - SELECT * FROM items - WHERE itemnumber = ?"); - $sth->execute($itemnumber); - my $data = $sth->fetchrow_hashref; - return $data; - } else { - my $sth = $dbh->prepare(" - SELECT * FROM items - WHERE barcode = ?" - ); - $sth->execute($barcode); - my $data = $sth->fetchrow_hashref; - return $data; - } -} # sub GetItem - =head2 get_itemnumbers_of =over 4 diff --git a/C4/Items.pm b/C4/Items.pm index 02aebe111a..2624f7e69d 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -36,6 +36,7 @@ my $VERSION = 3.00; # function exports @EXPORT = qw( + GetItem AddItemFromMarc AddItem ModItemFromMarc @@ -85,6 +86,41 @@ of C =cut +=head2 GetItem + +=over 4 + +$item = GetItem($itemnumber,$barcode); + +=back + +Return item information, for a given itemnumber or barcode. +The return value is a hashref mapping item column +names to values. + +=cut + +sub GetItem { + my ($itemnumber,$barcode) = @_; + my $dbh = C4::Context->dbh; + if ($itemnumber) { + my $sth = $dbh->prepare(" + SELECT * FROM items + WHERE itemnumber = ?"); + $sth->execute($itemnumber); + my $data = $sth->fetchrow_hashref; + return $data; + } else { + my $sth = $dbh->prepare(" + SELECT * FROM items + WHERE barcode = ?" + ); + $sth->execute($barcode); + my $data = $sth->fetchrow_hashref; + return $data; + } +} # sub GetItem + =head2 AddItemFromMarc =over 4 diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 847f7d1992..2a5a2fd32b 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -27,6 +27,7 @@ use strict; require Exporter; use C4::Context; use C4::Biblio; +use C4::Items; use C4::Search; use C4::Circulation; use C4::Accounts; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 6e075184c4..98fa43ff1f 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -19,6 +19,7 @@ use strict; require Exporter; use CGI; use C4::Biblio; +use C4::Items; use C4::Auth; # checkauth, getborrowernumber. use C4::Koha; use C4::Circulation; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index a7b8d610cb..4e32b4b7d9 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -27,6 +27,7 @@ use C4::Reserves; use C4::Members; use C4::Output; use C4::Biblio; +use C4::Items; use C4::Dates qw/format_date/; use C4::Letters; use C4::Branch; # GetBranches diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 83c317603b..1fcd091239 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -20,6 +20,7 @@ use C4::Members; use HTML::Template::Pro; use C4::Dates; use C4::Biblio; +use C4::Items; my $query = new CGI; my ($template, $loggedinuser, $cookie) diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 64eb94af8a..36379f8b96 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -23,6 +23,7 @@ use strict; use C4::Biblio; +use C4::Items; use CGI; use C4::Output; use C4::Reserves; diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 79c44956e1..6c82e53ad0 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -67,6 +67,7 @@ use strict; use CGI; use C4::VirtualShelves; use C4::Biblio; +use C4::Items; use C4::Auth; use C4::Output; -- 2.39.5