From d46afabec960f2dcb352b1c01a3129e153945552 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 17 May 2017 10:36:05 +0000 Subject: [PATCH] Bug 18606: Get rid of GetCollectionItemBranches Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 2 +- C4/RotatingCollections.pm | 31 ------------------------------- Koha/Item.pm | 19 +++++++++++++++++++ circ/returns.pl | 6 ++++-- 4 files changed, 24 insertions(+), 34 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index dce77ea..28840f7 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -36,7 +36,7 @@ use C4::Message; use C4::Debug; use C4::Log; # logaction use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units); -use C4::RotatingCollections qw(GetCollectionItemBranches); +use C4::RotatingCollections; use Algorithm::CheckDigits; use Data::Dumper; diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index dafc1dc..521a4e9 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -51,8 +51,6 @@ BEGIN { AddItemToCollection RemoveItemFromCollection TransferCollection - - GetCollectionItemBranches ); } @@ -204,35 +202,6 @@ sub TransferCollection { } -=head2 GetCollectionItemBranches - - my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); - -=cut - -sub GetCollectionItemBranches { - my ($itemnumber) = @_; - - if ( !$itemnumber ) { - return; - } - - my $dbh = C4::Context->dbh; - - my ( $sth, @results ); - $sth = $dbh->prepare( -"SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking - WHERE items.itemnumber = collections_tracking.itemnumber - AND collections.colId = collections_tracking.colId - AND items.itemnumber = ?" - ); - $sth->execute($itemnumber); - - my $row = $sth->fetchrow_hashref; - - return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); -} - =head2 isItemInThisCollection $inCollection = isItemInThisCollection( $itemnumber, $colId ); diff --git a/Koha/Item.pm b/Koha/Item.pm index 964359e..d3f50d1 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -31,6 +31,7 @@ use Koha::Item::Transfer::Limits; use Koha::Item::Transfers; use Koha::Patrons; use Koha::Libraries; +use Koha::RotatingCollections; use base qw(Koha::Object); @@ -282,6 +283,24 @@ sub current_holds { return Koha::Holds->_new_from_dbic($hold_rs); } +=head3 rotating_collection + +=cut + +sub rotating_collection { + my ( $self ) = @_; + my $collection = Koha::RotatingCollections->search( + { + 'collections_trackings.itemnumber' => $self->itemnumber + }, + { + join => [ 'collections_trackings' ] + } + ); + + return $collection->single; +} + =head3 type =cut diff --git a/circ/returns.pl b/circ/returns.pl index c2f20ef..dab45fb 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -44,7 +44,6 @@ use C4::Items; use C4::Members; use C4::Members::Messaging; use C4::Koha; # FIXME : is it still useful ? -use C4::RotatingCollections; use Koha::AuthorisedValues; use Koha::DateUtils; use Koha::Calendar; @@ -625,7 +624,10 @@ $template->param( my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!? if ( $item_from_barcode ) { $itemnumber = $item_from_barcode->itemnumber; - my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber ); + my $holdingBranch = $item_from_barcode->holdingbranch; + my $collection = $item_from_barcode->rotating_collection; + my $collectionBranch; + $collectionBranch = $collection->colBranchcode if $collection; if ( $holdingBranch and $collectionBranch ) { $holdingBranch //= ''; $collectionBranch //= $returnbranch; -- 2.1.4