From ab0e6d6c3074ce3d8dff126858c8c33dd71013fc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 21 May 2016 14:18:04 +0100 Subject: [PATCH] Bug 16534: Do not process the checkout if the checkin has failed --- C4/Circulation.pm | 21 +++++++++++++++------ .../prog/en/modules/circ/circulation.tt | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 913ec0b..12fccdc 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1046,12 +1046,19 @@ sub CanBookBeIssued { # issued to someone else my $currborinfo = C4::Members::GetMember( borrowernumber => $issue->{borrowernumber} ); -# warn "=>.$currborinfo->{'firstname'} $currborinfo->{'surname'} ($currborinfo->{'cardnumber'})"; - $needsconfirmation{ISSUED_TO_ANOTHER} = 1; - $needsconfirmation{issued_firstname} = $currborinfo->{'firstname'}; - $needsconfirmation{issued_surname} = $currborinfo->{'surname'}; - $needsconfirmation{issued_cardnumber} = $currborinfo->{'cardnumber'}; - $needsconfirmation{issued_borrowernumber} = $currborinfo->{'borrowernumber'}; + + my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} ); + + unless ( $can_be_returned ) { + $issuingimpossible{RETURN_IMPOSSIBLE} = 1; + $issuingimpossible{branch_to_return} = $message; + } else { + $needsconfirmation{ISSUED_TO_ANOTHER} = 1; + $needsconfirmation{issued_firstname} = $currborinfo->{'firstname'}; + $needsconfirmation{issued_surname} = $currborinfo->{'surname'}; + $needsconfirmation{issued_cardnumber} = $currborinfo->{'cardnumber'}; + $needsconfirmation{issued_borrowernumber} = $currborinfo->{'borrowernumber'}; + } } unless ( $ignore_reserves ) { @@ -1379,6 +1386,8 @@ sub AddIssue { if ( $actualissue->{borrowernumber}) { # 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} ); + return unless $allowed; AddReturn( $item->{'barcode'}, C4::Context->userenv->{'branch'} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index cd3fc35..90c2d42 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -554,6 +554,10 @@ $(document).ready(function() {
  • This item belongs to [% Branches.GetName( itemhomebranch ) %] and cannot be checked out from this location.
  • [% END %] + [% IF RETURN_IMPOSSIBLE %] +
  • This item must be return to [% Branches.GetName( branch_to_return ) %].
  • + [% END %] + [% IF ( USERBLOCKEDWITHENDDATE ) %]
  • Patron has a restriction until [% USERBLOCKEDWITHENDDATE | $KohaDates %].
  • [% END %] -- 2.8.1