@@ -, +, @@ --- C4/Circulation.pm | 2 +- C4/Reserves.pm | 2 +- Koha/Biblio.pm | 17 ++++++++++------- Koha/Item.pm | 6 +++--- Koha/Recall.pm | 2 +- circ/returns.pl | 4 ++-- .../bootstrap/en/includes/title-actions-menu.inc | 2 +- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 8 +------- misc/cronjobs/recalls/expire_recalls.pl | 2 +- misc/cronjobs/recalls/overdue_recalls.pl | 2 +- opac/opac-recall.pl | 4 ++-- 11 files changed, 24 insertions(+), 27 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -1125,7 +1125,7 @@ sub CanBookBeIssued { # Only bother doing this if UseRecalls is enabled and the item is recallable # Don't look at recalls that are in transit if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) { - my @recalls = $biblio->recalls; + my @recalls = $biblio->recalls->as_list; foreach my $r ( @recalls ) { if ( $r->itemnumber and --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -413,7 +413,7 @@ sub CanItemBeReserved { # check if a recall exists on this item from this borrower return { status => 'recall' } - if Koha::Recalls->search({ borrowernumber => $borrowernumber, itemnumber => $itemnumber, old => undef })->count; + if Koha::Recalls->search({ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, old => undef })->count; my $controlbranch = C4::Context->preference('ReservesControlBranch'); --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -1172,12 +1172,15 @@ Return all active recalls attached to this biblio, sorted by oldest first sub recalls { my ( $self, $params ) = @_; - if ( $params->{borrowernumber} ) { - my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef, borrowernumber => $params->{borrowernumber} }, { order_by => { -asc => 'recalldate' } }); - return @recalls_rs; - } - my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } }); - return @recalls_rs; + + my $args = { + biblionumber => $self->biblionumber, + old => undef, + }; + $args->{ borrowernumber } = $params->{ borrowernumber } if $params->{ borrowernumber }; + + my $recalls_rs = $self->_result->recalls->search( $args, { order_by => { -asc => 'recalldate' } }); + return Koha::Recalls->_new_from_dbic( $recalls_rs ); } =head3 can_be_recalled @@ -1200,7 +1203,7 @@ sub can_be_recalled { $branchcode = $patron->branchcode; } - my @all_items = Koha::Items->search({ biblionumber => $self->biblionumber }); + my @all_items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list; # if there are no available items at all, no recall can be placed return 0 if ( scalar @all_items == 0 ); --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -1444,7 +1444,7 @@ Return the relevant recall for this item sub recall { my ( $self ) = @_; - my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } }); + my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } })->as_list; foreach my $recall (@recalls) { if ( $recall->item_level_recall and $recall->itemnumber == $self->itemnumber ){ return $recall; @@ -1517,7 +1517,7 @@ sub can_be_recalled { # check item availability # items are unavailable for recall if they are lost, withdrawn or notforloan - my @items = Koha::Items->search({ biblionumber => $self->biblionumber, itemlost => 0, withdrawn => 0, notforloan => 0 }); + my @items = Koha::Items->search({ biblionumber => $self->biblionumber, itemlost => 0, withdrawn => 0, notforloan => 0 })->as_list; # if there are no available items at all, no recall can be placed return 0 if ( scalar @items == 0 ); @@ -1591,7 +1591,7 @@ Get the most relevant recall for this item. sub check_recalls { my ( $self ) = @_; - my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, itemnumber => [ $self->itemnumber, undef ], status => [ 'R','O','W','T' ] }, { order_by => { -asc => 'recalldate' } }); + my @recalls = Koha::Recalls->search({ biblionumber => $self->biblionumber, itemnumber => [ $self->itemnumber, undef ], status => [ 'R','O','W','T' ] }, { order_by => { -asc => 'recalldate' } })->as_list; my $recall; # iterate through relevant recalls to find the best one. --- a/Koha/Recall.pm +++ a/Koha/Recall.pm @@ -110,7 +110,7 @@ sub checkout { unless ( $self->item_level_recall ) { # Only look at checkouts of items that are allowed to be recalled, and get the oldest one - my @items = Koha::Items->search({ biblionumber => $self->biblionumber }); + my @items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list; my @itemnumbers; foreach (@items) { my $recalls_allowed = Koha::CirculationRules->get_effective_rule({ --- a/circ/returns.pl +++ a/circ/returns.pl @@ -178,7 +178,6 @@ if ( $query->param('recall_id') ) { my $itemnumber = $query->param('itemnumber'); my $return_branch = $query->param('returnbranch'); - my $expirationdate = $recall->calc_expirationdate; my $item; if ( !$recall->item_level_recall ) { $item = Koha::Items->find( $itemnumber ); @@ -187,7 +186,8 @@ if ( $query->param('recall_id') ) { if ( $recall->branchcode ne $return_branch ) { $recall->start_transfer({ item => $item }) if !$recall->in_transit; } else { - $recall->set_waiting({ item => $item }) if !$recall->waiting; + my $expirationdate = $recall->calc_expirationdate; + $recall->set_waiting({ item => $item, expirationdate => $expirationdate }) if !$recall->waiting; } } --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc @@ -18,7 +18,7 @@ [% END # / OPACHoldRequests %] [% IF Koha.Preference('UseRecalls') %] - Place recall + Place recall [% END %] [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -767,13 +767,7 @@ [% FOREACH RECALL IN RECALLS %]
Item recalled: [% RECALL.item.barcode | html %]
[% END %]