Bugzilla – Attachment 77699 Details for
Bug 21206
C4::Items - Remove GetItem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21206: Replace C4::Items::GetItem
Bug-21206-Replace-C4ItemsGetItem.patch (text/plain), 116.11 KB, created by
Jonathan Druart
on 2018-08-10 16:06:18 UTC
(
hide
)
Description:
Bug 21206: Replace C4::Items::GetItem
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-08-10 16:06:18 UTC
Size:
116.11 KB
patch
obsolete
>From 863573e4354ff576984394c6d5788ef5d74339b1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 6 Aug 2018 19:50:41 -0300 >Subject: [PATCH] Bug 21206: Replace C4::Items::GetItem > >Note: This is here for information purpose, feel free to test it if you >wan to play with it. > >TODO: C4::Reserves::_get_itype is not longer in use > >No more GetItem must be returned by: >git grep GetItem|grep -v GetItemsAvailableToFillHoldRequestsForBib|grep >-v GetItemsForInventory|grep -v GetItemsInfo|grep -v >GetItemsLocationInfo|grep -v GetItemsInCollection|grep -v >GetItemCourseReservesInfo|grep -v GetItemnumbersFromOrder|grep -v >GetItemSearchField|grep -v GetItemTypesCategorized|grep -v >GetItemNumbersFromImportBatch|cut -d':' -f1|sort|uniq >--- > C4/Biblio.pm | 15 +- > C4/Circulation.pm | 293 +++++++++++---------- > C4/CourseReserves.pm | 10 +- > C4/HoldsQueue.pm | 7 +- > C4/ILSDI/Services.pm | 40 +-- > C4/Items.pm | 41 +-- > C4/Message.pm | 2 +- > C4/Reserves.pm | 39 ++- > acqui/orderreceive.pl | 10 +- > catalogue/getitem-ajax.pl | 39 +-- > catalogue/updateitem.pl | 2 +- > cataloguing/additem.pl | 23 +- > installer/data/mysql/backfill_statistics.pl | 9 +- > labels/label-edit-batch.pl | 3 +- > misc/recreateIssueStatistics.pl | 22 +- > opac/opac-renew.pl | 7 +- > opac/opac-shelves.pl | 6 +- > opac/sco/sco-main.pl | 9 +- > reserve/placerequest.pl | 8 +- > svc/checkin | 14 +- > t/db_dependent/Acquisition/CancelReceipt.t | 9 +- > t/db_dependent/Circulation.t | 6 +- > t/db_dependent/Circulation/IsItemIssued.t | 9 +- > t/db_dependent/Circulation/Returns.t | 11 +- > t/db_dependent/Circulation/issue.t | 13 +- > .../Holds/DisallowHoldIfItemsAvailable.t | 15 +- > t/db_dependent/Items.t | 68 ++--- > .../Items/AutomaticItemModificationByAge.t | 51 ++-- > t/db_dependent/Items/DelItem.t | 10 +- > t/db_dependent/Items/MoveItemFromBiblio.t | 13 +- > t/db_dependent/Items_DelItemCheck.t | 5 +- > t/db_dependent/Reserves.t | 3 +- > tools/batchMod.pl | 8 +- > tools/inventory.pl | 6 +- > tools/viewlog.pl | 10 +- > virtualshelves/shelves.pl | 7 +- > 36 files changed, 435 insertions(+), 408 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 0c5a917c6b..237216db2a 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2196,10 +2196,9 @@ sub PrepHostMarcField { > my ($hostbiblionumber,$hostitemnumber, $marcflavour) = @_; > $marcflavour ||="MARC21"; > >- require C4::Items; > my $hostrecord = GetMarcBiblio({ biblionumber => $hostbiblionumber }); >- my $item = C4::Items::GetItem($hostitemnumber); >- >+ my $item = Koha::Items->find($hostitemnumber); >+ > my $hostmarcfield; > if ( $marcflavour eq "MARC21" || $marcflavour eq "NORMARC" ) { > >@@ -2222,7 +2221,7 @@ sub PrepHostMarcField { > > #other fields > my $ed = $hostrecord->subfield('250','a'); >- my $barcode = $item->{'barcode'}; >+ my $barcode = $item->barcode; > my $title = $hostrecord->subfield('245','a'); > > # record control number, 001 with 003 and prefix >@@ -2807,8 +2806,12 @@ sub EmbedItemsInMarcBiblio { > require C4::Items; > while ( my ($itemnumber) = $sth->fetchrow_array ) { > next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers; >- my $i = $opachiddenitems ? C4::Items::GetItem($itemnumber) : undef; >- push @items, { itemnumber => $itemnumber, item => $i }; >+ my $item; >+ if ( $opachiddenitems ) { >+ $item = Koha::Items->find($itemnumber); >+ $item = $item ? $item->unblessed : undef; >+ } >+ push @items, { itemnumber => $itemnumber, item => $item }; > } > my @hiddenitems = > $opachiddenitems >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b772a7a999..32c4b7c4fb 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -668,17 +668,18 @@ sub CanBookBeIssued { > my $onsite_checkout = $params->{onsite_checkout} || 0; > my $override_high_holds = $params->{override_high_holds} || 0; > >- my $item = GetItem(undef, $barcode ); >+ my $item = Koha::Items->find({barcode => $barcode }); > # MANDATORY CHECKS - unless item exists, nothing else matters > unless ( $item ) { > $issuingimpossible{UNKNOWN_BARCODE} = 1; > } > return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; > >- my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); >- my $biblio = Koha::Biblios->find( $item->{biblionumber} ); >+ my $item_unblessed = $item->unblessed; # Transition... >+ my $issue = $item->checkout; >+ my $biblio = $item->biblio; > my $biblioitem = $biblio->biblioitem; >- my $effective_itemtype = $item->{itype}; # GetItem deals with that >+ my $effective_itemtype = $item->effective_itemtype; > my $dbh = C4::Context->dbh; > my $patron_unblessed = $patron->unblessed; > >@@ -692,7 +693,7 @@ sub CanBookBeIssued { > unless ( $duedate ) { > my $issuedate = $now->clone(); > >- my $branch = _GetCircControlBranch($item, $patron_unblessed); >+ my $branch = _GetCircControlBranch($item_unblessed, $patron_unblessed); > $duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $patron_unblessed ); > > # Offline circ calls AddIssue directly, doesn't run through here >@@ -711,17 +712,17 @@ sub CanBookBeIssued { > # > # BORROWER STATUS > # >- if ( $patron->category->category_type eq 'X' && ( $item->{barcode} )) { >+ if ( $patron->category->category_type eq 'X' && ( $item->barcode )) { > # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . > &UpdateStats({ > branch => C4::Context->userenv->{'branch'}, > type => 'localuse', >- itemnumber => $item->{'itemnumber'}, >+ itemnumber => $item->itemnumber, > itemtype => $effective_itemtype, > borrowernumber => $patron->borrowernumber, >- ccode => $item->{'ccode'}} >+ ccode => $item->ccode} > ); >- ModDateLastSeen( $item->{'itemnumber'} ); >+ ModDateLastSeen( $item->itemnumber ); # FIXME Move to Koha::Item > return( { STATS => 1 }, {}); > } > >@@ -832,7 +833,7 @@ sub CanBookBeIssued { > } else { > my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed( > $patron->borrowernumber, >- $item->{'itemnumber'}, >+ $item->itemnumber, > ); > if ( $CanBookBeRenewed == 0 ) { # no more renewals allowed > if ( $renewerror eq 'onsite_checkout' ) { >@@ -853,7 +854,7 @@ sub CanBookBeIssued { > > my $patron = Koha::Patrons->find( $issue->borrowernumber ); > >- my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); >+ my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); > > unless ( $can_be_returned ) { > $issuingimpossible{RETURN_IMPOSSIBLE} = 1; >@@ -874,7 +875,7 @@ sub CanBookBeIssued { > and $issue > and $issue->onsite_checkout > and $issue->borrowernumber == $patron->borrowernumber ? 1 : 0 ); >- my $toomany = TooMany( $patron_unblessed, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); >+ my $toomany = TooMany( $patron_unblessed, $item->biblionumber, $item_unblessed, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } ); > # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book > if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { > if ( $toomany->{max_allowed} == 0 ) { >@@ -897,19 +898,19 @@ sub CanBookBeIssued { > $patron = Koha::Patrons->find( $patron->borrowernumber ); # FIXME Refetch just in case, to avoid regressions. But must not be needed > my $wants_check = $patron->wants_check_for_previous_checkout; > $needsconfirmation{PREVISSUE} = 1 >- if ($wants_check and $patron->do_check_for_previous_checkout($item)); >+ if ($wants_check and $patron->do_check_for_previous_checkout($item_unblessed)); > > # > # ITEM CHECKING > # >- if ( $item->{'notforloan'} ) >+ if ( $item->notforloan ) > { > if(!C4::Context->preference("AllowNotForLoanOverride")){ > $issuingimpossible{NOT_FOR_LOAN} = 1; >- $issuingimpossible{item_notforloan} = $item->{'notforloan'}; >+ $issuingimpossible{item_notforloan} = $item->notforloan; > }else{ > $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; >- $needsconfirmation{item_notforloan} = $item->{'notforloan'}; >+ $needsconfirmation{item_notforloan} = $item->notforloan; > } > } > else { >@@ -942,17 +943,17 @@ sub CanBookBeIssued { > } > } > } >- if ( $item->{'withdrawn'} && $item->{'withdrawn'} > 0 ) >+ if ( $item->withdrawn && $item->withdrawn > 0 ) > { > $issuingimpossible{WTHDRAWN} = 1; > } >- if ( $item->{'restricted'} >- && $item->{'restricted'} == 1 ) >+ if ( $item->restricted >+ && $item->restricted == 1 ) > { > $issuingimpossible{RESTRICTED} = 1; > } >- if ( $item->{'itemlost'} && C4::Context->preference("IssueLostItem") ne 'nothing' ) { >- my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->{itemlost} }); >+ if ( $item->itemlost && C4::Context->preference("IssueLostItem") ne 'nothing' ) { >+ my $av = Koha::AuthorisedValues->search({ category => 'LOST', authorised_value => $item->itemlost }); > my $code = $av->count ? $av->next->lib : ''; > $needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' ); > $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' ); >@@ -960,9 +961,10 @@ sub CanBookBeIssued { > if ( C4::Context->preference("IndependentBranches") ) { > my $userenv = C4::Context->userenv; > unless ( C4::Context->IsSuperLibrarian() ) { >- if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){ >+ my $HomeOrHoldingBranch = C4::Context->preference("HomeOrHoldingBranch"); >+ if ( $item->$HomeOrHoldingBranch ne $userenv->{branch} ){ > $issuingimpossible{ITEMNOTSAMEBRANCH} = 1; >- $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")}; >+ $issuingimpossible{'itemhomebranch'} = $item->$HomeOrHoldingBranch; > } > $needsconfirmation{BORRNOTSAMEBRANCH} = $patron->branchcode > if ( $patron->branchcode ne $userenv->{branch} ); >@@ -974,7 +976,7 @@ sub CanBookBeIssued { > my $rentalConfirmation = C4::Context->preference("RentalFeesCheckoutConfirmation"); > > if ( $rentalConfirmation ){ >- my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); >+ my ($rentalCharge) = GetIssuingCharges( $item->itemnumber, $patron->borrowernumber ); > if ( $rentalCharge > 0 ){ > $needsconfirmation{RENTALCHARGE} = $rentalCharge; > } >@@ -982,7 +984,7 @@ sub CanBookBeIssued { > > unless ( $ignore_reserves ) { > # See if the item is on reserve. >- my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ); >+ my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->itemnumber ); > if ($restype) { > my $resbor = $res->{'borrowernumber'}; > if ( $resbor ne $patron->borrowernumber ) { >@@ -1027,7 +1029,7 @@ sub CanBookBeIssued { > > ## check for high holds decreasing loan period > if ( C4::Context->preference('decreaseLoanHighHolds') ) { >- my $check = checkHighHolds( $item, $patron_unblessed ); >+ my $check = checkHighHolds( $item_unblessed, $patron_unblessed ); > > if ( $check->{exceeded} ) { > if ($override_high_holds) { >@@ -1056,7 +1058,7 @@ sub CanBookBeIssued { > ) { > # Check if borrower has already issued an item from the same biblio > # Only if it's not a subscription >- my $biblionumber = $item->{biblionumber}; >+ my $biblionumber = $item->biblionumber; > require C4::Serials; > my $is_a_subscription = C4::Serials::CountSubscriptionFromBiblionumber($biblionumber); > unless ($is_a_subscription) { >@@ -1089,7 +1091,7 @@ Check whether the item can be returned to the provided branch > > =over 4 > >-=item C<$item> is a hash of item information as returned from GetItem >+=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) > > =item C<$branch> is the branchcode where the return is taking place > >@@ -1287,21 +1289,21 @@ sub AddIssue { > # Stop here if the patron or barcode doesn't exist > if ( $borrower && $barcode && $barcodecheck ) { > # find which item we issue >- my $item = GetItem( '', $barcode ) >+ my $item = Koha::Items->find({ barcode => $barcode }) > or return; # if we don't get an Item, abort. >- my $item_object = Koha::Items->find( { barcode => $barcode } ); >+ my $item_unblessed = $item->unblessed; > >- my $branch = _GetCircControlBranch( $item, $borrower ); >+ my $branch = _GetCircControlBranch( $item_unblessed, $borrower ); > > # get actual issuing if there is one >- my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); >+ my $actualissue = $item->checkout; > > # check if we just renew the issue. > if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} > and not $switch_onsite_checkout ) { > $datedue = AddRenewal( > $borrower->{'borrowernumber'}, >- $item->{'itemnumber'}, >+ $item->itemnumber, > $branch, > $datedue, > $issuedate, # here interpreted as the renewal date >@@ -1312,15 +1314,15 @@ sub AddIssue { > if ( $actualissue and not $switch_onsite_checkout ) { > # This book is currently on loan, but not to the person > # who wants to borrow it now. mark it returned before issuing to the new borrower >- my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); >+ my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); > return unless $allowed; >- AddReturn( $item->{'barcode'}, C4::Context->userenv->{'branch'} ); >+ AddReturn( $item->barcode, C4::Context->userenv->{'branch'} ); > } > >- C4::Reserves::MoveReserve( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $cancelreserve ); >+ C4::Reserves::MoveReserve( $item->itemnumber, $borrower->{'borrowernumber'}, $cancelreserve ); > > # Starting process for transfer job (checking transfert and validate it if we have one) >- my ($datesent) = GetTransfers( $item->{'itemnumber'} ); >+ my ($datesent) = GetTransfers( $item->itemnumber ); > if ($datesent) { > # updating line of branchtranfert to finish it, and changing the to branch value, implement a comment for visibility of this case (maybe for stats ....) > my $sth = $dbh->prepare( >@@ -1331,14 +1333,14 @@ sub AddIssue { > WHERE itemnumber= ? AND datearrived IS NULL" > ); > $sth->execute( C4::Context->userenv->{'branch'}, >- $item->{'itemnumber'} ); >+ $item->itemnumber ); > } > > # If automatic renewal wasn't selected while issuing, set the value according to the issuing rule. > unless ($auto_renew) { > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $borrower->{categorycode}, >- itemtype => $item->{itype}, >+ itemtype => $item->effective_itemtype, > branchcode => $branch > } > ); >@@ -1348,7 +1350,7 @@ sub AddIssue { > > # Record in the database the fact that the book was issued. > unless ($datedue) { >- my $itype = $item_object->effective_itemtype; >+ my $itype = $item->effective_itemtype; > $datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); > > } >@@ -1357,7 +1359,7 @@ sub AddIssue { > $issue = Koha::Database->new()->schema()->resultset('Issue')->update_or_create( > { > borrowernumber => $borrower->{'borrowernumber'}, >- itemnumber => $item->{'itemnumber'}, >+ itemnumber => $item->itemnumber, > issuedate => $issuedate->strftime('%Y-%m-%d %H:%M:%S'), > date_due => $datedue->strftime('%Y-%m-%d %H:%M:%S'), > branchcode => C4::Context->userenv->{'branch'}, >@@ -1368,49 +1370,48 @@ sub AddIssue { > > if ( C4::Context->preference('ReturnToShelvingCart') ) { > # ReturnToShelvingCart is on, anything issued should be taken off the cart. >- CartToShelf( $item->{'itemnumber'} ); >+ CartToShelf( $item->itemnumber ); > } >- $item->{'issues'}++; >+ > if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) { >- UpdateTotalIssues( $item->{'biblionumber'}, 1 ); >+ UpdateTotalIssues( $item->biblionumber, 1 ); > } > > ## If item was lost, it has now been found, reverse any list item charges if necessary. >- if ( $item->{'itemlost'} ) { >+ if ( $item->itemlost ) { > if ( > Koha::RefundLostItemFeeRules->should_refund( > { > current_branch => C4::Context->userenv->{branch}, >- item_home_branch => $item->{homebranch}, >- item_holding_branch => $item->{holdingbranch} >+ item_home_branch => $item->homebranch, >+ item_holding_branch => $item->holdingbranch, > } > ) > ) > { >- _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, >- $item->{'barcode'} ); >+ _FixAccountForLostAndReturned( $item->itemnumber, undef, >+ $item->barcode ); > } > } > > ModItem( > { >- issues => $item->{'issues'}, >+ issues => $item->issues + 1, > holdingbranch => C4::Context->userenv->{'branch'}, > itemlost => 0, > onloan => $datedue->ymd(), > datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), > }, >- $item->{'biblionumber'}, >- $item->{'itemnumber'}, >+ $item->biblionumber, >+ $item->itemnumber, > { log_action => 0 } > ); >- ModDateLastSeen( $item->{'itemnumber'} ); >+ ModDateLastSeen( $item->itemnumber ); > > # If it costs to borrow this book, charge it to the patron's account. >- my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); >+ my ( $charge, $itemtype ) = GetIssuingCharges( $item->itemnumber, $borrower->{'borrowernumber'} ); > if ( $charge > 0 ) { > AddIssuingCharge( $issue, $charge ); >- $item->{'charge'} = $charge; > } > > # Record the fact that this book was issued. >@@ -1420,11 +1421,11 @@ sub AddIssue { > type => ( $onsite_checkout ? 'onsite_checkout' : 'issue' ), > amount => $charge, > other => ( $sipmode ? "SIP-$sipmode" : '' ), >- itemnumber => $item->{'itemnumber'}, >- itemtype => $item->{'itype'}, >- location => $item->{location}, >+ itemnumber => $item->itemnumber, >+ itemtype => $item->effective_itemtype, >+ location => $item->location, > borrowernumber => $borrower->{'borrowernumber'}, >- ccode => $item->{'ccode'} >+ ccode => $item->ccode, > } > ); > >@@ -1433,7 +1434,7 @@ sub AddIssue { > my %conditions = ( > branchcode => $branch, > categorycode => $borrower->{categorycode}, >- item_type => $item->{itype}, >+ item_type => $item->effective_itemtype, > notification => 'CHECKOUT', > ); > if ( $circulation_alert->is_enabled_for( \%conditions ) ) { >@@ -1449,7 +1450,7 @@ sub AddIssue { > logaction( > "CIRCULATION", "ISSUE", > $borrower->{'borrowernumber'}, >- $item->{'itemnumber'} >+ $item->itemnumber, > ) if C4::Context->preference("IssueLog"); > } > } >@@ -1802,13 +1803,13 @@ sub AddReturn { > my $stat_type = 'return'; > > # get information on item >- my $item = GetItem( undef, $barcode ); >+ my $item = Koha::Items->find({ barcode => $barcode }); > unless ($item) { > return ( 0, { BadBarcode => $barcode } ); # no barcode means no item or borrower. bail out. > } > >- my $itemnumber = $item->{ itemnumber }; >- my $itemtype = $item->{itype}; # GetItem called effective_itemtype >+ my $itemnumber = $item->itemnumber; >+ my $itemtype = $item->effective_itemtype; > > my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); > if ( $issue ) { >@@ -1827,21 +1828,22 @@ sub AddReturn { > } > } > >- if ( $item->{'location'} eq 'PROC' ) { >+ my $item_unblessed = $item->unblessed; >+ if ( $item->location eq 'PROC' ) { > if ( C4::Context->preference("InProcessingToShelvingCart") ) { >- $item->{'location'} = 'CART'; >+ $item_unblessed->{location} = 'CART'; > } > else { >- $item->{location} = $item->{permanent_location}; >+ $item_unblessed->{location} = $item->permanent_location; > } > >- ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'}, { log_action => 0 } ); >+ ModItem( $item_unblessed, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); > } > > # full item data, but no borrowernumber or checkout info (no issue) >- my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; >+ my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; > # get the proper branch to which to return the item >- my $returnbranch = $item->{$hbr} || $branch ; >+ my $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $branch; > # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) > > my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not >@@ -1857,8 +1859,8 @@ sub AddReturn { > } > else { > foreach my $key ( keys %$rules ) { >- if ( $item->{notforloan} eq $key ) { >- $messages->{'NotForLoanStatusUpdated'} = { from => $item->{notforloan}, to => $rules->{$key} }; >+ if ( $item->notforloan eq $key ) { >+ $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; > ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); > last; > } >@@ -1867,7 +1869,7 @@ sub AddReturn { > } > > # check if the return is allowed at this branch >- my ($returnallowed, $message) = CanBookBeReturned($item, $branch); >+ my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); > unless ($returnallowed){ > $messages->{'Wrongbranch'} = { > Wrongbranch => $branch, >@@ -1877,12 +1879,12 @@ sub AddReturn { > return ( $doreturn, $messages, $issue, $patron_unblessed); > } > >- if ( $item->{'withdrawn'} ) { # book has been cancelled >+ if ( $item->withdrawn ) { # book has been cancelled > $messages->{'withdrawn'} = 1; > $doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems"); > } > >- if ( $item->{itemlost} and C4::Context->preference("BlockReturnOfLostItems") ) { >+ if ( $item->itemlost and C4::Context->preference("BlockReturnOfLostItems") ) { > $doreturn = 0; > } > >@@ -1899,7 +1901,7 @@ sub AddReturn { > # don't allow dropbox mode to create an invalid entry in issues (issuedate > today) > # FIXME: check issuedate > returndate, factoring in holidays > >- $circControlBranch = _GetCircControlBranch($item,$patron_unblessed); >+ $circControlBranch = _GetCircControlBranch($item_unblessed, $patron_unblessed); > $is_overdue = $issue->is_overdue( $dropboxdate ); > } else { > $is_overdue = $issue->is_overdue; >@@ -1907,12 +1909,12 @@ sub AddReturn { > > if ($patron) { > eval { >- MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, >+ MarkIssueReturned( $borrowernumber, $item->itemnumber, > $circControlBranch, $return_date, $patron->privacy ); > }; > unless ( $@ ) { > if ( ( C4::Context->preference('CalculateFinesOnReturn') && $is_overdue ) || $return_date ) { >- _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed, return_date => $return_date } ); >+ _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); > } > } else { > carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); >@@ -1925,56 +1927,56 @@ sub AddReturn { > > } > >- ModItem( { onloan => undef }, $item->{biblionumber}, $item->{itemnumber}, { log_action => 0 } ); >+ ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); > } > > # the holdingbranch is updated if the document is returned to another location. > # this is always done regardless of whether the item was on loan or not >- my $item_holding_branch = $item->{ holdingbranch }; >- if ($item->{'holdingbranch'} ne $branch) { >- UpdateHoldingbranch($branch, $item->{'itemnumber'}); >- $item->{'holdingbranch'} = $branch; # update item data holdingbranch too >+ my $item_holding_branch = $item->holdingbranch; >+ if ($item->holdingbranch ne $branch) { >+ UpdateHoldingbranch($branch, $item->itemnumber); >+ $item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later > } >- ModDateLastSeen( $item->{'itemnumber'} ); >+ ModDateLastSeen( $item->itemnumber ); > > # check if we have a transfer for this document >- my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->{'itemnumber'} ); >+ my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); > > # if we have a transfer to do, we update the line of transfers with the datearrived >- my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->{'itemnumber'} ); >+ my $is_in_rotating_collection = C4::RotatingCollections::isItemInAnyCollection( $item->itemnumber ); > if ($datesent) { > if ( $tobranch eq $branch ) { > my $sth = C4::Context->dbh->prepare( > "UPDATE branchtransfers SET datearrived = now() WHERE itemnumber= ? AND datearrived IS NULL" > ); >- $sth->execute( $item->{'itemnumber'} ); >+ $sth->execute( $item->itemnumber ); > # if we have a reservation with valid transfer, we can set it's status to 'W' >- ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); >- C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W'); >+ ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); >+ C4::Reserves::ModReserveStatus($item->itemnumber, 'W'); > } else { > $messages->{'WrongTransfer'} = $tobranch; >- $messages->{'WrongTransferItem'} = $item->{'itemnumber'}; >+ $messages->{'WrongTransferItem'} = $item->itemnumber; > } > $validTransfert = 1; > } else { >- ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") ); >+ ShelfToCart( $item->itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); > } > > # fix up the accounts..... >- if ( $item->{'itemlost'} ) { >+ if ( $item->itemlost ) { > $messages->{'WasLost'} = 1; > unless ( C4::Context->preference("BlockReturnOfLostItems") ) { > if ( > Koha::RefundLostItemFeeRules->should_refund( > { > current_branch => C4::Context->userenv->{branch}, >- item_home_branch => $item->{homebranch}, >+ item_home_branch => $item->homebranch, > item_holding_branch => $item_holding_branch > } > ) > ) > { >- _FixAccountForLostAndReturned( $item->{'itemnumber'}, >+ _FixAccountForLostAndReturned( $item->itemnumber, > $borrowernumber, $barcode ); > $messages->{'LostItemFeeRefunded'} = 1; > } >@@ -1983,14 +1985,14 @@ sub AddReturn { > > # fix up the overdues in accounts... > if ($borrowernumber) { >- my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); >- defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined >+ my $fix = _FixOverduesOnReturn($borrowernumber, $item->itemnumber, $exemptfine, $dropbox); >+ defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->itemnumber...) failed!"; # zero is OK, check defined > > if ( $issue and $issue->is_overdue ) { > # fix fine days > $today = dt_from_string($return_date) if $return_date; > $today = $dropboxdate if $dropbox; >- my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item, dt_from_string($issue->date_due), $today ); >+ my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $today ); > if ($reminder){ > $messages->{'PrevDebarred'} = $debardate; > } else { >@@ -2015,7 +2017,7 @@ sub AddReturn { > # if we don't have a reserve with the status W, we launch the Checkreserves routine > my ($resfound, $resrec); > my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds >- ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'withdrawn'} ); >+ ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); > if ($resfound) { > $resrec->{'ResFound'} = $resfound; > $messages->{'ResFound'} = $resrec; >@@ -2028,7 +2030,7 @@ sub AddReturn { > itemnumber => $itemnumber, > itemtype => $itemtype, > borrowernumber => $borrowernumber, >- ccode => $item->{ ccode } >+ ccode => $item->ccode, > }); > > # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then. >@@ -2037,19 +2039,19 @@ sub AddReturn { > my %conditions = ( > branchcode => $branch, > categorycode => $patron->categorycode, >- item_type => $item->{itype}, >+ item_type => $itemtype, > notification => 'CHECKIN', > ); > if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { > SendCirculationAlert({ > type => 'CHECKIN', >- item => $item, >+ item => $item_unblessed, > borrower => $patron->unblessed, > branch => $branch, > }); > } > >- logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) >+ logaction("CIRCULATION", "RETURN", $borrowernumber, $item->itemnumber) > if C4::Context->preference("ReturnLog"); > } > >@@ -2065,13 +2067,14 @@ sub AddReturn { > > # Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer > if (!$is_in_rotating_collection && ($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){ >+ my $BranchTransferLimitsType = C4::Context->preference("BranchTransferLimitsType"); > if (C4::Context->preference("AutomaticItemReturn" ) or > (C4::Context->preference("UseBranchTransferLimits") and >- ! IsBranchTransferAllowed($branch, $returnbranch, $item->{C4::Context->preference("BranchTransferLimitsType")} ) >+ ! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) > )) { >- $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $returnbranch; >- $debug and warn "item: " . Dumper($item); >- ModItemTransfer($item->{'itemnumber'}, $branch, $returnbranch); >+ $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; >+ $debug and warn "item: " . Dumper($item_unblessed); >+ ModItemTransfer($item->itemnumber, $branch, $returnbranch); > $messages->{'WasTransfered'} = 1; > } else { > $messages->{'NeedsTransfer'} = $returnbranch; >@@ -2589,7 +2592,7 @@ sub CanBookBeRenewed { > my $dbh = C4::Context->dbh; > my $renews = 1; > >- my $item = GetItem($itemnumber) or return ( 0, 'no_item' ); >+ my $item = Koha::Items->find($itemnumber) or return ( 0, 'no_item' ); > my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); > return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; > >@@ -2645,7 +2648,7 @@ sub CanBookBeRenewed { > my @reservable; > my %borrowers; > ITEM: foreach my $i (@itemnumbers) { >- my $item = GetItem($i); >+ my $item = Koha::Items->find($i)->unblessed; > next if IsItemOnHoldAndFound($i); > for my $b (@borrowernumbers) { > my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed; >@@ -2666,10 +2669,10 @@ sub CanBookBeRenewed { > > return ( 1, undef ) if $override_limit; > >- my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); >+ my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $patron->categorycode, >- itemtype => $item->{itype}, >+ itemtype => $item->effective_itemtype, > branchcode => $branchcode > } > ); >@@ -2793,15 +2796,13 @@ sub AddRenewal { > my $datedue = shift; > my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); > >- my $item = GetItem($itemnumber) or return; >- my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item >- my $biblio = $item_object->biblio; >+ my $item = Koha::Items->find($itemnumber) or return; >+ my $biblio = $item->biblio; >+ my $issue = $item->checkout; >+ my $item_unblessed = $item->unblessed; > > my $dbh = C4::Context->dbh; > >- # Find the issues record for this book >- my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); >- > return unless $issue; > > $borrowernumber ||= $issue->borrowernumber; >@@ -2815,7 +2816,7 @@ sub AddRenewal { > my $patron_unblessed = $patron->unblessed; > > if ( C4::Context->preference('CalculateFinesOnReturn') && $issue->is_overdue ) { >- _CalculateAndUpdateFine( { issue => $issue, item => $item, borrower => $patron_unblessed } ); >+ _CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed } ); > } > _FixOverduesOnReturn( $borrowernumber, $itemnumber ); > >@@ -2824,11 +2825,11 @@ sub AddRenewal { > # based on the value of the RenewalPeriodBase syspref. > unless ($datedue) { > >- my $itemtype = $item_object->effective_itemtype; >+ my $itemtype = $item->effective_itemtype; > $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? > dt_from_string( $issue->date_due, 'sql' ) : > DateTime->now( time_zone => C4::Context->tz()); >- $datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item, $patron_unblessed), $patron_unblessed, 'is a renewal'); >+ $datedue = CalcDateDue($datedue, $itemtype, _GetCircControlBranch($item_unblessed, $patron_unblessed), $patron_unblessed, 'is a renewal'); > } > > # Update the issues record to have the new due date, and a new count >@@ -2842,8 +2843,8 @@ sub AddRenewal { > $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); > > # Update the renewal count on the item, and tell zebra to reindex >- $renews = $item->{renewals} + 1; >- ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber, { log_action => 0 } ); >+ $renews = $item->renewals + 1; >+ ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->biblionumber, $itemnumber, { log_action => 0 } ); > > # Charge a new rental fee, if applicable? > my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); >@@ -2858,7 +2859,7 @@ sub AddRenewal { > VALUES (now(),?,?,?,?,?,?,?,?)" > ); > $sth->execute( $borrowernumber, $accountno, $charge, $manager_id, >- "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}", >+ "Renewal of Rental Item " . $biblio->title . " " . $item->barcode, > 'Rent', $charge, $itemnumber ); > } > >@@ -2868,14 +2869,14 @@ sub AddRenewal { > my %conditions = ( > branchcode => $branch, > categorycode => $patron->categorycode, >- item_type => $item->{itype}, >+ item_type => $item->effective_itemtype, > notification => 'CHECKOUT', > ); > if ( $circulation_alert->is_enabled_for( \%conditions ) ) { > SendCirculationAlert( > { > type => 'RENEWAL', >- item => $item, >+ item => $item_unblessed, > borrower => $patron->unblessed, > branch => $branch, > } >@@ -2903,10 +2904,10 @@ sub AddRenewal { > type => 'renew', > amount => $charge, > itemnumber => $itemnumber, >- itemtype => $item->{itype}, >- location => $item->{location}, >+ itemtype => $item->effective_itemtype, >+ location => $item->location, > borrowernumber => $borrowernumber, >- ccode => $item->{'ccode'} >+ ccode => $item->ccode, > } > ); > >@@ -2924,7 +2925,7 @@ sub GetRenewCount { > my $renewsleft = 0; > > my $patron = Koha::Patrons->find( $bornum ); >- my $item = GetItem($itemno); >+ my $item = Koha::Items->find($itemno); > > return (0, 0, 0) unless $patron or $item; # Wrong call, no renewal allowed > >@@ -2941,11 +2942,11 @@ sub GetRenewCount { > my $data = $sth->fetchrow_hashref; > $renewcount = $data->{'renewals'} if $data->{'renewals'}; > # $item and $borrower should be calculated >- my $branchcode = _GetCircControlBranch($item, $patron->unblessed); >+ my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); > > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $patron->categorycode, >- itemtype => $item->{itype}, >+ itemtype => $item->effective_itemtype, > branchcode => $branchcode > } > ); >@@ -2980,17 +2981,17 @@ sub GetSoonestRenewDate { > > my $dbh = C4::Context->dbh; > >- my $item = GetItem($itemnumber) or return; >- my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; >+ my $item = Koha::Items->find($itemnumber) or return; >+ my $itemissue = $item->checkout or return; > > $borrowernumber ||= $itemissue->borrowernumber; > my $patron = Koha::Patrons->find( $borrowernumber ) > or return; > >- my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); >+ my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $patron->categorycode, >- itemtype => $item->{itype}, >+ itemtype => $item->effective_itemtype, > branchcode => $branchcode > } > ); >@@ -3039,17 +3040,17 @@ sub GetLatestAutoRenewDate { > > my $dbh = C4::Context->dbh; > >- my $item = GetItem($itemnumber) or return; >- my $itemissue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; >+ my $item = Koha::Items->find($itemnumber) or return; >+ my $itemissue = $item->checkout or return; > > $borrowernumber ||= $itemissue->borrowernumber; > my $patron = Koha::Patrons->find( $borrowernumber ) > or return; > >- my $branchcode = _GetCircControlBranch( $item, $patron->unblessed ); >+ my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $patron->categorycode, >- itemtype => $item->{itype}, >+ itemtype => $item->effective_itemtype, > branchcode => $branchcode > } > ); >@@ -3626,8 +3627,8 @@ sub ReturnLostItem{ > > MarkIssueReturned( $borrowernumber, $itemnum ); > my $patron = Koha::Patrons->find( $borrowernumber ); >- my $item = C4::Items::GetItem( $itemnum ); >- my $old_note = ($item->{'paidfor'} && ($item->{'paidfor'} ne q{})) ? $item->{'paidfor'}.' / ' : q{}; >+ my $item = Koha::Items->find($itemnum); >+ my $old_note = ($item->paidfor && ($item->paidfor ne q{})) ? $item->paidfor.' / ' : q{}; > my @datearr = localtime(time); > my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3]; > my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber; >@@ -3815,8 +3816,12 @@ sub ProcessOfflinePayment { > sub TransferSlip { > my ($branch, $itemnumber, $barcode, $to_branch) = @_; > >- my $item = GetItem( $itemnumber, $barcode ) >- or return; >+ my $item = >+ $itemnumber >+ ? Koha::Items->find($itemnumber) >+ : Koha::Items->find( { barcode => $barcode } ); >+ >+ $item or return; > > return C4::Letters::GetPreparedLetter ( > module => 'circulation', >@@ -3824,8 +3829,8 @@ sub TransferSlip { > branchcode => $branch, > tables => { > 'branches' => $to_branch, >- 'biblio' => $item->{biblionumber}, >- 'items' => $item, >+ 'biblio' => $item->biblionumber, >+ 'items' => $item->unblessed, > }, > ); > } >diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm >index 3a3f422a96..553427992b 100644 >--- a/C4/CourseReserves.pm >+++ b/C4/CourseReserves.pm >@@ -20,7 +20,7 @@ use Modern::Perl; > use List::MoreUtils qw(any); > > use C4::Context; >-use C4::Items qw(GetItem ModItem); >+use C4::Items qw(ModItem); > use C4::Circulation qw(GetOpenIssue); > > use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS); >@@ -572,13 +572,13 @@ sub _UpdateCourseItem { > ## Update fields that didn't have an original value, but now do > ## We must save the original value in course_items, and also > ## update the item fields to the new value >- my $item = GetItem( $course_item->{'itemnumber'} ); >+ my $item = Koha::Items->find($course_item->{'itemnumber'}); > my %mod_params_new; > my %mod_params_old; > foreach (@FIELDS) { > if ( $params{$_} && !$course_item->{$_} ) { > $mod_params_new{$_} = $params{$_}; >- $mod_params_old{$_} = $item->{$_}; >+ $mod_params_old{$_} = $item->$_; > } > } > _ModStoredFields( 'ci_id' => $params{'ci_id'}, %mod_params_old ); >@@ -665,14 +665,14 @@ sub _SwapAllFields { > warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG; > > my $course_item = GetCourseItem( ci_id => $ci_id ); >- my $item = GetItem( $course_item->{'itemnumber'} ); >+ my $item = Koha::Items->find($course_item->{'itemnumber'}); > > my %course_item_fields; > my %item_fields; > foreach (@FIELDS) { > if ( $course_item->{$_} ) { > $course_item_fields{$_} = $course_item->{$_}; >- $item_fields{$_} = $item->{$_}; >+ $item_fields{$_} = $item->$_; > } > } > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index ce525ba64b..1015763dd8 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -29,6 +29,7 @@ use C4::Circulation; > use C4::Members; > use C4::Biblio; > use Koha::DateUtils; >+use Koha::Items; > use Koha::Patrons; > > use List::Util qw(shuffle); >@@ -674,9 +675,9 @@ sub CreatePicklistFromItemMap { > my $reservenotes = $mapped_item->{reservenotes}; > my $item_level = $mapped_item->{item_level}; > >- my $item = GetItem($itemnumber); >- my $barcode = $item->{barcode}; >- my $itemcallnumber = $item->{itemcallnumber}; >+ my $item = Koha::Items->find($itemnumber); >+ my $barcode = $item->barcode; >+ my $itemcallnumber = $item->itemcallnumber; > > my $patron = Koha::Patrons->find( $borrowernumber ); > my $cardnumber = $patron->cardnumber; >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 607c481401..7508e94b2a 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -537,17 +537,17 @@ sub GetServices { > my $borrower = $patron->unblessed; > # Get the item, or return an error code if not found > my $itemnumber = $cgi->param('item_id'); >- my $item = GetItem( $itemnumber ); >- return { code => 'RecordNotFound' } unless $$item{itemnumber}; >+ my $item = Koha::Items->find($itemnumber); >+ return { code => 'RecordNotFound' } unless $item; > > my @availablefor; > > # Reserve level management >- my $biblionumber = $item->{'biblionumber'}; >+ my $biblionumber = $item->biblionumber; > my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber ); > if ($canbookbereserved eq 'OK') { > push @availablefor, 'title level hold'; >- my $canitembereserved = IsAvailableForItemLevelRequest($item, $borrower); >+ my $canitembereserved = IsAvailableForItemLevelRequest($item->unblessed, $borrower); > if ($canitembereserved) { > push @availablefor, 'item level hold'; > } >@@ -570,7 +570,7 @@ sub GetServices { > } > > # Issuing management >- my $barcode = $item->{'barcode'} || ''; >+ my $barcode = $item->barcode || ''; > $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') ); > if ($barcode) { > my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode ); >@@ -609,14 +609,14 @@ sub RenewLoan { > > # Get the item, or return an error code > my $itemnumber = $cgi->param('item_id'); >- my $item = GetItem( $itemnumber ); >- return { code => 'RecordNotFound' } unless $$item{itemnumber}; >+ my $item = Koha::Items->find($itemnumber); >+ return { code => 'RecordNotFound' } unless $item; > > # Add renewal if possible > my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); > if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); } > >- my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; # FIXME should be handled >+ my $issue = $item ? $item->checkout : return; # FIXME should be handled > > # Hashref building > my $out; >@@ -734,11 +734,11 @@ sub HoldItem { > > # Get the item or return an error code > my $itemnumber = $cgi->param('item_id'); >- my $item = GetItem( $itemnumber ); >- return { code => 'RecordNotFound' } unless $$item{itemnumber}; >+ my $item = Koha::Items->find($itemnumber); >+ return { code => 'RecordNotFound' } unless $item; > > # If the biblio does not match the item, return an error code >- return { code => 'RecordNotFound' } if $$item{biblionumber} ne $biblio->biblionumber; >+ return { code => 'RecordNotFound' } if $item->biblionumber ne $biblio->biblionumber; > > # Check for item disponibility > my $canitembereserved = C4::Reserves::CanItemBeReserved( $borrowernumber, $itemnumber ); >@@ -813,25 +813,25 @@ Returns, for an itemnumber, an array containing availability information. > > sub _availability { > my ($itemnumber) = @_; >- my $item = GetItem( $itemnumber, undef, undef ); >+ my $item = Koha::Items->find($itemnumber); > >- if ( not $item->{'itemnumber'} ) { >+ unless ( $item ) { > return ( undef, 'unknown', 'Error: could not retrieve availability for this ID', undef ); > } > >- my $biblionumber = $item->{'biblioitemnumber'}; >- my $library = Koha::Libraries->find( $item->{holdingbranch} ); >+ my $biblionumber = $item->biblioitemnumber; >+ my $library = Koha::Libraries->find( $item->holdingbranch ); > my $location = $library ? $library->branchname : ''; > >- if ( $item->{'notforloan'} ) { >+ if ( $item->notforloan ) { > return ( $biblionumber, 'not available', 'Not for loan', $location ); >- } elsif ( $item->{'onloan'} ) { >+ } elsif ( $item->onloan ) { > return ( $biblionumber, 'not available', 'Checked out', $location ); >- } elsif ( $item->{'itemlost'} ) { >+ } elsif ( $item->itemlost ) { > return ( $biblionumber, 'not available', 'Item lost', $location ); >- } elsif ( $item->{'withdrawn'} ) { >+ } elsif ( $item->withdrawn ) { > return ( $biblionumber, 'not available', 'Item withdrawn', $location ); >- } elsif ( $item->{'damaged'} ) { >+ } elsif ( $item->damaged ) { > return ( $biblionumber, 'not available', 'Item damaged', $location ); > } else { > return ( $biblionumber, 'available', undef, $location ); >diff --git a/C4/Items.pm b/C4/Items.pm >index 360378b32f..ea219c2871 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -189,10 +189,9 @@ sub CartToShelf { > croak "FAILED CartToShelf() - no itemnumber supplied"; > } > >- my $item = GetItem($itemnumber); >- if ( $item->{location} eq 'CART' ) { >- $item->{location} = $item->{permanent_location}; >- ModItem($item, undef, $itemnumber); >+ my $item = Koha::Items->find($itemnumber); >+ if ( $item->location eq 'CART' ) { >+ ModItem({ location => $item->permanent_location}, undef, $itemnumber); > } > } > >@@ -212,9 +211,7 @@ sub ShelfToCart { > croak "FAILED ShelfToCart() - no itemnumber supplied"; > } > >- my $item = GetItem($itemnumber); >- $item->{'location'} = 'CART'; >- ModItem($item, undef, $itemnumber); >+ ModItem({ location => 'CART'}, undef, $itemnumber); > } > > =head2 AddItemFromMarc >@@ -567,12 +564,12 @@ sub ModItem { > > my @fields = qw( itemlost withdrawn damaged ); > >- # Only call GetItem if we need to set an "on" date field >+ # Only retrieve the item if we need to set an "on" date field > if ( $item->{itemlost} || $item->{withdrawn} || $item->{damaged} ) { >- my $pre_mod_item = GetItem( $item->{'itemnumber'} ); >+ my $pre_mod_item = Koha::Items->find( $item->{'itemnumber'} ); > for my $field (@fields) { > if ( defined( $item->{$field} ) >- and not $pre_mod_item->{$field} >+ and not $pre_mod_item->$field > and $item->{$field} ) > { > $item->{ $field . '_on' } = >@@ -1429,13 +1426,12 @@ sub GetMarcItem { > # while the other treats the MARC representation as authoritative > # under certain circumstances. > >- my $itemrecord = GetItem($itemnumber); >+ my $item = Koha::Items->find($itemnumber) or return; > > # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. > # Also, don't emit a subfield if the underlying field is blank. > >- >- return Item2Marc($itemrecord,$biblionumber); >+ return Item2Marc($item->unblessed, $biblionumber); > > } > sub Item2Marc { >@@ -1876,31 +1872,21 @@ sub ItemSafeToDelete { > > my $countanalytics = GetAnalyticsCount($itemnumber); > >- # check that there is no issue on this item before deletion. >- my $sth = $dbh->prepare( >- q{ >- SELECT COUNT(*) FROM issues >- WHERE itemnumber = ? >- } >- ); >- $sth->execute($itemnumber); >- my ($onloan) = $sth->fetchrow; >- >- my $item = GetItem($itemnumber); >+ my $item = Koha::Items->find($itemnumber) or return; > >- if ($onloan) { >+ if ($item->checkout) { > $status = "book_on_loan"; > } > elsif ( defined C4::Context->userenv > and !C4::Context->IsSuperLibrarian() > and C4::Context->preference("IndependentBranches") >- and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) ) >+ and ( C4::Context->userenv->{branch} ne $item->homebranch ) ) > { > $status = "not_same_branch"; > } > else { > # check it doesn't have a waiting reserve >- $sth = $dbh->prepare( >+ my $sth = $dbh->prepare( > q{ > SELECT COUNT(*) FROM reserves > WHERE (found = 'W' OR found = 'T') >@@ -2785,7 +2771,6 @@ sub ToggleNewStatus { > while ( my $values = $sth->fetchrow_hashref ) { > my $biblionumber = $values->{biblionumber}; > my $itemnumber = $values->{itemnumber}; >- my $item = C4::Items::GetItem( $itemnumber ); > for my $substitution ( @$substitutions ) { > next unless $substitution->{field}; > C4::Items::ModItem( {$substitution->{field} => $substitution->{value}}, $biblionumber, $itemnumber ) >diff --git a/C4/Message.pm b/C4/Message.pm >index 30b71c827c..f0ea6eac9e 100644 >--- a/C4/Message.pm >+++ b/C4/Message.pm >@@ -37,7 +37,7 @@ How to add a new message to the queue: > use C4::Message; > use C4::Items; > my $borrower = { borrowernumber => 1 }; >- my $item = C4::Items::GetItem(1); >+ my $item = Koha::Items->find($itemnumber)->unblessed; > my $letter = C4::Letters::GetPreparedLetter ( > module => 'circulation', > letter_code => 'CHECKOUT', >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index a549c3d751..9040b1d3f1 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -314,14 +314,14 @@ sub CanItemBeReserved { > > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery >- my $item = GetItem($itemnumber); >- my $biblio = Koha::Biblios->find( $item->{biblionumber} ); >+ my $item = Koha::Items->find($itemnumber); >+ my $biblio = $item->biblio; > my $patron = Koha::Patrons->find( $borrowernumber ); > my $borrower = $patron->unblessed; > > # If an item is damaged and we don't allow holds on damaged items, we can stop right here > return 'damaged' >- if ( $item->{damaged} >+ if ( $item->damaged > && !C4::Context->preference('AllowHoldsOnDamagedItems') ); > > # Check for the age restriction >@@ -349,7 +349,7 @@ sub CanItemBeReserved { > > if ( $controlbranch eq "ItemHomeLibrary" ) { > $branchfield = "items.homebranch"; >- $branchcode = $item->{homebranch}; >+ $branchcode = $item->homebranch; > } > elsif ( $controlbranch eq "PatronLibrary" ) { > $branchfield = "borrowers.branchcode"; >@@ -357,7 +357,7 @@ sub CanItemBeReserved { > } > > # we retrieve rights >- if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->{'itype'}, $branchcode ) ) { >+ if ( my $rights = GetHoldRule( $borrower->{'categorycode'}, $item->effective_itemtype, $branchcode ) ) { > $ruleitemtype = $rights->{itemtype}; > $allowedreserves = $rights->{reservesallowed}; > $holds_per_record = $rights->{holds_per_record}; >@@ -366,7 +366,6 @@ sub CanItemBeReserved { > $ruleitemtype = '*'; > } > >- $item = Koha::Items->find( $itemnumber ); > my $holds = Koha::Holds->search( > { > borrowernumber => $borrowernumber, >@@ -412,7 +411,7 @@ sub CanItemBeReserved { > my $circ_control_branch = > C4::Circulation::_GetCircControlBranch( $item->unblessed(), $borrower ); > my $branchitemrule = >- C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->itype ); >+ C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->itype ); # FIXME Should not be item->effective_itemtype? > > if ( $branchitemrule->{holdallowed} == 0 ) { > return 'notReservable'; >@@ -429,8 +428,7 @@ sub CanItemBeReserved { > if ( C4::Context->preference('IndependentBranches') > and !C4::Context->preference('canreservefromotherbranches') ) > { >- my $itembranch = $item->homebranch; >- if ( $itembranch ne $borrower->{branchcode} ) { >+ if ( $item->homebranch ne $borrower->{branchcode} ) { > return 'cannotReserveFromOtherBranches'; > } > } >@@ -475,8 +473,8 @@ sub GetOtherReserves { > my $nextreservinfo; > my ( undef, $checkreserves, undef ) = CheckReserves($itemnumber); > if ($checkreserves) { >- my $iteminfo = GetItem($itemnumber); >- if ( $iteminfo->{'holdingbranch'} ne $checkreserves->{'branchcode'} ) { >+ my $item = Koha::Items->find($itemnumber); >+ if ( $item->holdingbranch ne $checkreserves->{'branchcode'} ) { > $messages->{'transfert'} = $checkreserves->{'branchcode'}; > #minus priorities of others reservs > ModReserveMinusPriority( >@@ -487,7 +485,7 @@ sub GetOtherReserves { > #launch the subroutine dotransfer > C4::Items::ModItemTransfer( > $itemnumber, >- $iteminfo->{'holdingbranch'}, >+ $item->holdingbranch, > $checkreserves->{'branchcode'} > ), > ; >@@ -712,15 +710,15 @@ sub CheckReserves { > } > } else { > my $patron; >- my $iteminfo; >+ my $item; > my $local_hold_match; > > if ($LocalHoldsPriority) { > $patron = Koha::Patrons->find( $res->{borrowernumber} ); >- $iteminfo = C4::Items::GetItem($itemnumber); >+ $item = Koha::Items->find($itemnumber); > > my $local_holds_priority_item_branchcode = >- $iteminfo->{$LocalHoldsPriorityItemControl}; >+ $item->$LocalHoldsPriorityItemControl; > my $local_holds_priority_patron_branchcode = > ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) > ? $res->{branchcode} >@@ -734,14 +732,15 @@ sub CheckReserves { > > # See if this item is more important than what we've got so far > if ( ( $res->{'priority'} && $res->{'priority'} < $priority ) || $local_hold_match ) { >- $iteminfo ||= C4::Items::GetItem($itemnumber); >- next if $res->{itemtype} && $res->{itemtype} ne _get_itype( $iteminfo ); >+ $item ||= Koha::Items->find($itemnumber); >+ next if $res->{itemtype} && $res->{itemtype} ne $item->effective_itemtype; > $patron ||= Koha::Patrons->find( $res->{borrowernumber} ); >- my $branch = GetReservesControlBranch( $iteminfo, $patron->unblessed ); >- my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$iteminfo->{'itype'}); >+ my $branch = GetReservesControlBranch( $item->unblessed, $patron->unblessed ); >+ my $branchitemrule = C4::Circulation::GetBranchItemRule($branch,$item->effective_itemtype); > next if ($branchitemrule->{'holdallowed'} == 0); > next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode)); >- next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $iteminfo->{ $branchitemrule->{hold_fulfillment_policy} }) ); >+ my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy}; >+ next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) ); > $priority = $res->{'priority'}; > $highest = $res; > last if $local_hold_match; >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 6f04257ca6..4dbcc85240 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -128,10 +128,9 @@ if ($AcqCreateItem eq 'receiving') { > ); > } elsif ($AcqCreateItem eq 'ordering') { > my $fw = ($acq_fw) ? 'ACQ' : ''; >- my @itemnumbers = $order_object->items->get_column('itemnumbers'); >- my @items; >- foreach (@itemnumbers) { >- my $item = GetItem($_); # FIXME We do not need this call, we already have the Koha::Items >+ my $items = $order_object->items; >+ while ( my $i = $items->next ) { >+ my $item = $i->unblessed; > my $descriptions; > $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} }); > $item->{notforloan} = $descriptions->{lib} // ''; >@@ -148,8 +147,9 @@ if ($AcqCreateItem eq 'receiving') { > $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); > $item->{materials} = $descriptions->{lib} // ''; > >- my $itemtype = Koha::ItemTypes->find( $item->{itype} ); >+ my $itemtype = Koha::ItemTypes->find($i->effective_itemtype); > if (defined $itemtype) { >+ # We should not do that here, but call ->itemtype->description when needed instead > $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? > } > push @items, $item; >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >index 10df69ef75..ece6acc688 100755 >--- a/catalogue/getitem-ajax.pl >+++ b/catalogue/getitem-ajax.pl >@@ -29,6 +29,7 @@ use C4::Output; > use Koha::Libraries; > > use Koha::AuthorisedValues; >+use Koha::Items; > use Koha::ItemTypes; > > my $cgi = new CGI; >@@ -46,36 +47,38 @@ my $itemnumber = $cgi->param('itemnumber'); > if($itemnumber) { > my $acq_fw = GetMarcStructure(1, 'ACQ'); > my $fw = ($acq_fw) ? 'ACQ' : ''; >- $item = GetItem($itemnumber); >+ $item = Koha::Items->find($itemnumber); >+ my $item_unblessed = $item->unblessed; # FIXME Not needed, call home_branch and holding_branch in the templates instead > >- if($item->{homebranch}) { >- $item->{homebranchname} = Koha::Libraries->find($item->{homebranch})->branchname; >+ if($item->homebranch) { # This test should not be needed, homebranch and holdingbranch are mandatory >+ $item_unblessed->{homebranchname} = $item->home_branch->branchname; > } > >- if($item->{holdingbranch}) { >- $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname; >+ if($item->holdingbranch) { >+ $item_unblessed->{holdingbranchname} = $item->holding_branch->branchname; > } > > my $descriptions; >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} }); >- $item->{notforloan} = $descriptions->{lib} // ''; >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->notforloan }); >+ $item_unblessed->{notforloan} = $descriptions->{lib} // ''; > >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} }); >- $item->{restricted} = $descriptions->{lib} // ''; >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->restricted }); >+ $item_unblessed->{restricted} = $descriptions->{lib} // ''; > >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} }); >- $item->{location} = $descriptions->{lib} // ''; >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->location }); >+ $item_unblessed->{location} = $descriptions->{lib} // ''; > >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} }); >- $item->{collection} = $descriptions->{lib} // ''; >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->collection }); >+ $item_unblessed->{collection} = $descriptions->{lib} // ''; > >- $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} }); >- $item->{materials} = $descriptions->{lib} // ''; >+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->materials }); >+ $item_unblessed->{materials} = $descriptions->{lib} // ''; > >- my $itemtype = Koha::ItemTypes->find( $item->{itype} ); >- $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? >+ my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); >+ # We should not do that here, but call ->itemtype->description when needed instea >+ $item_unblessed->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? > } > >-my $json_text = to_json( $item, { utf8 => 1 } ); >+my $json_text = to_json( $item_unblessed, { utf8 => 1 } ); > > output_with_http_headers $cgi, undef, $json_text, 'json'; >diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl >index f06dfedfb1..7924b2b85e 100755 >--- a/catalogue/updateitem.pl >+++ b/catalogue/updateitem.pl >@@ -44,7 +44,7 @@ my $confirm=$cgi->param('confirm'); > my $dbh = C4::Context->dbh; > > # get the rest of this item's information >-my $item_data_hashref = GetItem($itemnumber, undef); >+my $item_data_hashref = Koha::Items->find($itemnumber)->unblessed; > > # make sure item statuses are set to 0 if empty or NULL > for ($damaged,$itemlost,$withdrawn) { >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 6af351d375..7b82c65471 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -74,15 +74,20 @@ sub get_item_from_barcode { > > sub set_item_default_location { > my $itemnumber = shift; >- my $item = GetItem( $itemnumber ); >+ my $item = Koha::Items->find($itemnumber); > if ( C4::Context->preference('NewItemsDefaultLocation') ) { >- $item->{'permanent_location'} = $item->{'location'}; >- $item->{'location'} = C4::Context->preference('NewItemsDefaultLocation'); >- ModItem( $item, undef, $itemnumber); >+ ModItem( >+ { >+ permanent_location => $item->location, >+ location => C4::Context->preference('NewItemsDefaultLocation') >+ }, >+ undef, >+ $itemnumber >+ ); > } > else { >- $item->{'permanent_location'} = $item->{'location'} if !defined($item->{'permanent_location'}); >- ModItem( $item, undef, $itemnumber); >+ ModItem( { permanent_location => $item->location }, undef, $itemnumber ) >+ unless defined $item->permanent_location; > } > } > >@@ -695,12 +700,12 @@ if ($op eq "additem") { > if ($exist_itemnumber && $exist_itemnumber != $itemnumber) { > push @errors,"barcode_not_unique"; > } else { >- my $item = GetItem( $itemnumber ); >+ my $item = Koha::Items->find($itemnumber ); > my $newitem = ModItemFromMarc($itemtosave, $biblionumber, $itemnumber); > $itemnumber = q{}; >- my $olditemlost = $item->{itemlost}; >+ my $olditemlost = $item->itemlost; > my $newitemlost = $newitem->{itemlost}; >- LostItem( $item->{itemnumber}, 'additem' ) >+ LostItem( $item->itemnumber, 'additem' ) > if $newitemlost && $newitemlost ge '1' && !$olditemlost; > } > $nextop="additem"; >diff --git a/installer/data/mysql/backfill_statistics.pl b/installer/data/mysql/backfill_statistics.pl >index d03b46177d..0264c2c890 100755 >--- a/installer/data/mysql/backfill_statistics.pl >+++ b/installer/data/mysql/backfill_statistics.pl >@@ -79,13 +79,14 @@ my $query = "UPDATE statistics SET itemtype = ? WHERE itemnumber = ?"; > my $update = $dbh->prepare($query); > # $debug and print "Update Query: $query\n"; > foreach (@itemnumbers) { >- my $item = GetItem($_); >- unless ($item) { >+ my $item = Koha::Items->find($_); >+ unless ($item) { > print STDERR "\tNo item found for itemnumber $_\n"; > next; > } >- $update->execute($item->{itype},$_) or warn "Error in UPDATE execution"; >- printf "\titemnumber %5d : %7s (%s rows)\n", $_, $item->{itype}, $update->rows; >+ my $itemtype = $item->effective_itemtype; >+ $update->execute($itemtype,$_) or warn "Error in UPDATE execution"; >+ printf "\titemnumber %5d : %7s (%s rows)\n", $_, $itemtype, $update->rows; > } > > my $old_issues = $dbh->prepare("SELECT * FROM old_issues WHERE timestamp = ? AND itemnumber = ?"); >diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl >index 0026ebe483..7de01117fc 100755 >--- a/labels/label-edit-batch.pl >+++ b/labels/label-edit-batch.pl >@@ -25,7 +25,6 @@ use CGI qw ( -utf8 ); > > use C4::Auth qw(get_template_and_user); > use C4::Output qw(output_html_with_http_headers); >-use C4::Items qw(GetItem); > use C4::Creators; > use C4::Labels; > >@@ -88,7 +87,7 @@ elsif ($op eq 'add') { > my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a <cr> separated list > foreach my $number (@numbers_list) { > $number =~ s/\r$//; # strip any naughty return chars >- if( $number_type eq "itemnumber" && GetItem($number) ) { >+ if( $number_type eq "itemnumber" && Koha::ITems->find($number) ) { > push @item_numbers, $number; > } > elsif ($number_type eq "barcode" ) { # we must test in case an invalid barcode is passed in; we effectively disgard them atm >diff --git a/misc/recreateIssueStatistics.pl b/misc/recreateIssueStatistics.pl >index a4382f191b..e6bf0dea5e 100755 >--- a/misc/recreateIssueStatistics.pl >+++ b/misc/recreateIssueStatistics.pl >@@ -26,6 +26,7 @@ use C4::Context; > use C4::Items; > use Data::Dumper; > use Getopt::Long; >+use Koha::Items; > > my $dbh = C4::Context->dbh; > >@@ -73,7 +74,8 @@ if ($issues == 1) { > my $insert = "INSERT INTO statistics (datetime, branch, value, type, other, itemnumber, itemtype, borrowernumber) > VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; > $substh = $dbh->prepare($insert); >- my $item = GetItem($hashref->{'itemnumber'}); >+ my $item = Koha::Items->find($hashref->{'itemnumber'}); >+ my $itemtype = $item->effective_itemtype; > > $substh->execute( > $hashref->{'issuedate'}, >@@ -82,10 +84,10 @@ if ($issues == 1) { > 'issue', > '', > $hashref->{'itemnumber'}, >- $item->{'itype'}, >+ $itemtype, > $hashref->{'borrowernumber'} > ); >- print "date: $hashref->{'issuedate'} branchcode: $hashref->{'branchcode'} type: issue itemnumber: $hashref->{'itemnumber'} itype: $item->{'itype'} borrowernumber: $hashref->{'borrowernumber'}\n"; >+ print "date: $hashref->{'issuedate'} branchcode: $hashref->{'branchcode'} type: issue itemnumber: $hashref->{'itemnumber'} itype: $itemtype borrowernumber: $hashref->{'borrowernumber'}\n"; > $count_issues++; > } > >@@ -106,7 +108,8 @@ if ($issues == 1) { > my $insert = "INSERT INTO statistics (datetime, branch, value, type, other, itemnumber, itemtype, borrowernumber) > VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; > $substh = $dbh->prepare($insert); >- my $item = GetItem($hashref->{'itemnumber'}); >+ my $item = Koha::Items->find($hashref->{'itemnumber'}); >+ my $itemtype = $item->effective_itemtype; > > $substh->execute( > $hashref->{'lastreneweddate'}, >@@ -115,10 +118,10 @@ if ($issues == 1) { > 'renew', > '', > $hashref->{'itemnumber'}, >- $item->{'itype'}, >+ $itemtype, > $hashref->{'borrowernumber'} > ); >- print "date: $hashref->{'lastreneweddate'} branchcode: $hashref->{'branchcode'} type: renew itemnumber: $hashref->{'itemnumber'} itype: $item->{'itype'} borrowernumber: $hashref->{'borrowernumber'}\n"; >+ print "date: $hashref->{'lastreneweddate'} branchcode: $hashref->{'branchcode'} type: renew itemnumber: $hashref->{'itemnumber'} itype: $itemtype borrowernumber: $hashref->{'borrowernumber'}\n"; > $count_renewals++; > > } >@@ -145,7 +148,8 @@ if ($returns == 1) { > my $insert = "INSERT INTO statistics (datetime, branch, value, type, other, itemnumber, itemtype, borrowernumber) > VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; > $substh = $dbh->prepare($insert); >- my $item = GetItem($hashref->{'itemnumber'}); >+ my $item = Koha::Items->find($hashref->{'itemnumber'}); >+ my $itemtype = $item->effective_itemtype; > > $substh->execute( > $hashref->{'returndate'}, >@@ -154,10 +158,10 @@ if ($returns == 1) { > 'return', > '', > $hashref->{'itemnumber'}, >- $item->{'itype'}, >+ $itemtype, > $hashref->{'borrowernumber'} > ); >- print "date: $hashref->{'returndate'} branchcode: $hashref->{'branchcode'} type: return itemnumber: $hashref->{'itemnumber'} itype: $item->{'itype'} borrowernumber: $hashref->{'borrowernumber'}\n"; >+ print "date: $hashref->{'returndate'} branchcode: $hashref->{'branchcode'} type: return itemnumber: $hashref->{'itemnumber'} itype: $itemtype borrowernumber: $hashref->{'borrowernumber'}\n"; > $count_returns++; > } > >diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl >index 676012ea6f..525db0fc15 100755 >--- a/opac/opac-renew.pl >+++ b/opac/opac-renew.pl >@@ -30,6 +30,7 @@ use C4::Auth; > use C4::Context; > use C4::Items; > use C4::Members; >+use Koha::Items; > use Koha::Patrons; > use Date::Calc qw( Today Date_to_Days ); > my $query = new CGI; >@@ -66,14 +67,14 @@ else { > my $renewalbranch = C4::Context->preference('OpacRenewalBranch'); > my $branchcode; > if ( $renewalbranch eq 'itemhomebranch' ) { >- my $item = GetItem($itemnumber); >- $branchcode = $item->{'homebranch'}; >+ my $item = Koha::Items->find($itemnumber); >+ $branchcode = $item->homebranch; > } > elsif ( $renewalbranch eq 'patronhomebranch' ) { > $branchcode = Koha::Patrons->find( $borrowernumber )->branchcode; > } > elsif ( $renewalbranch eq 'checkoutbranch' ) { >- my $issue = GetOpenIssue($itemnumber); >+ my $issue = GetOpenIssue($itemnumber); # FIXME Should not be $item->checkout? > $branchcode = $issue->{'branchcode'}; > } > elsif ( $renewalbranch eq 'NULL' ) { >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index b2799ea023..0bdb4a5661 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -176,10 +176,10 @@ if ( $op eq 'add_form' ) { > $shelf = Koha::Virtualshelves->find($shelfnumber); > if ($shelf) { > if( my $barcode = $query->param('barcode') ) { >- my $item = GetItem( 0, $barcode); >- if (defined $item && $item->{itemnumber}) { >+ my $item = Koha::Items->find({ barcode => $barcode }); >+ if ( $item ) { > if ( $shelf->can_biblios_be_added( $loggedinuser ) ) { >- my $added = eval { $shelf->add_biblio( $item->{biblionumber}, $loggedinuser ); }; >+ my $added = eval { $shelf->add_biblio( $item->biblionumber, $loggedinuser ); }; > if ($@) { > push @messages, { type => 'error', code => ref($@), msg => $@ }; > } elsif ( $added ) { >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index 9fcf7293b5..bb65d1bebe 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -45,6 +45,7 @@ use C4::Biblio; > use C4::Items; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Acquisition::Currencies; >+use Koha::Items; > use Koha::Patrons; > use Koha::Patron::Images; > use Koha::Patron::Messages; >@@ -104,7 +105,7 @@ my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed) = ( > > my $issuenoconfirm = 1; #don't need to confirm on issue. > my $issuer = Koha::Patrons->find( $issuerid )->unblessed; >-my $item = GetItem(undef,$barcode); >+my $item = Koha::Items->find({ barcode => $barcode }); > if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { > my $dbh = C4::Context->dbh; > my $resval; >@@ -157,7 +158,7 @@ elsif ( $patron and $op eq "checkout" ) { > $template->param( > impossible => $issue_error, > "circ_error_$issue_error" => 1, >- title => $item->{title}, >+ title => $item->biblio->title, # FIXME Need to be backport! GetItem did not return the biblio's title > hide_main => 1, > ); > if ($issue_error eq 'DEBT') { >@@ -174,7 +175,7 @@ elsif ( $patron and $op eq "checkout" ) { > } elsif ( $needconfirm->{RENEW_ISSUE} ) { > if ($confirmed) { > #warn "renewing"; >- AddRenewal( $borrower->{borrowernumber}, $item->{itemnumber} ); >+ AddRenewal( $borrower->{borrowernumber}, $item->itemnumber ); > } else { > #warn "renew confirmation"; > $template->param( >@@ -235,7 +236,7 @@ elsif ( $patron and $op eq "checkout" ) { > $confirm_required = 1; > #warn "issue confirmation"; > $template->param( >- confirm => "Issuing title: " . $item->{title}, >+ confirm => "Issuing title: " . $item->biblio->title, > barcode => $barcode, > hide_main => 1, > inputfocus => 'confirm', >diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl >index 351041b5df..c614200a67 100755 >--- a/reserve/placerequest.pl >+++ b/reserve/placerequest.pl >@@ -31,6 +31,8 @@ use C4::Reserves; > use C4::Circulation; > use C4::Members; > use C4::Auth qw/checkauth/; >+ >+use Koha::Items; > use Koha::Patrons; > > my $input = CGI->new(); >@@ -87,9 +89,9 @@ if ( $type eq 'str8' && $borrower ) { > } > > if ( defined $checkitem && $checkitem ne '' ) { >- my $item = GetItem($checkitem); >- if ( $item->{'biblionumber'} ne $biblionumber ) { >- $biblionumber = $item->{'biblionumber'}; >+ my $item = Koha::Items->find($checkitem); >+ if ( $item->biblionumber ne $biblionumber ) { >+ $biblionumber = $item->biblionumber; > } > } > >diff --git a/svc/checkin b/svc/checkin >index 9b72abaa79..e0dc21c7db 100755 >--- a/svc/checkin >+++ b/svc/checkin >@@ -24,7 +24,7 @@ use CGI; > use JSON qw(to_json); > > use C4::Circulation; >-use C4::Items qw(GetItem ModItem); >+use C4::Items qw(ModItem); > use C4::Context; > use C4::Auth qw(check_cookie_auth); > use Koha::Checkouts; >@@ -64,17 +64,15 @@ $data->{borrowernumber} = $borrowernumber; > $data->{branchcode} = $branchcode; > > if ( C4::Context->preference("InProcessingToShelvingCart") ) { >- my $item = GetItem($itemnumber); >- if ( $item->{'location'} eq 'PROC' ) { >- $item->{'location'} = 'CART'; >- ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); >+ my $item = Koha::Items->find($itemnumber); >+ if ( $item->location eq 'PROC' ) { >+ ModItem( { location => 'CART' }, $item->biblionumber, $item->itemnumber ); > } > } > > if ( C4::Context->preference("ReturnToShelvingCart") ) { >- my $item = GetItem($itemnumber); >- $item->{'location'} = 'CART'; >- ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} ); >+ my $item = Koha::Items->find($itemnumber); >+ ModItem( { location => 'CART' }, $item->biblionumber, $item->itemnumber ); > } > > my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber }); >diff --git a/t/db_dependent/Acquisition/CancelReceipt.t b/t/db_dependent/Acquisition/CancelReceipt.t >index a900885de6..f659e9ef3a 100644 >--- a/t/db_dependent/Acquisition/CancelReceipt.t >+++ b/t/db_dependent/Acquisition/CancelReceipt.t >@@ -31,6 +31,7 @@ use Koha::Database; > use Koha::DateUtils; > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Orders; >+use Koha::Items; > use MARC::Record; > > my $schema = Koha::Database->new()->schema(); >@@ -162,10 +163,10 @@ is( > "Create items on ordering: items are not deleted after cancelling a receipt" > ); > >-my $item1 = C4::Items::GetItem( $itemnumber1 ); >-is( $item1->{notforloan}, 9, "The notforloan value has been updated with '9'" ); >+my $item1 = Koha::Items->find( $itemnumber1 ); >+is( $item1->notforloan, 9, "The notforloan value has been updated with '9'" ); > >-my $item2 = C4::Items::GetItem( $itemnumber2 ); >-is( $item2->{notforloan}, 0, "The notforloan value has been updated with '9'" ); >+my $item2 = Koha::Items->find( $itemnumber2 ); >+is( $item2->notforloan, 0, "The notforloan value has been updated with '9'" ); > > $schema->storage->txn_rollback(); >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 570b385ee1..e3ecbe385e 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -34,6 +34,7 @@ use C4::Overdues qw(UpdateFine CalcFine); > use Koha::DateUtils; > use Koha::Database; > use Koha::IssuingRules; >+use Koha::Items; > use Koha::Checkouts; > use Koha::Patrons; > use Koha::Subscriptions; >@@ -483,7 +484,8 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my $passeddatedue1 = AddIssue($renewing_borrower, $barcode7, $five_weeks_ago); > is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due); > >- my ( $fine ) = CalcFine( GetItem(undef, $barcode7), $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now ); >+ my $item = Koha::Items->find({barcode => $barcode7}); >+ my ( $fine ) = CalcFine( $item->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now ); > C4::Overdues::UpdateFine( > { > issue_id => $passeddatedue1->id(), >@@ -853,7 +855,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > LostItem( $itemnumber, 'test', 1 ); > >- my $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber); >+ $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber); > ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); > my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber }); > is( $checkout, undef, 'LostItem called with forced return has checked in the item' ); >diff --git a/t/db_dependent/Circulation/IsItemIssued.t b/t/db_dependent/Circulation/IsItemIssued.t >index ab26f0c3cb..7e4cf2334e 100644 >--- a/t/db_dependent/Circulation/IsItemIssued.t >+++ b/t/db_dependent/Circulation/IsItemIssued.t >@@ -25,6 +25,7 @@ use C4::Items; > use C4::Biblio; > use Koha::Database; > use Koha::DateUtils; >+use Koha::Items; > use Koha::Patrons; > > use t::lib::TestBuilder; >@@ -68,12 +69,12 @@ my ( undef, undef, $itemnumber ) = AddItem( > $biblionumber > ); > >-my $item = GetItem( $itemnumber ); >+my $item = Koha::Items->find( $itemnumber ); > >-is ( IsItemIssued( $item->{itemnumber} ), 0, "item is not on loan at first" ); >+is ( IsItemIssued( $item->itemnumber ), 0, "item is not on loan at first" ); > > AddIssue($borrower, 'i_dont_exist'); >-is ( IsItemIssued( $item->{itemnumber} ), 1, "item is now on loan" ); >+is ( IsItemIssued( $item->itemnumber ), 1, "item is now on loan" ); > > is( > DelItemCheck( $biblionumber, $itemnumber), >@@ -82,7 +83,7 @@ is( > ); > > AddReturn('i_dont_exist', $library->{branchcode}); >-is ( IsItemIssued( $item->{itemnumber} ), 0, "item has been returned" ); >+is ( IsItemIssued( $item->itemnumber ), 0, "item has been returned" ); > > is( > DelItemCheck( $biblionumber, $itemnumber), >diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t >index 50f733bb52..a162f1f760 100644 >--- a/t/db_dependent/Circulation/Returns.t >+++ b/t/db_dependent/Circulation/Returns.t >@@ -87,17 +87,16 @@ subtest "InProcessingToShelvingCart tests" => sub { > > t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 ); > AddReturn( $barcode, $branch ); >- $item = GetItem( $itemnumber ); >- is( $item->{location}, 'CART', >+ $item = Koha::Items->find( $itemnumber ); >+ is( $item->location, 'CART', > "InProcessingToShelvingCart functions as intended" ); > >- $item->{location} = $location; >- ModItem( $item, undef, $itemnumber ); >+ ModItem( {location => $location}, undef, $itemnumber ); > > t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 ); > AddReturn( $barcode, $branch ); >- $item = GetItem( $itemnumber ); >- is( $item->{location}, $permanent_location, >+ $item = Koha::Items->find( $itemnumber ); >+ is( $item->location, $permanent_location, > "InProcessingToShelvingCart functions as intended" ); > }; > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index f613f081f1..77416ead58 100644 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -32,6 +32,7 @@ use Koha::Checkouts; > use Koha::Database; > use Koha::DateUtils; > use Koha::Holds; >+use Koha::Items; > use Koha::Library; > use Koha::Patrons; > >@@ -358,17 +359,17 @@ my $itemnumber; > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); > AddReturn( 'barcode_3', $branchcode_1 ); >-my $item = GetItem( $itemnumber ); >-ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); >+my $item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); > AddReturn( 'barcode_3', $branchcode_1 ); >-$item = GetItem( $itemnumber ); >-ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); > > AddReturn( 'barcode_3', $branchcode_1 ); >-$item = GetItem( $itemnumber ); >-ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); > > # Bug 14640 - Cancel the hold on checking out if asked > my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber, >diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >index a5237d9aa3..5a7055dd0a 100755 >--- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >+++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >@@ -6,6 +6,7 @@ use C4::Context; > use C4::Circulation; > use C4::Items; > use Koha::IssuingRule; >+use Koha:Items; > > use Test::More tests => 6; > >@@ -79,7 +80,7 @@ my $itemnumber1 = > $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber") > or BAIL_OUT("Cannot find newly created item"); > >-my $item1 = GetItem( $itemnumber1 ); >+my $item1 = Koha::Items->find( $itemnumber1 )->unblessed; > > $dbh->do(" > INSERT INTO items (barcode, biblionumber, biblioitemnumber, homebranch, holdingbranch, notforloan, damaged, itemlost, withdrawn, onloan, itype) >@@ -90,7 +91,7 @@ my $itemnumber2 = > $dbh->selectrow_array("SELECT itemnumber FROM items WHERE biblionumber = $biblionumber ORDER BY itemnumber DESC") > or BAIL_OUT("Cannot find newly created item"); > >-my $item2 = GetItem( $itemnumber2 ); >+my $item2 = Koha::Items->find( $itemnumber2 )->unblessed; > > $dbh->do("DELETE FROM issuingrules"); > my $rule = Koha::IssuingRule->new( >@@ -134,8 +135,9 @@ AddReturn( $item1->{barcode} ); > subtest 'Item is available at a different library' => sub { > plan tests => 4; > >- Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_B, holdingbranch => $library_B })->store; >- $item1 = GetItem( $itemnumber1 ); >+ $item1 = Koha::Items->find( $item1->{itemnumber} ); >+ $item1->set({homebranch => $library_B, holdingbranch => $library_B })->store; >+ $item1 = $item1->unblessed; > #Scenario is: > #One shelf holds is 'If all unavailable'/2 > #Item 1 homebranch library B is available >@@ -174,8 +176,9 @@ AddReturn( $item1->{barcode} ); > subtest 'Item is available at the same library' => sub { > plan tests => 4; > >- Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_A, holdingbranch => $library_A })->store; >- $item1 = GetItem( $itemnumber1 ); >+ $item1 = Koha::Items->find( $item1->{itemnumber} ); >+ $item1->set({homebranch => $library_A, holdingbranch => $library_A })->store; >+ $item1 = $item1->unblessed; > #Scenario is: > #One shelf holds is 'If all unavailable'/2 > #Item 1 homebranch library A is available >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index 92151d662d..9b2ea717e1 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -64,43 +64,43 @@ subtest 'General Add, Get and Del tests' => sub { > cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber."); > > # Get item. >- my $getitem = GetItem($itemnumber); >- cmp_ok($getitem->{'itemnumber'}, '==', $itemnumber, "Retrieved item has correct itemnumber."); >- cmp_ok($getitem->{'biblioitemnumber'}, '==', $item_bibitemnum, "Retrieved item has correct biblioitemnumber."); >- is( $getitem->{location}, $location, "The location should not have been modified" ); >- is( $getitem->{permanent_location}, $location, "The permanent_location should have been set to the location value" ); >+ my $getitem = Koha::Items->find($itemnumber); >+ cmp_ok($getitem->itemnumber, '==', $itemnumber, "Retrieved item has correct itemnumber."); >+ cmp_ok($getitem->biblioitemnumber, '==', $item_bibitemnum, "Retrieved item has correct biblioitemnumber."); >+ is( $getitem->location, $location, "The location should not have been modified" ); >+ is( $getitem->permanent_location, $location, "The permanent_location should have been set to the location value" ); > > # Modify item; setting barcode. > ModItem({ barcode => '987654321' }, $bibnum, $itemnumber); >- my $moditem = GetItem($itemnumber); >- cmp_ok($moditem->{'barcode'}, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->{'barcode'} . '.'); >+ my $moditem = Koha::Items->find($itemnumber); >+ cmp_ok($moditem->barcode, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->barcode . '.'); > > # Delete item. > DelItem({ biblionumber => $bibnum, itemnumber => $itemnumber }); >- my $getdeleted = GetItem($itemnumber); >- is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected."); >+ my $getdeleted = Koha::Items->find($itemnumber); >+ is($getdeleted, undef, "Item deleted as expected."); > > ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location, permanent_location => 'my permanent location', itype => $itemtype->{itemtype} } , $bibnum); >- $getitem = GetItem($itemnumber); >- is( $getitem->{location}, $location, "The location should not have been modified" ); >- is( $getitem->{permanent_location}, 'my permanent location', "The permanent_location should not have modified" ); >+ $getitem = Koha::Items->find($itemnumber); >+ is( $getitem->location, $location, "The location should not have been modified" ); >+ is( $getitem->permanent_location, 'my permanent location', "The permanent_location should not have modified" ); > > ModItem({ location => $location }, $bibnum, $itemnumber); >- $getitem = GetItem($itemnumber); >- is( $getitem->{location}, $location, "The location should have been set to correct location" ); >- is( $getitem->{permanent_location}, $location, "The permanent_location should have been set to location" ); >+ $getitem = Koha::Items->find($itemnumber); >+ is( $getitem->location, $location, "The location should have been set to correct location" ); >+ is( $getitem->permanent_location, $location, "The permanent_location should have been set to location" ); > > ModItem({ location => 'CART' }, $bibnum, $itemnumber); >- $getitem = GetItem($itemnumber); >- is( $getitem->{location}, 'CART', "The location should have been set to CART" ); >- is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" ); >+ $getitem = Koha::Items->find($itemnumber); >+ is( $getitem->location, 'CART', "The location should have been set to CART" ); >+ is( $getitem->permanent_location, $location, "The permanent_location should not have been set to CART" ); > > t::lib::Mocks::mock_preference('item-level_itypes', '1'); >- $getitem = GetItem($itemnumber); >- is( $getitem->{itype}, $itemtype->{itemtype}, "Itemtype set correctly when using item-level_itypes" ); >+ $getitem = Koha::Items->find($itemnumber); >+ is( $getitem->effective_itemtype, $itemtype->{itemtype}, "Itemtype set correctly when using item-level_itypes" ); > t::lib::Mocks::mock_preference('item-level_itypes', '0'); >- $getitem = GetItem($itemnumber); >- is( $getitem->{itype}, undef, "Itemtype set correctly when not using item-level_itypes" ); >+ $getitem = Koha::Items->find($itemnumber); >+ is( $getitem->effective_itemtype, undef, "Itemtype set correctly when not using item-level_itypes" ); > > $schema->storage->txn_rollback; > }; >@@ -188,8 +188,8 @@ subtest 'GetHiddenItemnumbers tests' => sub { > my @itemnumbers = ($item1_itemnumber,$item2_itemnumber); > my @hidden; > my @items; >- push @items, GetItem( $item1_itemnumber ); >- push @items, GetItem( $item2_itemnumber ); >+ push @items, Koha::Items->find( $item1_itemnumber )->unblessed; >+ push @items, Koha::Items->find( $item2_itemnumber )->unblessed; > > # Empty OpacHiddenItems > t::lib::Mocks::mock_preference('OpacHiddenItems',''); >@@ -488,8 +488,8 @@ subtest 'SearchItems test' => sub { > ModItemFromMarc($item3_record, $biblionumber, $item3_itemnumber); > > # Make sure the link is used >- my $item3 = GetItem($item3_itemnumber); >- ok($item3->{itemnotes} eq 'foobar', 'itemnotes eq "foobar"'); >+ my $item3 = Koha::Items->find($item3_itemnumber); >+ ok($item3->itemnotes eq 'foobar', 'itemnotes eq "foobar"'); > > # Do the same search again. > # This time it will search in items.itemnotes >@@ -685,21 +685,21 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { > my (undef, undef, $item_itemnumber) = AddItemFromMarc($item_record, $biblionumber); > > # Make sure everything has been set up >- my $item = GetItem($item_itemnumber); >- is( $item->{barcode}, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' ); >+ my $item = Koha::Items->find($item_itemnumber); >+ is( $item->barcode, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' ); > > # Delete the barcode field and save the record > $item_record->delete_fields( $barcode_field ); > $item_record->append_fields( $itemtype_field ); # itemtype is mandatory > ModItemFromMarc($item_record, $biblionumber, $item_itemnumber); >- $item = GetItem($item_itemnumber); >- is( $item->{barcode}, undef, 'The default value should have been set to the barcode, the field is mapped to a kohafield' ); >+ $item = Koha::Items->find($item_itemnumber); >+ is( $item->barcode, undef, 'The default value should have been set to the barcode, the field is mapped to a kohafield' ); > > # Re-add the barcode field and save the record > $item_record->append_fields( $barcode_field ); > ModItemFromMarc($item_record, $biblionumber, $item_itemnumber); >- $item = GetItem($item_itemnumber); >- is( $item->{barcode}, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' ); >+ $item = Koha::Items->find($item_itemnumber); >+ is( $item->barcode, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' ); > > # Remove the mapping for barcode > Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'p' })->delete; >@@ -719,8 +719,8 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { > $item_record->append_fields( $another_barcode_field ); > # The DB value should not have been updated > ModItemFromMarc($item_record, $biblionumber, $item_itemnumber); >- $item = GetItem($item_itemnumber); >- is ( $item->{barcode}, $a_barcode, 'items.barcode is not mapped anymore, so the DB column has not been updated' ); >+ $item = Koha::Items->find($item_itemnumber); >+ is ( $item->barcode, $a_barcode, 'items.barcode is not mapped anymore, so the DB column has not been updated' ); > > $cache->clear_from_cache("default_value_for_mod_marc-"); > $cache->clear_from_cache( "MarcSubfieldStructure-" ); >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index 17172be5d2..fad82fc67c 100644 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -11,6 +11,7 @@ use C4::Items; > use C4::Biblio; > use C4::Context; > use Koha::DateUtils; >+use Koha::Items; > use t::lib::TestBuilder; > > my $schema = Koha::Database->new->schema; >@@ -61,8 +62,8 @@ my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem( > $biblionumber > ); > >-my $item = C4::Items::GetItem( $itemnumber ); >-is ( $item->{new_status}, 'new_value', q|AddItem insert the 'new_status' field| ); >+my $item = Koha::Items->find( $itemnumber ); >+is ( $item->new_status, 'new_value', q|AddItem insert the 'new_status' field| ); > > my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', $frameworkcode); > my $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); >@@ -89,8 +90,8 @@ my @rules = ( > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-my $modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'updated_value', q|ToggleNewStatus: The new_status value is updated|); >+my $modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'updated_value', q|ToggleNewStatus: The new_status value is updated|); > $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); > is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new_status value is updated| ); > >@@ -115,18 +116,16 @@ is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNew > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'updated_value', q|ToggleNewStatus: The new_status value is not updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'updated_value', q|ToggleNewStatus: The new_status value is not updated|); > $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); > is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new_status value is not updated| ); > > # Play with age >-$item = C4::Items::GetItem( $itemnumber ); > my $dt_today = dt_from_string; > my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) ); > > C4::Items::ModItem( { dateaccessioned => $days5ago }, $biblionumber, $itemnumber ); >-$item = C4::Items::GetItem( $itemnumber ); > > @rules = ( > { >@@ -146,26 +145,26 @@ $item = C4::Items::GetItem( $itemnumber ); > }, > ); > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'updated_value', q|ToggleNewStatus: Age = 10 : The new_status value is not updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'updated_value', q|ToggleNewStatus: Age = 10 : The new_status value is not updated|); > > $rules[0]->{age} = 5; > $rules[0]->{substitutions}[0]{value} = 'new_updated_value5'; > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_updated_value5', q|ToggleNewStatus: Age = 5 : The new_status value is updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_updated_value5', q|ToggleNewStatus: Age = 5 : The new_status value is updated|); > > $rules[0]->{age} = ''; > $rules[0]->{substitutions}[0]{value} = 'new_updated_value_empty_string'; > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_updated_value_empty_string', q|ToggleNewStatus: Age = '' : The new_status value is updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_updated_value_empty_string', q|ToggleNewStatus: Age = '' : The new_status value is updated|); > > $rules[0]->{age} = undef; > $rules[0]->{substitutions}[0]{value} = 'new_updated_value_undef'; > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_updated_value_undef', q|ToggleNewStatus: Age = undef : The new_status value is updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_updated_value_undef', q|ToggleNewStatus: Age = undef : The new_status value is updated|); > > # Field deletion > @rules = ( >@@ -188,8 +187,8 @@ is( $modified_item->{new_status}, 'new_updated_value_undef', q|ToggleNewStatus: > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, '', q|ToggleNewStatus: The new_status value is empty|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, '', q|ToggleNewStatus: The new_status value is empty|); > $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); > is( $marc_item->subfield($tagfield, $new_tagfield), undef, q|ToggleNewStatus: The new_status field is removed from the item marc| ); > >@@ -218,8 +217,8 @@ is( $marc_item->subfield($tagfield, $new_tagfield), undef, q|ToggleNewStatus: Th > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_value', q|ToggleNewStatus: conditions multiple: all match, the new_status value is updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_value', q|ToggleNewStatus: conditions multiple: all match, the new_status value is updated|); > > @rules = ( > { >@@ -245,8 +244,8 @@ is( $modified_item->{new_status}, 'new_value', q|ToggleNewStatus: conditions mul > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_value', q|ToggleNewStatus: conditions multiple: at least 1 condition does not match, the new_status value is not updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_value', q|ToggleNewStatus: conditions multiple: at least 1 condition does not match, the new_status value is not updated|); > > @rules = ( > { >@@ -272,8 +271,8 @@ is( $modified_item->{new_status}, 'new_value', q|ToggleNewStatus: conditions mul > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'new_updated_value', q|ToggleNewStatus: conditions multiple: the 2 conditions match, the new_status value is updated|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'new_updated_value', q|ToggleNewStatus: conditions multiple: the 2 conditions match, the new_status value is updated|); > > @rules = ( > { >@@ -295,8 +294,8 @@ is( $modified_item->{new_status}, 'new_updated_value', q|ToggleNewStatus: condit > > C4::Items::ToggleNewStatus( { rules => \@rules } ); > >-$modified_item = C4::Items::GetItem( $itemnumber ); >-is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|); >+$modified_item = Koha::Items->find( $itemnumber ); >+is( $modified_item->new_status, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|); > > # Clear cache > $cache = Koha::Caches->get_instance(); >diff --git a/t/db_dependent/Items/DelItem.t b/t/db_dependent/Items/DelItem.t >index 03f1f5840e..94262204c5 100644 >--- a/t/db_dependent/Items/DelItem.t >+++ b/t/db_dependent/Items/DelItem.t >@@ -4,6 +4,8 @@ use MARC::Record; > use C4::Items; > use C4::Biblio; > >+use Koha::Items; >+ > use t::lib::TestBuilder; > > use Test::More tests => 6; >@@ -24,15 +26,15 @@ my ( $item_bibnum, $item_bibitemnum, $itemnumber ); > > my $deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } ); > is( $deleted, 1, "DelItem should return 1 if the item has been deleted" ); >-my $deleted_item = GetItem($itemnumber); >-is( $deleted_item->{itemnumber}, undef, "DelItem with biblionumber parameter - the item should be deleted." ); >+my $deleted_item = Koha::Items->find($itemnumber); >+is( $deleted_item, undef, "DelItem with biblionumber parameter - the item should be deleted." ); > > ( $item_bibnum, $item_bibitemnum, $itemnumber ) = > AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblionumber ); > $deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } ); > is( $deleted, 1, "DelItem should return 1 if the item has been deleted" ); >-$deleted_item = GetItem($itemnumber); >-is( $deleted_item->{itemnumber}, undef, "DelItem without biblionumber parameter - the item should be deleted." ); >+$deleted_item = Koha::Items->find($itemnumber); >+is( $deleted_item, undef, "DelItem without biblionumber parameter - the item should be deleted." ); > > $deleted = DelItem( { itemnumber => $itemnumber + 1} ); > is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" ); >diff --git a/t/db_dependent/Items/MoveItemFromBiblio.t b/t/db_dependent/Items/MoveItemFromBiblio.t >index 21855d91da..fec7e51442 100644 >--- a/t/db_dependent/Items/MoveItemFromBiblio.t >+++ b/t/db_dependent/Items/MoveItemFromBiblio.t >@@ -22,6 +22,7 @@ use C4::Items; > use C4::Reserves; > use Koha::Database; > use Koha::Holds; >+use Koha::Items; > > use t::lib::TestBuilder; > use Data::Dumper qw|Dumper|; >@@ -79,12 +80,12 @@ $to_biblionumber_after_moved = C4::Items::MoveItemFromBiblio( $item2->{itemnumbe > > is( $to_biblionumber_after_moved, undef, 'MoveItemFromBiblio should return undef if the move has failed. If called twice, the item is not attached to the first biblio anymore' ); > >-my $get_item1 = C4::Items::GetItem( $item1->{itemnumber} ); >-is( $get_item1->{biblionumber}, $from_biblio->{biblionumber}, 'The item1 should not have been moved' ); >-my $get_item2 = C4::Items::GetItem( $item2->{itemnumber} ); >-is( $get_item2->{biblionumber}, $to_biblio->{biblionumber}, 'The item2 should have been moved' ); >-my $get_item3 = C4::Items::GetItem( $item3->{itemnumber} ); >-is( $get_item3->{biblionumber}, $to_biblio->{biblionumber}, 'The item3 should not have been moved' ); >+my $get_item1 = Koha::Items->find( $item1->{itemnumber} ); >+is( $get_item1->biblionumber, $from_biblio->{biblionumber}, 'The item1 should not have been moved' ); >+my $get_item2 = Koha::Items->find( $item2->{itemnumber} ); >+is( $get_item2->biblionumber, $to_biblio->{biblionumber}, 'The item2 should have been moved' ); >+my $get_item3 = Koha::Items->find( $item3->{itemnumber} ); >+is( $get_item3->biblionumber, $to_biblio->{biblionumber}, 'The item3 should not have been moved' ); > > my $get_bib_level_hold = Koha::Holds->find( $bib_level_hold_not_to_move->{reserve_id} ); > my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{reserve_id} ); >diff --git a/t/db_dependent/Items_DelItemCheck.t b/t/db_dependent/Items_DelItemCheck.t >index 57514d0491..ce06dfe629 100644 >--- a/t/db_dependent/Items_DelItemCheck.t >+++ b/t/db_dependent/Items_DelItemCheck.t >@@ -19,6 +19,7 @@ use Modern::Perl; > > use C4::Circulation; > use Koha::Database; >+use Koha::Items; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -159,9 +160,9 @@ is( > > DelItemCheck( $biblio->{biblionumber}, $item->{itemnumber} ); > >-my $test_item = GetItem( $item->{itemnumber} ); >+my $test_item = Koha::Items->find( $item->{itemnumber} ); > >-is( $test_item->{itemnumber}, undef, >+is( $test_item, undef, > "DelItemCheck should delete item if ItemSafeToDelete returns true" > ); > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index a458e8daa8..02a971c6be 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -35,6 +35,7 @@ use C4::Reserves; > use Koha::Caches; > use Koha::DateUtils; > use Koha::Holds; >+use Koha::Items; > use Koha::Libraries; > use Koha::Notice::Templates; > use Koha::Patrons; >@@ -539,7 +540,7 @@ is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 'OK', "Res > ####### EO Bug 13113 <<< > #### > >-$item = GetItem($itemnumber); >+$item = Koha::Items->find($itemnumber)->unblessed; > > ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" ); > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 2afb35e0d6..b86b5e27af 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -175,7 +175,9 @@ if ($op eq "action") { > foreach my $itemnumber(@itemnumbers){ > > $job->progress($i) if $runinbackground; >- my $itemdata = GetItem($itemnumber); >+ my $itemdata = Koha::Items->find($itemnumber); >+ next unless $itemdata; # Should have been tested earlier, but just in case... >+ $itemdata = $itemdata->unblessed; > if ( $del ){ > my $return = DelItemCheck( $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'}); > if ($return == 1) { >@@ -534,7 +536,9 @@ sub BuildItemsData{ > my ( $itemtagfield, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", ""); > my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", ""); > foreach my $itemnumber (@itemnumbers){ >- my $itemdata=GetItem($itemnumber); >+ my $itemdata = Koha::Items->find($itemnumber); >+ next unless $itemdata; # Should have been tested earlier, but just in case... >+ $itemdata = $itemdata->unblessed; > my $itemmarc=Item2Marc($itemdata); > my %this_row; > foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) { >diff --git a/tools/inventory.pl b/tools/inventory.pl >index 3da000afc0..fcc21d15fa 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -39,6 +39,7 @@ use Koha::Biblios; > use Koha::DateUtils; > use Koha::AuthorisedValues; > use Koha::BiblioFrameworks; >+use Koha::Items; > use List::MoreUtils qw( none ); > > my $minlocation=$input->param('minlocation') || ''; >@@ -184,8 +185,9 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { > if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) { > push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 }; > } else { >- my $item = GetItem( '', $barcode ); >- if ( defined $item && $item->{'itemnumber'} ) { >+ my $item = Koha::Items->find({barcode => $barcode}); >+ if ( $item ) { >+ $item = $item->unblessed; > # Modify date last seen for scanned items, remove lost status > ModItem( { itemlost => 0, datelastseen => $date }, undef, $item->{'itemnumber'} ); > $moddatecount++; >diff --git a/tools/viewlog.pl b/tools/viewlog.pl >index e9e9f423ef..ca36d1b5f6 100755 >--- a/tools/viewlog.pl >+++ b/tools/viewlog.pl >@@ -30,6 +30,8 @@ use C4::Log; > use C4::Items; > use C4::Debug; > use C4::Search; # enabled_staff_search_views >+ >+use Koha::Items; > use Koha::Patrons; > > use vars qw($debug $cgi_debug); >@@ -118,11 +120,11 @@ if ($do_it) { > # get item information so we can create a working link > my $itemnumber = $result->{'object'}; > $itemnumber = $result->{'info'} if ( $result->{module} eq "CIRCULATION" ); >- my $item = GetItem($itemnumber); >+ my $item = Koha::Items->find($itemnumber); > if ($item) { >- $result->{'biblionumber'} = $item->{'biblionumber'}; >- $result->{'biblioitemnumber'} = $item->{'biblionumber'}; >- $result->{'barcode'} = $item->{'barcode'}; >+ $result->{'biblionumber'} = $item->biblionumber; >+ $result->{'biblioitemnumber'} = $item->biblionumber; >+ $result->{'barcode'} = $item->barcode; > } > } > >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index 192580f857..09a48b784d 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -29,6 +29,7 @@ use C4::XSLT; > > use Koha::Biblios; > use Koha::Biblioitems; >+use Koha::Items; > use Koha::ItemTypes; > use Koha::CsvProfiles; > use Koha::Patrons; >@@ -151,9 +152,9 @@ if ( $op eq 'add_form' ) { > foreach my $barcode (@barcodes){ > $barcode =~ s/\r$//; # strip any naughty return chars > next if $barcode eq ''; >- my $item = GetItem( 0, $barcode); >- if (defined $item && $item->{itemnumber}) { >- my $added = eval { $shelf->add_biblio( $item->{biblionumber}, $loggedinuser ); }; >+ my $item = Koha::Items->find({barcode => $barcode}); >+ if ( $item ) { >+ my $added = eval { $shelf->add_biblio( $item->biblionumber, $loggedinuser ); }; > if ($@) { > push @messages, { item_barcode => $barcode, type => 'alert', code => ref($@), msg => $@ }; > } elsif ( $added ) { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21206
:
77699
|
77700
|
77701
|
78080
|
78081
|
78082
|
78153
|
78154
|
78155
|
82831
|
82832
|
82833
|
82834
|
84006
|
84007
|
84008
|
84009
|
84010
|
84184
|
84185
|
84186
|
84187
|
84188
|
85163
|
85164
|
85165
|
85166
|
85167
|
85168