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 Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
e47fa012f6
commit
31c29fd31f
15
C4/Biblio.pm
15
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
|
||||
|
|
@ -2825,8 +2824,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 @items2pass = map { $_->{item} } @items;
|
||||
my @hiddenitems =
|
||||
|
|
|
|||
|
|
@ -670,17 +670,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;
|
||||
|
||||
|
|
@ -694,7 +695,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
|
||||
|
|
@ -713,17 +714,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 }, {});
|
||||
}
|
||||
|
||||
|
|
@ -834,7 +835,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' ) {
|
||||
|
|
@ -855,7 +856,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;
|
||||
|
|
@ -876,7 +877,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 ) {
|
||||
|
|
@ -899,19 +900,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 {
|
||||
|
|
@ -944,17 +945,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' );
|
||||
|
|
@ -962,9 +963,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} );
|
||||
|
|
@ -976,7 +978,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;
|
||||
}
|
||||
|
|
@ -984,7 +986,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 ) {
|
||||
|
|
@ -1029,7 +1031,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) {
|
||||
|
|
@ -1058,7 +1060,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) {
|
||||
|
|
@ -1091,7 +1093,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
|
||||
|
||||
|
|
@ -1289,21 +1291,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
|
||||
|
|
@ -1314,15 +1316,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(
|
||||
|
|
@ -1333,14 +1335,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
|
||||
}
|
||||
);
|
||||
|
|
@ -1350,7 +1352,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 );
|
||||
|
||||
}
|
||||
|
|
@ -1372,7 +1374,7 @@ sub AddIssue {
|
|||
else {
|
||||
$issue = Koha::Checkout->new(
|
||||
{
|
||||
itemnumber => $item->{itemnumber},
|
||||
itemnumber => $item->itemnumber,
|
||||
%$issue_attributes,
|
||||
}
|
||||
)->store;
|
||||
|
|
@ -1380,49 +1382,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.
|
||||
|
|
@ -1432,11 +1433,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,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -1445,7 +1446,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 ) ) {
|
||||
|
|
@ -1461,7 +1462,7 @@ sub AddIssue {
|
|||
logaction(
|
||||
"CIRCULATION", "ISSUE",
|
||||
$borrower->{'borrowernumber'},
|
||||
$item->{'itemnumber'}
|
||||
$item->itemnumber,
|
||||
) if C4::Context->preference("IssueLog");
|
||||
}
|
||||
}
|
||||
|
|
@ -1814,13 +1815,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 ) {
|
||||
|
|
@ -1840,21 +1841,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
|
||||
|
|
@ -1870,8 +1872,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;
|
||||
}
|
||||
|
|
@ -1880,7 +1882,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,
|
||||
|
|
@ -1890,12 +1892,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;
|
||||
}
|
||||
|
||||
|
|
@ -1915,17 +1917,17 @@ sub AddReturn {
|
|||
if ($patron) {
|
||||
eval {
|
||||
if ( $dropbox ) {
|
||||
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
|
||||
MarkIssueReturned( $borrowernumber, $item->itemnumber,
|
||||
$dropboxdate, $patron->privacy );
|
||||
}
|
||||
else {
|
||||
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'},
|
||||
MarkIssueReturned( $borrowernumber, $item->itemnumber,
|
||||
$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 );
|
||||
|
|
@ -1938,58 +1940,58 @@ 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
|
||||
}
|
||||
|
||||
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
|
||||
ModDateLastSeen( $item->{itemnumber}, $leave_item_lost );
|
||||
ModDateLastSeen( $item->itemnumber, $leave_item_lost );
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
|
@ -1998,14 +2000,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 {
|
||||
|
|
@ -2030,7 +2032,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;
|
||||
|
|
@ -2043,7 +2045,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.
|
||||
|
|
@ -2052,19 +2054,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");
|
||||
}
|
||||
|
||||
|
|
@ -2080,13 +2082,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;
|
||||
|
|
@ -2612,7 +2615,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;
|
||||
return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item });
|
||||
|
|
@ -2670,7 +2673,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;
|
||||
|
|
@ -2691,10 +2694,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
|
||||
}
|
||||
);
|
||||
|
|
@ -2818,15 +2821,13 @@ sub AddRenewal {
|
|||
my $datedue = shift;
|
||||
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
|
||||
|
||||
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;
|
||||
|
|
@ -2840,7 +2841,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 );
|
||||
|
||||
|
|
@ -2849,11 +2850,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
|
||||
|
|
@ -2867,15 +2868,15 @@ 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 );
|
||||
if ( $charge > 0 ) {
|
||||
my $accountno = C4::Accounts::getnextacctno( $borrowernumber );
|
||||
my $manager_id = 0;
|
||||
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
|
||||
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
|
||||
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
|
||||
Koha::Account::Line->new(
|
||||
{
|
||||
|
|
@ -2890,7 +2891,7 @@ sub AddRenewal {
|
|||
branchcode => $branchcode,
|
||||
description => 'Renewal of Rental Item '
|
||||
. $biblio->title
|
||||
. " $item->{'barcode'}",
|
||||
. " $item->barcode",
|
||||
}
|
||||
)->store();
|
||||
}
|
||||
|
|
@ -2901,14 +2902,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,
|
||||
}
|
||||
|
|
@ -2936,10 +2937,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,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -2957,7 +2958,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
|
||||
|
||||
|
|
@ -2974,11 +2975,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
|
||||
}
|
||||
);
|
||||
|
|
@ -3013,17 +3014,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
|
||||
}
|
||||
);
|
||||
|
|
@ -3072,17 +3073,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
|
||||
}
|
||||
);
|
||||
|
|
@ -3662,8 +3663,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;
|
||||
|
|
@ -3852,8 +3853,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',
|
||||
|
|
@ -3861,8 +3866,8 @@ sub TransferSlip {
|
|||
branchcode => $branch,
|
||||
tables => {
|
||||
'branches' => $to_branch,
|
||||
'biblio' => $item->{biblionumber},
|
||||
'items' => $item,
|
||||
'biblio' => $item->biblionumber,
|
||||
'items' => $item->unblessed,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -606,14 +606,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 ( defined( $course_item->{$_} ) ) {
|
||||
$course_item_fields{$_} = $course_item->{$_};
|
||||
$item_fields{$_} = $item->{$_} || q{};
|
||||
$item_fields{$_} = $item->$_ || q{};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -535,17 +535,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->{status} 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';
|
||||
}
|
||||
|
|
@ -568,7 +568,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 );
|
||||
|
|
@ -607,14 +607,17 @@ 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
|
||||
return unless $item; # FIXME should be handled
|
||||
|
||||
my $issue = $item->checkout;
|
||||
return $issue; # FIXME should be handled
|
||||
|
||||
# Hashref building
|
||||
my $out;
|
||||
|
|
@ -745,11 +748,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 )->{status};
|
||||
|
|
@ -823,25 +826,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 );
|
||||
|
|
|
|||
41
C4/Items.pm
41
C4/Items.pm
|
|
@ -177,10 +177,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,9 +199,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
|
||||
|
|
@ -555,12 +552,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' } =
|
||||
|
|
@ -1338,13 +1335,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 {
|
||||
|
|
@ -1783,31 +1779,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 = Koha::Items->find($itemnumber) or return;
|
||||
|
||||
my $item = GetItem($itemnumber);
|
||||
|
||||
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')
|
||||
|
|
@ -2692,7 +2678,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 )
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -320,14 +320,14 @@ sub CanItemBeReserved {
|
|||
|
||||
# we retrieve borrowers and items informations #
|
||||
# item->{itype} will come for biblioitems if necessery
|
||||
my $item = C4::Items::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 { status =>'damaged' }
|
||||
if ( $item->{damaged}
|
||||
if ( $item->damaged
|
||||
&& !C4::Context->preference('AllowHoldsOnDamagedItems') );
|
||||
|
||||
# Check for the age restriction
|
||||
|
|
@ -355,7 +355,7 @@ sub CanItemBeReserved {
|
|||
|
||||
if ( $controlbranch eq "ItemHomeLibrary" ) {
|
||||
$branchfield = "items.homebranch";
|
||||
$branchcode = $item->{homebranch};
|
||||
$branchcode = $item->homebranch;
|
||||
}
|
||||
elsif ( $controlbranch eq "PatronLibrary" ) {
|
||||
$branchfield = "borrowers.branchcode";
|
||||
|
|
@ -363,7 +363,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};
|
||||
|
|
@ -373,7 +373,6 @@ sub CanItemBeReserved {
|
|||
$ruleitemtype = '*';
|
||||
}
|
||||
|
||||
$item = Koha::Items->find( $itemnumber );
|
||||
my $holds = Koha::Holds->search(
|
||||
{
|
||||
borrowernumber => $borrowernumber,
|
||||
|
|
@ -449,7 +448,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 { status => 'notReservable' };
|
||||
|
|
@ -466,8 +465,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 { status => 'cannotReserveFromOtherBranches' };
|
||||
}
|
||||
}
|
||||
|
|
@ -528,8 +526,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(
|
||||
|
|
@ -540,7 +538,7 @@ sub GetOtherReserves {
|
|||
#launch the subroutine dotransfer
|
||||
C4::Items::ModItemTransfer(
|
||||
$itemnumber,
|
||||
$iteminfo->{'holdingbranch'},
|
||||
$item->holdingbranch,
|
||||
$checkreserves->{'branchcode'}
|
||||
),
|
||||
;
|
||||
|
|
@ -776,15 +774,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}
|
||||
|
|
@ -798,14 +796,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;
|
||||
|
|
|
|||
|
|
@ -130,10 +130,10 @@ if ($AcqCreateItem eq 'receiving') {
|
|||
);
|
||||
} elsif ($AcqCreateItem eq 'ordering') {
|
||||
my $fw = ($acq_fw) ? 'ACQ' : '';
|
||||
my @itemnumbers = $order_object->items->get_column('itemnumber');
|
||||
my $items = $order_object->items;
|
||||
my @items;
|
||||
foreach (@itemnumbers) {
|
||||
my $item = GetItem($_); # FIXME We do not need this call, we already have the Koha::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} // '';
|
||||
|
|
@ -150,8 +150,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;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use C4::Output;
|
|||
use Koha::Libraries;
|
||||
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::Items;
|
||||
use Koha::ItemTypes;
|
||||
|
||||
my $cgi = new CGI;
|
||||
|
|
@ -43,39 +44,42 @@ unless ($status eq "ok") {
|
|||
my $item = {};
|
||||
my $itemnumber = $cgi->param('itemnumber');
|
||||
|
||||
my $item_unblessed = {};
|
||||
if($itemnumber) {
|
||||
my $acq_fw = GetMarcStructure(1, 'ACQ');
|
||||
my $fw = ($acq_fw) ? 'ACQ' : '';
|
||||
$item = GetItem($itemnumber);
|
||||
$item = Koha::Items->find($itemnumber);
|
||||
$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';
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -693,12 +698,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";
|
||||
|
|
|
|||
|
|
@ -78,13 +78,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 = ?");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -89,7 +88,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
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,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;
|
||||
|
|
@ -65,14 +66,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' ) {
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -102,10 +103,11 @@ my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) =
|
|||
$query->param("confirmed") || '',
|
||||
$query->param("newissues") || '',
|
||||
);
|
||||
|
||||
my @newissueslist = split /,/, $newissues;
|
||||
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;
|
||||
|
|
@ -160,7 +162,7 @@ elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) {
|
|||
$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') {
|
||||
|
|
@ -177,7 +179,7 @@ elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) {
|
|||
} elsif ( $needconfirm->{RENEW_ISSUE} || $op eq 'renew' ) {
|
||||
if ($confirmed) {
|
||||
#warn "renewing";
|
||||
AddRenewal( $borrower->{borrowernumber}, $item->{itemnumber} );
|
||||
AddRenewal( $borrower->{borrowernumber}, $item->itemnumber );
|
||||
push @newissueslist, $barcode;
|
||||
$template->param( renewed => 1 );
|
||||
} else {
|
||||
|
|
@ -243,7 +245,7 @@ elsif ( $patron && ( $op eq 'checkout' || $op eq 'renew' ) ) {
|
|||
$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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
14
svc/checkin
14
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 });
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,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;
|
||||
|
|
@ -454,7 +455,7 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 );
|
|||
my $passeddatedue1 = AddIssue($renewing_borrower, $item_7->barcode, $five_weeks_ago);
|
||||
is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: " . $passeddatedue1->date_due);
|
||||
|
||||
my ( $fine ) = CalcFine( GetItem(undef, $item_7->barcode), $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
|
||||
my ( $fine ) = CalcFine( $item_7->unblessed, $renewing_borrower->{categorycode}, $branch, $five_weeks_ago, $now );
|
||||
C4::Overdues::UpdateFine(
|
||||
{
|
||||
issue_id => $passeddatedue1->id(),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -349,17 +350,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,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use C4::Context;
|
|||
use C4::Circulation;
|
||||
use C4::Items;
|
||||
use Koha::IssuingRule;
|
||||
use Koha::Items;
|
||||
|
||||
use Test::More tests => 6;
|
||||
|
||||
|
|
@ -77,7 +78,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)
|
||||
|
|
@ -88,7 +89,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(
|
||||
|
|
@ -132,8 +133,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
|
||||
|
|
@ -172,8 +174,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
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ subtest 'General Add, Get and Del tests' => sub {
|
|||
cmp_ok($item_bibitemnum, '==', $biblio->biblioitem->biblioitemnumber, "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" );
|
||||
|
||||
|
||||
# Do not modify anything, and do not explode!
|
||||
|
|
@ -79,35 +79,35 @@ subtest 'General Add, Get and Del tests' => sub {
|
|||
|
||||
# Modify item; setting barcode.
|
||||
ModItem({ barcode => '987654321' }, $biblio->biblionumber, $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 => $biblio->biblionumber, 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} } , $biblio->biblionumber);
|
||||
$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 }, $biblio->biblionumber, $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' }, $biblio->biblionumber, $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}, $biblio->biblioitem->itemtype, "Itemtype set correctly when not using item-level_itypes" );
|
||||
$getitem = Koha::Items->find($itemnumber);
|
||||
is( $getitem->effective_itemtype, $biblio->biblioitem->itemtype, "Itemtype set correctly when not using item-level_itypes" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
@ -195,8 +195,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','');
|
||||
|
|
@ -521,8 +521,8 @@ subtest 'SearchItems test' => sub {
|
|||
ModItemFromMarc($item3_record, $biblio->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
|
||||
|
|
@ -738,21 +738,21 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub {
|
|||
my (undef, undef, $item_itemnumber) = AddItemFromMarc($item_record, $biblio->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, $biblio->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, $biblio->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;
|
||||
|
|
@ -772,8 +772,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, $biblio->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-" );
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 => $biblio->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} }, $biblio->biblionumber );
|
||||
$deleted = DelItem( { biblionumber => $biblio->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" );
|
||||
|
|
|
|||
|
|
@ -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} );
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -521,7 +522,7 @@ is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_with_no_item->{bibl
|
|||
####### EO Bug 13113 <<<
|
||||
####
|
||||
|
||||
$item = GetItem($itemnumber);
|
||||
$item = Koha::Items->find($itemnumber)->unblessed;
|
||||
|
||||
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" );
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,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) {
|
||||
|
|
@ -530,7 +532,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()) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use Koha::DateUtils;
|
|||
use Koha::AuthorisedValues;
|
||||
use Koha::BiblioFrameworks;
|
||||
use Koha::ClassSources;
|
||||
use Koha::Items;
|
||||
use List::MoreUtils qw( none );
|
||||
|
||||
my $minlocation=$input->param('minlocation') || '';
|
||||
|
|
@ -195,8 +196,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++;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ use C4::Items;
|
|||
use C4::Serials;
|
||||
use C4::Debug;
|
||||
use C4::Search; # enabled_staff_search_views
|
||||
|
||||
use Koha::Items;
|
||||
use Koha::Patrons;
|
||||
|
||||
use vars qw($debug $cgi_debug);
|
||||
|
|
@ -120,11 +122,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue