From fcd0040e2a4cd4f04af1ba989b53c6241d952a9e Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Thu, 19 Jul 2018 22:39:04 +0000 Subject: [PATCH] Bug 19532 - Stopping an recalled item currently awaiting pickup from being able to be checked out to patrons other than the recall requester. Test plan: 1. Ensure 'UseRecalls' sypref is enabled and you have inputted values for recalls fields in the circulation rules (Administration->Circulation and fines rules) 2. Check item out to patron 1 3. Log into the OPAC as patron 2 and place a recall on the checked out item 4. Return the item and confirm the recall 5. In the staff client go to Circulation->Recalls queue, notice the recall has a status of 'Ready for pickup' 6. Try issuing the item to patron 3 and notice without this patch applied you can issue a recall awaiting pickup to a patron who did not place the recall. 7. Apply patch 8. Restart memcached and plack 9. Using a new item repeat steps 1,2,3,4,5,6 and notice you get a yellow message displayed stating: 'This item is awaiting pickup by another patron who recalled it.' The issuing has not taken place to a patron who is not the patron who placed the recall as the item is awaiting pickup by the recall requester. 10. Issue the item to patron 2 and notice the issuing takes place successfully Sponsored-By: Toi Ohomai Institute of Technology, New Zealand --- C4/Circulation.pm | 13 +++++++++++++ catalogue/detail.pl | 4 ++-- koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 4 ++++ opac/opac-recall.pl | 11 ++++++----- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f141eb6..4ce4166 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -666,6 +666,10 @@ sticky due date is invalid or due date in the past if the borrower borrows to much things +=head3 WAITING_RECALL_FOR_A_DIFFERENT_PATRON + +if the item has been recalled by a different patron and the recall status is waiting 'W' + =cut sub CanBookBeIssued { @@ -1023,6 +1027,15 @@ sub CanBookBeIssued { } } + #CHECK IF ITEM HAS WAITING RECALL FOR ANOTHER PATRON + if ( C4::Context->preference('UseRecalls') ) { + my $recall = Koha::Recalls->find({ itemnumber => $item->{'itemnumber'} }); + if ((defined $recall) && ($recall->patron->borrowernumber != $patron->borrowernumber) && $recall->status eq 'W') { + #Item has been recalled by a different patron and is waiting for them + $issuingimpossible{WAITING_RECALL_FOR_A_DIFFERENT_PATRON} = 1; + } + } + ## CHECK AGE RESTRICTION my $agerestriction = $biblioitem->agerestriction; my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $patron->unblessed ); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index deae6b4..05cbb25 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -334,8 +334,8 @@ foreach my $item (@items) { } } - my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef }); - if (defined $recall){ + my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber} }); + if (defined $recall && $recall->status ne 'F' && $recall->status ne 'C'){ $item->{recalled} = 1; $item->{recall} = $recall; } 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 a0b886e..7ad2088 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -79,6 +79,7 @@
Staff members are not allowed to discharge borrowers, nor borrowers to request a discharge.
[% END %] + [% IF ( NEEDSCONFIRMATION ) %]
@@ -313,6 +314,9 @@ [% IF ( INVALID_DATE ) %]
  • The due date "[% INVALID_DATE | html %]" is invalid
  • [% END %] + [% IF ( WAITING_RECALL_FOR_A_DIFFERENT_PATRON ) %] +
  • This item is awaiting pickup by another patron who recalled it.
  • + [% END %] [% IF ( UNKNOWN_BARCODE ) %]
  • The barcode was not found: [% barcode | html %] diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl index 24f9f1b..e5c1016 100755 --- a/opac/opac-recall.pl +++ b/opac/opac-recall.pl @@ -87,13 +87,14 @@ if ($op eq 'request'){ my $recall = Koha::Recalls->find($recall_request->recall_id); # updating due date on checkout my $timestamp = dt_from_string($recall->timestamp); - if ($issuing_rule->recall_due_date_interval eq '') { - my $due_date = $timestamp->add( $issuing_rule->lengthunit => 0 ); + my $due_date; + if ( $issuing_rule->recall_due_date_interval eq '' ) { + $due_date = $timestamp->add( $issuing_rule->lengthunit => 0 ); } else { - my $due_date = $timestamp->add( $issuing_rule->lengthunit => $issuing_rule->recall_due_date_interval); + $due_date = $timestamp->add( $issuing_rule->lengthunit => $issuing_rule->recall_due_date_interval ); } - my $checkout = Koha::Checkouts->find({ itemnumber = $itemnumber })->update({ date_due => $due_date }); - my $checkout_borrower = $checkout->patron; + my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber })->update({ date_due => $due_date }); + my $checkout_borrower = Koha::Patrons->find($checkout->borrowernumber->borrowernumber); # send notice to user with recalled item checked out my $letter = C4::Letters::GetPreparedLetter ( -- 2.1.4