diff --git a/circ/returns.pl b/circ/returns.pl index c7ea4fc780..11b0795ad7 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -155,12 +155,23 @@ if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { # fix up item type for display my $item = Koha::Items->find($itemnumber); my $biblio = $item->biblio; + my $hold = Koha::Holds->find($reserve_id) or die "Hold for item $itemnumber not found\n"; #TODO Not very elegant if ($cancel_reserve) { - my $hold = Koha::Holds->find($reserve_id); - if ($hold) { - $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire, cancellation_reason => $cancel_reason } ); - } # FIXME else? + $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire, cancellation_reason => $cancel_reason } ); + + # check if we have other reserves for this document, if we have a result send the message of transfer + my ( undef, $nextreservinfo, undef ) = CheckReserves( $item, C4::Context->preference('ConfirmFutureHolds') ); + if ( $userenv_branch ne $nextreservinfo->{'branchcode'} ) { + my $patron = Koha::Patrons->find( $nextreservinfo->{'borrowernumber'} ); + $template->param( + itemtitle => $biblio->title, + itembiblionumber => $biblio->biblionumber, + iteminfo => $biblio->author, + patron => $patron, + diffbranch => 1, + ); + } } else { my $diffBranchSend = ( $userenv_branch ne $diffBranchReturned ) ? $diffBranchReturned : undef; @@ -168,7 +179,6 @@ if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { # i.e., whether to apply waiting status ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id ); - my $hold = Koha::Holds->find($reserve_id); if ($diffBranchSend) { my $tobranch = $hold->pickup_library(); @@ -177,21 +187,6 @@ if ( $query->param('reserve_id') && $op eq 'cud-affect_reserve' ) { $transfer->transit; } } - - # check if we have other reserves for this document, if we have a result send the message of transfer - # FIXME do we need to do this if we didn't take the cancel_reserve branch above? - my ( undef, $nextreservinfo, undef ) = CheckReserves( $item, C4::Context->preference('ConfirmFutureHolds') ); - - if ( $userenv_branch ne $nextreservinfo->{'branchcode'} ) { - my $patron = Koha::Patrons->find( $nextreservinfo->{'borrowernumber'} ); - $template->param( - itemtitle => $biblio->title, - itembiblionumber => $biblio->biblionumber, - iteminfo => $biblio->author, - patron => $patron, - diffbranch => 1, - ); - } } if ( $query->param('recall_id') && $op eq 'cud-affect_recall' ) {