From db095c3a7b2aa41142dbd4d9705ddaa21e139a6d Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 11 May 2020 23:52:09 +0000 Subject: [PATCH] Bug 19532: Recalls on intranet See recalls on Intranet - old recalls (all inactive recalls) - recalls queue (all active recalls) - cancel, expire, revert waiting status, multiple cancel, mark overdue - recalls to pull (available but not yet waiting) - cancel - recalls awaiting pickup (awaiting pickup, awaiting pickup more than RecallMaxPickUpDelay days) - expire, revert waiting status - overdue recalls (overdue to be returned) - cancel, multiple cancel - biblio recalls tab (all active recalls relevant to this bib) - cancel, expire, revert waiting status, mark overdue - patron recalls tab (all active recalls relevant to this patron) - cancel, expire, revert waiting status, mark overdue - patron recalls history tab (all recalls relevant to this patron) - cancel, expire, revert waiting status, mark overdue - log viewer and the general circulation of recalls == TEST PLAN FOR RECALLS == ADMINISTRATION 1. Apply all patches 2. Run database updates, update schema files and confirm everything applies cleanly 3. Run tests and confirm everything passes: t/db_dependent/Koha/Recall.t t/db_dependent/Koha/Recalls.t t/db_dependent/Stats.t t/db_dependent/Circulation/CalcFine.t t/db_dependent/Koha/Item.t t/db_dependent/Koha/Biblio.t t/db_dependent/Koha/Patron.t t/db_dependent/XSLT.t t/db_dependent/Search.t t/db_dependent/Holds.t t/db_dependent/Circulation/transferbook.t t/db_dependent/Circulation.t 4. Go to Administration -> system preferences. Find the UseRecalls system preference. It should be DISABLED. Confirm RecallsMaxPickUpDelay is set to 7 by default. 5. Go to Administration -> circulation rules. Confirm there are no recalls circulation rules showing. 6. Test a few circulation flows: checking out, placing a reserve, checking in, fulfilling a reserve, etc. Confirm everything works as normal. 7. Go to Administration -> system preferences. Enable the UseRecalls system preference. 8. Go to Administration -> circulation rules. Set the following rules: Recalls allowed (count) = 0 Recalls per record (count) = 0 On shelf recalls allowed ( If any unavailable / If all unavailable ) = If any unavailable Recall due date interval (days) = 3 Recall overdue fine amount = (something different to your normal fine amount) Recall pickup period (days) = 1 Throughout your testing, try with different combinations of these rules and itemtype / branchcode / categorycode. Also try with null values. Keep the circulation rules open in another tab so you can refer to and update these easily. You should also have at least one other tab open for the staff client, and a third tab open for the OPAC, for ease of testing. 9. Go to your account -> More -> Set permissions. Confirm the recalls permission is checked. 10. Set up a test user with OPAC login details (Borrower A). This could also be your own user, as long as you have OPAC login access. 11. Set up a test record (Biblio A) with at least two items (Item A and Item B) of the same item type (or an item type with the same recall circ rules). PLACING A RECALL 12. Log in to the OPAC as Borrower A. Do a catalogue search with a term that will return multiple results, including Biblio A. 13. Click on Biblio A. 14. Notice there is a 'Place recall' button on the sidebar menu. Click this button. There will be a message saying that there are no items to recall - this is because all items are available. 15. Check out Item A to another borrower (Borrower B). 16. Refresh the 'Place recall' page. You will still NOT be able to place a recall - this is because Recalls allowed = 0 and Recalls per record = 0. 17. Edit the circulation rules to have the following values: Recalls allowed (count) = 1 Recalls per record (count) = 1 18. Refresh the 'Place recall' page. You will now see the form to place a recall. BIBLIO-LEVEL RECALL, NO TRANSFER 19. Place a biblio-level recall. Pickup location: Branch A, the set branch when you are logged into the staff client Recall not needed after (expiration date): whatever you want Select 'recall next available item' Click confirm 20. Confirm the recall is placed successfully. Confirm that the new due date displayed is correctly calculated to be today's date, plus 3 days (taken from the 'recall due date interval' circ rule) 21. In the staff client, look at Borrower B's account, and go to their Notices tab. Confirm they have received a 'Notification to return recalled item' notice. 22. Look at Borrower B's checkouts table. Notice the due date for their checkout has been adjusted, and there is now a note to say that the item was recalled and the due date adjusted. 23. Log in to the OPAC as Borrower B and go to your summary tab. Notice there is a note under their checkout to say the item had been recalled. 24. Log out of the OPAC and log back in as Borrower A. 25. Go to your summary tab. Confirm there is a Recalls tab with a count of 1. 26. Cancel the recall using the button. Confirm it cancels and the Recalls tab disappears. 27. Do a catalogue search with a term that will return multiple results, including Biblio A. 28. When the results load, notice there is a 'Place recall' button next to the 'Place hold' button. Click this 'Place recall' button. 29. Notice you are redirected straight to the form to place a recall. 30. Place a biblio-level recall again, following the steps in Step 19. 31. Go to your recalls history tab. Notice your first cancelled recall shows here. 32. Cancel the recall you just created, using the button. Confirm it cancels and you are redirected to your summary tab. 33. In the staff client, enable the UseCourseReserves system preference. 34. Go to the main menu, click Course Reserves. 35. Add a new course. (You may also have to define an authorised value for DEPARTMENT.) 36. Add Item A as a reserve to this course. 37. View Course Reserves in the OPAC. Click the course you just created. 38. Notice the reserve has a Recall button underneath it's 'Checked out' status. Click this button. 39. Place a biblio-level recall again, following the steps in Step 19. 40. Click the 'Place recall' link in the breadcrumbs. 41. Notice there is a message saying that you have reached the max number of recalls on this record. This is because Recalls allowed = 1 and Recalls per record = 1. 42. Edit the circulation rules to have the following values: Recalls allowed (count) = 10 Recalls per record (count) = 5 43. Refresh the 'Place recall' page. You will now see the form to place a recall. 44. Create another test record (Biblio B) with at least one item (Item C). 45. Find this record on the OPAC and place a biblio-level recall again, following the steps in Step 19. 46. In the staff client, go to Circulation -> Old recalls. You should be able to see your two cancelled recalls. 47. Go to Circulation -> Recalls queue. Your current recalls should show here. 48. Use the 'Select all' checkbox to select all recalls. 49. Cancel the recalls using the 'Cancel selected recalls' button. 50. Go to the OPAC and place a biblio-level recall on Biblio A again, following the steps in Step 19. 51. In the staff client, check in Item A, which should still be checked out to Borrower B. 52. A box should pop-up asking you to confirm Borrower A's recall. Click ignore. 53. Click the link to go view Biblio A's details in the catalogue. 54. Click the recalls tab. Notice Borrower A's recall is displayed, and shows it is still Requested (has not been confirmed waiting). 55. Check in Item A again. This time, confirm the recall as waiting using the "Confirm recall" button. 56. Go to Borrower A's Notices tab. Confirm there is a notice "Recalled item awaiting pickup". 57. Go to Borrower A's checkouts. Notice there is a recalls tab. Confirm the recall is showing as "Ready for pickup". 58. Click the 'Actions' dropdown. Click the "Revert waiting" button. The page should show a message that the waiting status has been reverted, without reloading. 59. This time, check in Item B. The recall confirmation box should show again, because this a biblio-level recall that any recallable item under Biblio A can fill. Click the "Print slip and confirm" button. 60. Check the slip that is generated. Confirm it contains Borrower A's correct details, and the details of the recall are correct. 61. Go to Circulation -> Recalls awaiting pickup. Confirm the recall is now waiting and shows in this list. (You could also try this with Item B having a different item type to Item A, and circ rules not allowing Item B's item type to have recalls. When checking in Item A, it should not trigger the recall box). 62. Go to Borrower A's checkouts. Check out Item B. 63. Confirm the checkout is successful and the recall is removed from the Recalls tab. 64. Go to Circulation -> Old recalls. The fulfilled recall should show. 65. Check in Item B. BIBLIO-LEVEL RECALL, TRANSFER REQUIRED 66. Check out Item A to Borrower B. 67. Log in to the OPAC as Borrower A. 68. Find Biblio A and place a biblio-level recall. Pickup location: Branch B, a different branch from your logged in branch. This recall will require a transfer. Recall not needed after (expiration date): whatever you want Select 'recall next available item' Click confirm 69. In the staff client, check in Item A at Branch A. Notice the box that pops up shows that a transfer is required. 70. Click "confirm recall and transfer" and confirm the transfer. 71. Go to your account and click the Recalls tab. 72. Confirm the recall status now shows the item is in transit to Branch B. 73. In the drop-down top-right of your window, select 'Set library'. 74. Set your library to Branch B. 75. Go to Circulation -> Transfers to receive. Notice that the recall is showing here. 76. Click 'Cancel transfer'. 77. Go to Circulation -> Recalls queue 78. Confirm the recall status has been reverted to Requested. 79. Set your library back to Branch A. 80. Check in Item A and trigger the transfer. 81. Set your library back to Branch B. 82. Check in Item A at Branch B. 83. When the 'Recall found' box pops up, click Ignore. 84. Go to Circulation -> Recalls to pull. The recall should show here, with a button to "Cancel recall and return to: Branch A" 85. Click the button to cancel the recall. 86. Repeat Steps 66-70. 87. Check in Item A at Branch B. Confirm the recall as waiting. 88. Check out Item A to Borrower A to fulfill the recall. 89. Set your library back to Branch A and check in Item A. ITEM-LEVEL RECALL, NO TRANSFER 90. Go to Administration -> circulation rules. Set the following rules: On shelf recalls allowed ( If any unavailable / If all unavailable ) = If all unavailable 91. Check out Item A to Borrower B. 92. Log in to the OPAC as Borrower A and go to Biblio A. 93. Click the 'Place recall' button. Confirm there is a message that there are no items to recall. This is because On shelf recalls allowed = If all unavailable, and there is still one item (Item B) available. 94. In the staff client, edit Item B to have a withdrawn, item lost or not for loan status. 95. Refresh the 'Place recall' page. Confirm you can now see the form to place a recall. 96. Place an item-level recall. Pickup location: Branch A. Recall not needed after (expiration date): whatever you want Select 'recall a specific item' Item B will not be selectable, and Item A should be selected by default. Click confirm 97. In the staff client, edit Item B and remove the lost or missing status. 98. Check in Item B. Confirm the recall box does not pop up, because it cannot fill the item-level recall. 99. Check in Item A. Confirm the recall as waiting. 100. Go to Circulation -> Recalls awaiting pickup 101. Expire the recall. Confirm it expires as expected. ITEM-LEVEL RECALL, TRANSFER REQUIRED 102. Repeat steps 91 to 95. 103. Place an item-level recall. Pickup location: Branch B, we will require a transfer. Recall not needed after (expiration date): whatever you want Select 'recall a specific item' Item B will not be selectable, and Item A should be selected by default. Click confirm 104. In the staff client, check in Item A. Confirm the recall and trigger the transfer. 105. Set your library to Branch B and check in Item A. 106. Confirm the recall as waiting. 107. Check out Item A to Borrower A and fulfill the recall. 108. Set your library back to Branch A and check in Item A. CRONJOBS: EXPIRING RECALL 109. Check out Item A to Borrower B. 110. Log in to the OPAC as Borrower A. Place a recall (any level) on Biblio A. 111. In your terminal, enter mysql and edit the expiration date of your recall to be before today UPDATE recalls SET expirationdate = NOW()-2 WHERE recall_id = X; 112. Run the expiry cronjob from within your shell perl misc/cronjobs/recalls/expire_recalls.pl 113. Go to Borrower A's account and go to the Recalls history tab 114. Confirm the recall has been expired because the current date surpassed the specified expiration date 115. Check out Item A to Borrower B. 116. Log in to the OPAC as Borrower A. Place a recall (any level) on Biblio A. 117. In the staff client, check in Item A and confirm the recall as waiting. 118. In your terminal, enter mysql and edit the waiting date of your recall to be before today UPDATE recalls SET waitingdate = NOW() - interval 5 day WHERE recall_id = X; 119. Run the expiry cronjob from within your shell perl misc/cronjobs/recalls/expire_recalls.pl 120. Go to Borrower A's account and go to the Recalls history tab 121. Confirm the recall has been expired because the recall had been waiting for more days than the Recall pickup period 122. Go to Administration -> circulation rules. Set the following rules: Recall pickup period (days) = 0 123. Set the RecallsMaxPickUpDelay system preference = 1. 124. Check out Item A to Borrower B. 125. Log in to the OPAC as Borrower A. Place a recall (any level) on Biblio A. 126. In the staff client, check in Item A and confirm the recall as waiting. 127. In your terminal, enter mysql and edit the waiting date of your recall to be before today UPDATE recalls SET waitingdate = NOW()-2 WHERE recall_id = X; 128. Run the expiry cronjob from within your shell perl misc/cronjobs/recalls/expire_recalls.pl 129. Go to Borrower A's account and go to the Recalls history tab 130. Confirm the recall has been expired because the recall had been waiting for more days than the RecallsMaxPickUpDelay syspref CRONJOBS: OVERDUE RECALL 131. Check out Item A to Borrower B 132. Log in to the OPAC as Borrower A. Place a recall (any level) on Biblio A. 133. In your terminal, enter mysql and edit the due date of the checkout to Borrower B to be before today UPDATE issues SET date_due = NOW()-2 WHERE issue_id = X; 134. Run the overdue cronjob from within your shell perl misc/cronjobs/recall/overdue_recalls.pl 135. Go to Circulation -> Overdue recalls 136. Confirm your recall is showing here now as the recall has been marked Overdue CIRCULATION 137. Check in Item A. 138. When the recall box pops up, click Ignore. 139. Check out Item A to Borrower B. You should see a yellow confirmation box, saying that another borrower has recalled the item you are trying to check out. 140. Click "No don't check out" and confirm the item isn't checked out and the recall remains. 141. Repeat Step 139. 142. Click "Yes check out" and confirm the item is checked out and the recall remains. 143. When Borrower B's checkout table loads, confirm that you cannot renew or check in the item from the Checkouts table because there is a 'Recalled' link which takes you to the recalls tab for that biblio. 144. Repeat Steps 137-139. 145. Select "Cancel recall" and click "Yes check out" and confirm the item is checked out and the recall has been cancelled. 146. Log in to the OPAC as Borrower A. Place a recall (any level) on Biblio A. 147. Check in Item A. Confirm the recall as waiting. 148. Check out Item A to Borrower B. You should see a yellow confirmation box, saying that that another borrower has recalled the item that you are trying to check out. 149. Select "Revert waiting status" and click "Yes check out" and confirm the item is checked out and the recall status has reverted to requested. OTHER 150. In your terminal, enter mysql and edit the due date of the checkout to Borrower B to be before today UPDATE issues SET date_due = NOW()-2 WHERE issue_id = X; 151. Go to Borrower A's recalls and click the Actions dropdown. 152. Click "Mark as overdue" and confirm the recall is marked as overdue manually. 153. Go to Tools -> Log Viewer. Check only the Recalls module, and leave all other parameters, and click Submit. 154. Confirm all of the recalls actions that have been made are correctly logged. Note: recalls messaging preferences are introduced in Bug 23781. The recall feature is fully documented at: https://wiki.koha-community.org/wiki/Catalyst_IT_Recalls Signed-off-by: David Nind Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- catalogue/detail.pl | 6 + circ/circulation.pl | 7 +- circ/returns.pl | 78 ++++++- circ/transferstoreceive.pl | 7 + .../prog/en/includes/biblio-view-menu.inc | 3 + .../prog/en/includes/circ-menu.inc | 3 + .../prog/en/includes/circ-nav.inc | 8 + .../prog/en/includes/patron-title.inc | 1 + .../prog/en/includes/recalls.inc | 134 ++++++++++++ .../prog/en/modules/catalogue/detail.tt | 15 +- .../prog/en/modules/catalogue/results.tt | 3 + .../prog/en/modules/cataloguing/addbooks.tt | 1 + .../prog/en/modules/circ/circulation-home.tt | 12 + .../prog/en/modules/circ/circulation.tt | 51 ++++- .../prog/en/modules/circ/printslip.tt | 2 + .../prog/en/modules/circ/renew.tt | 3 + .../prog/en/modules/circ/returns.tt | 205 +++++++++++++++++- .../en/modules/circ/transferstoreceive.tt | 2 + .../prog/en/modules/members/moremember.tt | 15 ++ .../prog/en/modules/members/recallshistory.tt | 48 ++++ .../en/modules/recalls/recalls_old_queue.tt | 56 +++++ .../en/modules/recalls/recalls_overdue.tt | 67 ++++++ .../prog/en/modules/recalls/recalls_queue.tt | 67 ++++++ .../en/modules/recalls/recalls_to_pull.tt | 175 +++++++++++++++ .../en/modules/recalls/recalls_waiting.tt | 181 ++++++++++++++++ .../prog/en/modules/recalls/request.tt | 63 ++++++ .../prog/en/modules/reserve/request.tt | 4 +- .../prog/en/modules/tools/viewlog.tt | 15 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 15 +- koha-tmpl/intranet-tmpl/prog/js/recalls.js | 175 +++++++++++++++ members/moremember.pl | 2 + members/recallshistory.pl | 47 ++++ recalls/recall_pickup_slip.pl | 74 +++++++ recalls/recalls_old_queue.pl | 47 ++++ recalls/recalls_overdue.pl | 61 ++++++ recalls/recalls_queue.pl | 57 +++++ recalls/recalls_to_pull.pl | 126 +++++++++++ recalls/recalls_waiting.pl | 76 +++++++ recalls/request.pl | 65 ++++++ reserve/request.pl | 4 + svc/checkouts | 22 ++ svc/recall | 89 ++++++++ tools/letter.pl | 2 +- tools/viewlog.pl | 9 + 44 files changed, 2091 insertions(+), 12 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_overdue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_queue.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/js/recalls.js create mode 100755 members/recallshistory.pl create mode 100755 recalls/recall_pickup_slip.pl create mode 100755 recalls/recalls_old_queue.pl create mode 100755 recalls/recalls_overdue.pl create mode 100755 recalls/recalls_queue.pl create mode 100755 recalls/recalls_to_pull.pl create mode 100755 recalls/recalls_waiting.pl create mode 100755 recalls/request.pl create mode 100755 svc/recall diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 75aeed0e96..32a3528765 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -401,6 +401,12 @@ foreach my $item (@items) { $item->{cover_images} = $item_object->cover_images; } + my $recall = Koha::Recalls->find({ itemnumber => $item->{itemnumber}, old => undef }); + if ( defined $recall ) { + $item->{recalled} = 1; + $item->{recall} = $recall; + } + if ($currentbranch and C4::Context->preference('SeparateHoldings')) { if ($itembranchcode and $itembranchcode eq $currentbranch) { push @itemloop, $item; diff --git a/circ/circulation.pl b/circ/circulation.pl index cb49995163..fb0a25bb29 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -173,6 +173,8 @@ if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) { } my $issueconfirmed = $query->param('issueconfirmed'); my $cancelreserve = $query->param('cancelreserve'); +my $cancel_recall = $query->param('cancel_recall'); +my $recall_id = $query->param('recall_id'); my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice my $charges = $query->param('charges') || q{}; @@ -392,7 +394,8 @@ if (@$barcodes) { } unless($confirm_required) { my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; - my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, } ); + my $recall_id = $messages->{RECALLED}; + my $issue = AddIssue( $patron->unblessed, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, recall_id => $recall_id, } ); $template_params->{issue} = $issue; $session->clear('auto_renew'); $inprocess = 1; @@ -439,6 +442,8 @@ if ($patron) { $template->param( holds_count => $holds->count(), WaitingHolds => $waiting_holds, + recalls => $patron->recalls, + specific_patron => 1, ); } diff --git a/circ/returns.pl b/circ/returns.pl index 6a9ec17617..8042250a38 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -77,6 +77,15 @@ if ( $query->param('print_slip') ) { ); } +# print a recall slip +if ( $query->param('recall_slip') ) { + $template->param( + recall_slip => 1, + recall_id => scalar $query->param('recall_id'), + ); +} + + ##################### #Global vars my $userenv = C4::Context->userenv; @@ -164,6 +173,24 @@ if ( $query->param('reserve_id') ) { } } +if ( $query->param('recall_id') ) { + my $recall = Koha::Recalls->find( scalar $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 ); + } + + 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 $borrower; my $returned = 0; my $messages; @@ -223,6 +250,10 @@ if ($transit) { my $transfer = Koha::Item::Transfers->find($transit); if ( $canceltransfer ) { $transfer->cancel({ reason => 'Manual', force => 1}); + my $recall_transfer_deleted = Koha::Recalls->find({ itemnumber => $itemnumber, status => 'T' }); + if ( defined $recall_transfer_deleted ) { + $recall_transfer_deleted->revert_transfer; + } $template->param( transfercancelled => 1); } else { $transfer->transit; @@ -231,6 +262,10 @@ if ($transit) { my $item = Koha::Items->find($itemnumber); my $transfer = $item->get_transfer; $transfer->cancel({ reason => 'Manual', force => 1}); + my $recall_transfer_deleted = Koha::Recalls->find({ itemnumber => $itemnumber, status => 'T' }); + if ( defined $recall_transfer_deleted ) { + $recall_transfer_deleted->revert_transfer; + } if($dest eq "ttr"){ print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl"); exit; @@ -359,6 +394,7 @@ $template->param( inputloop => \@inputloop ); my $found = 0; my $waiting = 0; my $reserved = 0; +my $recalled = 0; # new op dev : we check if the document must be returned to his homebranch directly, # if the document is transferred, we have warning message . @@ -417,7 +453,7 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { # # reserve found and item arrived at the expected branch # -if ( $messages->{'ResFound'}) { +if ( $messages->{'ResFound'} ) { my $reserve = $messages->{'ResFound'}; my $patron = Koha::Patrons->find( $reserve->{borrowernumber} ); my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } ); @@ -469,6 +505,40 @@ if ( $messages->{'ResFound'}) { ); } +if ( $messages->{RecallFound} ) { + my $recall = $messages->{RecallFound}; + if ( dt_from_string( $recall->timestamp ) == dt_from_string ) { + # we just updated this recall + $template->param( recall => $recall ); + } else { + my $transferbranch = $messages->{RecallNeedsTransfer}; + my $transfertodo = ( !$transferbranch or $transferbranch eq $recall->library->branchcode ) ? undef : 1; + $template->param( + found => 1, + recall => $recall, + recalled => $recall->waiting ? 0 : 1, + transfertodo => $transfertodo, + waitingrecall => $recall->waiting ? 1 : 0, + ); + } +} + +if ( $messages->{TransferredRecall} ) { + my $recall = $messages->{TransferredRecall}; + + # confirm transfer has arrived at the branch + my $transfer = Koha::Item::Transfers->search({ datearrived => { '!=' => undef }, itemnumber => $recall->itemnumber }, { order_by => { -desc => 'datearrived' } })->next; + + # if transfer has completed, show popup to confirm as waiting + if ( defined $transfer and $transfer->tobranch eq $recall->branchcode ) { + $template->param( + found => 1, + recall => $recall, + recalled => 1, + ); + } +} + # Error Messages my @errmsgloop; foreach my $code ( keys %$messages ) { @@ -550,6 +620,12 @@ foreach my $code ( keys %$messages ) { } elsif ( $code eq 'ReturnClaims' ) { $template->param( ReturnClaims => $messages->{ReturnClaims} ); + } elsif ( $code eq 'RecallFound' ) { + ; + } elsif ( $code eq 'RecallNeedsTransfer' ) { + ; + } elsif ( $code eq 'TransferredRecall' ) { + ; } else { die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die. # This forces the issue of staying in sync w/ Circulation.pm diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index d0545b20e9..d398ac733d 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -109,6 +109,13 @@ while ( my $library = $libraries->next ) { if ( my $first_hold = $holds->next ) { $getransf{patron} = Koha::Patrons->find( $first_hold->borrowernumber ); } + + # check for a recall for this transfer + my $recall = $item->recall; + if ( defined $recall ) { + $getransf{recall} = $recall; + } + push( @transferloop, \%getransf ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 2080b07707..4ef1173213 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -41,5 +41,8 @@ Checkout history [% IF ( CAN_user_tools_view_system_logs ) %][% IF ( logview ) %]
  • [% ELSE %]
  • [% END %]Modification log
  • [% END %] [% IF ( CAN_user_stockrotation_manage_rota_items && Koha.Preference('StockRotation') ) %][% IF ( stockrotationview ) %]
  • [% ELSE %]
  • [% END %]Rota
  • [% END %] + [% IF ( Koha.Preference('UseRecalls') && CAN_user_recalls ) %] + [% IF ( recallsview ) %]
  • [% ELSE %]
  • [% END %]Recalls ([% Biblio.RecallsCount( biblio_object_id ) | html %])
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index 824c1c9798..9b4940b2f3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -175,6 +175,9 @@ [% IF Koha.Preference('ILLModule') && CAN_user_ill %] [% IF illview %]
  • [% ELSE %]
  • [% END %]ILL requests history
  • [% END %] + [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %] + [% IF recallsview %]
  • [% ELSE %]
  • [% END %]Recalls history
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 14931325fd..99b882c76a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -46,6 +46,14 @@ [% IF Koha.Preference('OnSiteCheckouts') %]
  • Pending on-site checkouts
  • [% END %] + + [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] +
  • Recalls queue
  • +
  • Recalls to pull
  • +
  • Overdue recalls
  • +
  • Recalls awaiting pickup
  • +
  • Old recalls
  • + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc index 71a293588a..5a9b14d727 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc @@ -53,6 +53,7 @@ [%- END -%] [%- IF hide_patron_infos_if_needed AND ( display_patron_name OR display_cardnumber ) -%] [%- IF link_to == 'circulation_reserves' %] + [%- ELSIF link_to == 'circulation_recalls' %] [%- ELSE %] [%- END -%] [%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc new file mode 100644 index 0000000000..52b67ffbbc --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc @@ -0,0 +1,134 @@ +[% USE Branches %] +
    +[% IF recalls.count %] + + + + [% IF checkboxes %][% END %] + + [% UNLESS specific_patron %][% END %] + + + + + [% UNLESS viewing_old %][% END %] + [% UNLESS viewing_old %][% END %] + + + + + [% FOREACH recall IN recalls %] + [% IF recall.old %][% ELSE %][% END %] + + [% IF checkboxes %] + + [% END %] + + + + [% UNLESS specific_patron %] + + [% END %] + + + + + + + + + + [% UNLESS viewing_old %] + + [% END %] + + [% UNLESS viewing_old %] + + [% END %] + + + [% END %] + +
     TitleRequested byPlaced onExpires onPickup locationStatusDue date 
    + [% IF recall.old %] +   + [% ELSE %] + + [% END %] + + + [% recall.biblio.title | html %] + [% FOREACH s IN recall.biblio.subtitle %] + [% s | html %] + [% END %] + + [% IF recall.item %][% recall.item.barcode | html %][% END %] + [% recall.biblio.author | html %] + + [% recall.patron.firstname | html %] [% recall.patron.surname | html %] ([% recall.patron.cardnumber | html %]) + + [% recall.recalldate | $KohaDates %] + + [% IF ( recall.expirationdate ) %] + [% recall.expirationdate | $KohaDates %] + [% ELSIF ( !recall.old ) %] + Never expires + [% ELSE %] + - + [% END %] + + [% recall.library.branchname | html %] + + [% IF ( recall.in_transit ) %] + In transit to [% recall.library.branchname | html %] + [% ELSIF ( recall.waiting ) %] + Ready for pickup + [% ELSIF ( recall.expired ) %] + Expired on [% recall.expirationdate | $KohaDates %] + [% ELSIF ( recall.cancelled ) %] + Cancelled on [% recall.cancellationdate | $KohaDates %] + [% ELSIF ( recall.overdue ) %] + Overdue to be returned + [% ELSIF ( recall.finished ) %] + Fulfilled + [% ELSE %] + Requested + [% END %] + + [% IF recall.requested and recall.checkout %] + Due to be returned by [% recall.checkout.date_due | $KohaDates %] + [% ELSIF recall.waiting and RECALL.expirationdate %] + Pick up by [% RECALL.expirationdate | $KohaDates %] + [% ELSE %] + - + [% END %] + + [% IF recall.old %] +   + [% ELSE %] +
    + Actions + +
    + [% END %] +
    + [% ELSE %] + [% IF patron.borrowernumber %] +
    Patron has no recalls.
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] + [% END %] +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 70a22e7262..cae2357f35 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -495,14 +495,22 @@ Note that permanent location is a code, and location may be an authval. There is an item level hold on this item (priority = [% hold.priority | html %]). [% END %] [% END %] - [% UNLESS ( item.itemnotforloan || item.notforloan_per_itemtype || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfertwhen || hold ) %] - Available + + [% IF item.recalled %] + [% IF item.recall.waitingdate %] + Waiting at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.waitingdate | $KohaDates %] + [% ELSE %] + Item recalled by
    [% item.recall.patron.firstname | html %] [% item.recall.patron.surname | html %] ([% item.recall.patron.cardnumber | html %]) on [% item.recall.recalldate | $KohaDates %] + [% END %] + [% END %] + + [% UNLESS ( item.itemnotforloan || item.notforloan_per_itemtype || item.onloan || item.itemlost || item.withdrawn || item.damaged || item.transfertwhen || hold || item.recalled ) %] + Available [% END %] [% IF ( item.restricted ) %] ([% item.restrictedvalue | html %]) [% END %] - [% item.datelastseen | $KohaDates %] [% item.dateaccessioned | $KohaDates %] @@ -1030,6 +1038,7 @@ Note that permanent location is a code, and location may be an authval. [% MACRO jsinclude BLOCK %] [% INCLUDE 'catalog-strings.inc' %] [% Asset.js("js/catalog.js") | $raw %] + [% Asset.js("js/recalls.js") | $raw %] [% Asset.js("js/coce.js") | $raw %] [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] + [% Asset.js("js/recalls.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt index 2b0299fdb5..e75a25b6be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt @@ -8,6 +8,8 @@ Transfers print receipt › Circulation › Koha [% ELSIF ( caller == 'members' ) %] Print receipt for [% borrowernumber | html %] › Patrons › Koha +[% ELSIF ( caller == 'recall' ) %] +Recall print receipt › Circulation &rsqaquo; Koha [% ELSIF ( title ) %][%# FIXME title is never defined %] [% title | html %] › Patrons › Koha [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index d66fa733ec..14c1d9e4af 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -164,6 +164,9 @@ [% ELSIF error == "onsite_checkout" %]

    Item cannot be renewed because it's an onsite checkout

    + [% ELSIF error == 'recalled' %] +

    This item has been recalled.

    + [% ELSE %] [% error | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index d28c563576..c5f6bc7e1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -625,7 +625,7 @@ [% END # /IF transfer || needstransfer %] - [% IF ( reserved ) %] + [% IF ( reserved and !recalled and !waitingrecall ) %] [% END #/IF reserved %] + + [% IF ( recalled ) %] + + + [% END #/IF recalled %] + + [% IF ( waitingrecall ) %] + + + [% END #/IF recalledwaiting %] [% END # /IF found %]
    @@ -1041,6 +1234,11 @@ [% END %] [% END %] var columns_settings = [% TablesSettings.GetColumns( 'circ', 'returns', 'checkedintable', 'json' ) | $raw %] + + [% IF recall_slip %] + Dopop('/cgi-bin/koha/recalls/recall_pickup_slip.pl?recall_id=[% recall_id | uri %]'); + [% END %] + var returns_table = KohaTable("checkedintable", { "bFilter":false, "bPaginate":false, @@ -1124,6 +1322,11 @@ this.form.submit(); }); + $('.print-recall').on("click",function(e){ + this.form.recall_slip.value = 1; + this.form.submit(); + }); + $('.cancel-hold').on("click",function(e){ this.form.cancel_reserve.value = 1; this.form.submit(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt index 11ed6dfe86..26cee8e466 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt @@ -82,6 +82,8 @@ [% reser.patron.first_valid_email_address | html %] [% END %] + [% ELSIF ( reser.recall ) %] + Recall requested by [% reser.recall.patron.surname | html %][% IF reser.recall.patron.firstname %], [% reser.recall.patron.firstname | html %][% END %] ([% reser.recall.patron.cardnumber | html %]) [% ELSE %]

    None

    [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index d04371402a..335bbc2243 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -741,6 +741,14 @@ [% END %] + + [% IF Koha.Preference('UseRecalls') %] +
  • + + [% recalls.count | html %] Recalls + +
  • + [% END %] [% INCLUDE "checkouts-table.inc" %] @@ -763,6 +771,12 @@
    [% END %] + [% IF Koha.Preference('UseRecalls') %] +
    + [% INCLUDE 'recalls.inc' %] +
    + [% END %] + [% INCLUDE borrower_debarments.inc %] [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %] @@ -897,6 +911,7 @@ [% INCLUDE 'calendar.inc' %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] + [% Asset.js("js/recalls.js") | $raw %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt new file mode 100644 index 0000000000..a7ab7f424e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt @@ -0,0 +1,181 @@ +[% USE raw %] +[% USE Koha %] +[% USE KohaDates %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Recalls awaiting pickup › Circulation › Koha +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
    +
    + [% IF Koha.Preference('CircSidebar') %] +
    + [% ELSE %] +
    + [% END %] +
    +

    Recalls awaiting pickup

    + + [% IF Koha.Preference('UseRecalls') %] + +
    + + + +
    + [% IF ( recalls ) %] + + + + + + + + + + [% FOREACH recall IN recalls %] + + + + + + [% END %] + +
    Available sinceTitleRequested byPickup location 
    [% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title | html %] + [% FOREACH s IN recall.biblio.subtitle %] + [% s | html %] + [% END %] + + [% recall.biblio.author | html %] +
    Barcode: [% recall.item.barcode | html %] +
    + [% recall.patron.firstname | html %] [% recall.patron.surname | html %] + [% IF ( recall.patron.phone ) %]
    [% recall.patron.phone | html %][% END %] + [% IF ( recall.patron.email ) %]
    [% recall.patron.email | html %][% END %] +
    [% recall.library.branchname | html %] +
    + + +
    + + +
    +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] +
    + +
    + [% IF ( over.size ) %] + [% IF ( Koha.Preference('RecallsMaxPickUpDelay') ) %]

    Recalls listed here have been awaiting pickup for more than [% Koha.Preference('RecallsMaxPickUpDelay') | html %] days.

    [% END %] + + + + + + + + + + [% FOREACH recall IN over %] + + + + + + [% END %] + +
    Available sinceTitleRequested byPickup location 
    [% recall.waitingdate | $KohaDates %] + + [% recall.biblio.title | html %] + [% FOREACH s IN recall.biblio.subtitles %] + [% s | html %] + [% END %] + [% recall.item.enumchron | html %] + + [% recall.biblio.author | html %] +
    Barcode: [% recall.item.barcode | html %] +
    + [% recall.patron.firstname | html %] [% recall.patron.surname | html %] + [% IF ( recall.patron.phone ) %]
    [% recall.patron.phone | html %][% END %] + [% IF ( recall.patron.email ) %]
    [% recall.patron.email | html %][% END %] +
    [% recall.library.branchname | html %] +
    + + +
    + + +
    +
    +
    + [% ELSE %] +
    There are no recalls to show.
    + [% END %] +
    + +
    + + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + + [% IF Koha.Preference('CircSidebar') %] +
    + +
    + [% END %] + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt new file mode 100644 index 0000000000..2f4a573cf8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt @@ -0,0 +1,63 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Confirm recalls › Recalls › Koha +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
    +
    +
    +
    + +

    Existing recalls

    + + [% IF Koha.Preference('UseRecalls') %] + [% IF recalls.count %] +
    + + Select all + [% INCLUDE 'recalls.inc' %] +
    + +
    +
    + [% ELSE %] +
    No recalls have been made.
    + [% END %] + [% ELSE %] +
    Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
    + [% END %] + +
    +
    + +
    + +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/recalls.js") | $raw %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 7ca79df59c..6273c69c66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -375,7 +375,7 @@
    [% END %] - [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %] + [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted || recall ) %]
    [% UNLESS ( multi_hold ) %] @@ -397,6 +397,8 @@
  • No items are available to be placed on hold.
  • [% ELSIF ( maxreserves ) %]
  • Too many holds: [% patron.firstname | html %] [% patron.surname | html %] has too many holds.
  • + [% ELSIF ( recall ) %] +
  • [% patron.firstname | html %] [% patron.surname | html %] has already placed a recall on this item.
  • [% END # /IF exceeded_maxreserves %] [% ELSE # UNLESS multi_hold %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index c2924f5784..cdb1ef959c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -96,6 +96,8 @@ [% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] [% END %] [% CASE 'NEWS' %]News[% UNLESS Koha.Preference('NewsLog') %] [% END %] +[% CASE 'RECALLS' %]Recalls[% UNLESS Koha.Preference('RecallsLog') %] [% END %] + [% CASE %][% module | html %] [% END %] [% END %] @@ -143,6 +145,9 @@ [% CASE 'SERIAL CLAIM' %]Serial claim [% CASE 'ACQUISITION CLAIM' %]Acquisition claim [% CASE 'ACQUISITION ORDER' %]Acquisition order +[% CASE 'FULFILL' %]Fulfill +[% CASE 'OVERDUE' %]Overdue +[% CASE 'EXPIRE' %]Expire [% CASE %][% action | html %] [% END %] [% END %] @@ -213,7 +218,7 @@ [% ELSE %] [% END %] - [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS' ] %] + [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'NEWS', 'RECALLS' ] %] [% IF modules.grep(modx).size %] [% ELSE %] @@ -235,7 +240,7 @@ [% END %] - [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'FILL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' 'EDIT_MAPPINGS' 'RESET_MAPPINGS' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' 'CANCEL_ORDER' 'CREATE_ORDER' 'MODIFY_ORDER' 'CREATE_INVOICE_ADJUSTMENT' 'UPDATE_INVOICE_ADJUSTMENT' 'DELETE_INVOICE_ADJUSTMENT' 'RECEIVE_ORDER' 'MODIFY_BUDGET' 'MODIFY_FUND' 'CREATE_FUND' 'DELETE_FUND' ] %] + [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'FILL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' 'EDIT_MAPPINGS' 'RESET_MAPPINGS' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' 'CANCEL_ORDER' 'CREATE_ORDER' 'MODIFY_ORDER' 'CREATE_INVOICE_ADJUSTMENT' 'UPDATE_INVOICE_ADJUSTMENT' 'DELETE_INVOICE_ADJUSTMENT' 'RECEIVE_ORDER' 'MODIFY_BUDGET' 'MODIFY_FUND' 'CREATE_FUND' 'DELETE_FUND' 'OVERDUE' 'EXPIRE' 'FULFILL' ] %] [% IF actions.grep(actx).size %] [% ELSE %] @@ -366,6 +371,12 @@ [% ELSE %] [% loopro.object | html %] [% END %] + [% ELSIF ( loopro.module == 'RECALLS' ) %] + [% IF loopro.recall.item_level_recall %] + Item-level recall on item + [% ELSE %] + Biblio-level recall on biblio + [% END %] [% ELSE %] [% loopro.object | html %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 6246684a06..ae4c50fa9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -368,6 +368,10 @@ $(document).ready(function() { onsite_checkout += " (" + __("On-site checkout") + ")"; } + if ( oObj.recalled == 1 ) { + title += " - This item has been recalled and the due date updated."; + } + title += " " + "" + RECALLED + "" + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed-recalled"; } else if ( oObj.can_renew_error == "on_reserve" ) { msg += "" +"" + __("On hold") + "" @@ -591,7 +602,9 @@ $(document).ready(function() { "bSortable": false, "bVisible": AllowCirculate ? true : false, "mDataProp": function ( oObj ) { - if ( oObj.can_renew_error == "on_reserve" ) { + if ( oObj.can_renew_error == "recalled" ) { + return "" + __("Recalled") + ""; + } else if ( oObj.can_renew_error == "on_reserve" ) { return "" + __("On hold") + ""; } else if ( oObj.materials ) { return ""; diff --git a/koha-tmpl/intranet-tmpl/prog/js/recalls.js b/koha-tmpl/intranet-tmpl/prog/js/recalls.js new file mode 100644 index 0000000000..c45a6c8f19 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/recalls.js @@ -0,0 +1,175 @@ +$(document).ready(function() { + + $(".cancel_recall").click(function(e){ + if (confirmDelete(__("Are you sure you want to remove this recall?"))){ + var $self = $(this); + var $recall_id = $(this).data('id'); + var $action = $(this).data('action'); + var ajaxData = { + 'recall_id': $recall_id, + 'action' : $action, + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/recall', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + .done(function(data) { + var message = ""; + if(data.success == 0) { + message = __("The recall may have already been cancelled. Please refresh the page."); + } else { + message = __("Cancelled"); + } + $self.parent().parent().parent().parent().html(message); + }); + } + }); + + $(".expire_recall").click(function(e){ + if (confirmDelete(__("Are you sure you want to expire this recall?"))){ + var $self = $(this); + var $recall_id = $(this).data('id'); + var $action = $(this).data('action'); + var ajaxData = { + 'recall_id': $recall_id, + 'action' : $action, + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/recall', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + .done(function(data) { + var message = ""; + if(data.success == 0) { + message = __("The recall may have already been expired. Please refresh the page."); + } else { + message = __("Expired"); + } + $self.parent().parent().parent().parent().html(message); + }); + } + }); + + $(".revert_recall").click(function(e){ + if (confirmDelete(__("Are you sure you want to revert the waiting status of this recall?"))){ + var $self = $(this); + var $recall_id = $(this).data('id'); + var $action = $(this).data('action'); + var ajaxData = { + 'recall_id': $recall_id, + 'action' : $action, + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/recall', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + .done(function(data) { + var message = ""; + if(data.success == 0) { + message = __("The recall waiting status may have already been reverted. Please refresh the page."); + } else { + message = __("Status updated"); + } + $self.parent().parent().parent().parent().html(message); + }); + } + }); + + $(".overdue_recall").click(function(e){ + if (confirmDelete(__("Are you sure you want to mark this recall as overdue?"))){ + var $self = $(this); + var $recall_id = $(this).data('id'); + var $action = $(this).data('action'); + var ajaxData = { + 'recall_id': $recall_id, + 'action' : $action, + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/recall', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + .done(function(data) { + var message = ""; + if(data.success == 0) { + message = __("The recall may have already been marked as overdue. Please refresh the page."); + } else { + message = __("Marked overdue"); + } + $self.parent().parent().parent().parent().html(message); + }); + } + }); + + $(".transit_recall").click(function(e){ + if (confirmDelete(__("Are you sure you want to remove this recall and return the item to it's home library?"))){ + var $self = $(this); + var $recall_id = $(this).data('id'); + var $action = $(this).data('action'); + var ajaxData = { + 'recall_id': $recall_id, + 'action' : $action, + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/recall', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + .done(function(data) { + var message = ""; + if(data.success == 0) { + message = __("The recall may have already been removed. Please refresh the page."); + } else { + message = __("Cancelled"); + } + $self.parent().parent().parent().parent().html(message); + }); + } + }); + + $("#recalls-table").dataTable($.extend(true, {}, dataTablesDefaults, { + "aoColumnDefs": [ + { 'bSortable': false, 'aTargets': [ 'nosort' ] }, + { "sType": "title-string", "aTargets" : [ "title-string" ] }, + { "sType": "anti-the", "aTargets": [ "anti-the" ] } + ], + "sPaginationType": "full_numbers" + })); + + $("#cancel_selected").click(function(e){ + if ($("input[name='recall_ids']:checked").length > 0){ + return confirmDelete(__("Are you sure you want to remove the selected recall(s)?")); + } else { + alert(__("Please make a selection.")); + } + }); + + $("#select_all").click(function(){ + if ($("#select_all").prop("checked")){ + $("input[name='recall_ids']").prop("checked", true); + } else { + $("input[name='recall_ids']").prop("checked", false); + } + }); + + $("#hide_old").click(function(){ + if ($("#hide_old").prop("checked")){ + $(".old").show(); + } else { + $(".old").hide(); + } + }); +}); diff --git a/members/moremember.pl b/members/moremember.pl index 9f74c53586..2d3a39bc1c 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -273,6 +273,8 @@ $template->param( files => Koha::Patron::Files->new( borrowernumber => $borrowernumber ) ->GetFilesInfo(), #debarments => scalar GetDebarments({ borrowernumber => $borrowernumber }), has_modifications => $has_modifications, + recalls => $patron->recalls, + specific_patron => 1, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/recallshistory.pl b/members/recallshistory.pl new file mode 100755 index 0000000000..c67901931f --- /dev/null +++ b/members/recallshistory.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. + +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); + +my $input = CGI->new; +my ($template, $loggedinuser, $cookie)= get_template_and_user( + { + template_name => "members/recallshistory.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 1 }, + debug => 1, + } +); + +my $borrowernumber = $input->param('borrowernumber'); +my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber }, { order_by => { '-desc' => 'recalldate' } }); +my $patron = Koha::Patrons->find( $borrowernumber ); + +$template->param( + patron => $patron, + recalls => $recalls, + recallsview => 1, + specific_patron => 1, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/recalls/recall_pickup_slip.pl b/recalls/recall_pickup_slip.pl new file mode 100755 index 0000000000..cc6a02e73a --- /dev/null +++ b/recalls/recall_pickup_slip.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Context; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); + +my $input = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/printslip.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + } +); + +my $recallid = $input->param('recall_id'); +my $recall = Koha::Recalls->find($recallid); + +my $itemnumber; +if ( $recall->itemnumber ){ + $itemnumber = $recall->itemnumber; +} else { + $itemnumber = $recall->checkout->itemnumber; +} + +# Print slip to inform library staff of details of recall requester, so the item can be put aside for requester +my $letter = C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => 'RECALL_REQUESTER_DET', + message_transport_type => 'print', + tables => { + 'branches' => $recall->branchcode, + 'borrowers' => $recall->borrowernumber, + 'biblio' => $recall->biblionumber, + 'items' => $itemnumber, + 'recalls' => $recall->recall_id, + } +); + +my ($slip, $is_html); +if ($letter) { + $slip = $letter->{content}; + $is_html = $letter->{is_html}; +} + +$template->param( + slip => $slip, + plain => !$is_html, + caller => 'recall', +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/recalls/recalls_old_queue.pl b/recalls/recalls_old_queue.pl new file mode 100755 index 0000000000..ed826774ab --- /dev/null +++ b/recalls/recalls_old_queue.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_old_queue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $recalls = Koha::Recalls->search({ old => 1 }); +$template->param( + recalls => $recalls, + viewing_old => 1 +); + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_overdue.pl b/recalls/recalls_overdue.pl new file mode 100755 index 0000000000..82b755ccf3 --- /dev/null +++ b/recalls/recalls_overdue.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::BiblioFrameworks; +use Koha::DateUtils; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_overdue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my @recall_ids = $query->multi_param('recall_ids'); + +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} + +if ( $op eq 'list' ) { + my $recalls = Koha::Recalls->search({ status => 'O' }); + # will be set as Overdue by the misc/cronjobs/recall/overdue_recalls.pl cronjob + $template->param( + recalls => $recalls, + checkboxes => 1, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_queue.pl b/recalls/recalls_queue.pl new file mode 100755 index 0000000000..59ceb00314 --- /dev/null +++ b/recalls/recalls_queue.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_queue.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 'manage_recalls' }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my @recall_ids = $query->multi_param('recall_ids'); +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} +elsif ( $op eq 'list' ) { + my $recalls = Koha::Recalls->search({ old => undef }); + $template->param( + recalls => $recalls, + checkboxes => 1, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_to_pull.pl b/recalls/recalls_to_pull.pl new file mode 100755 index 0000000000..1665221bb7 --- /dev/null +++ b/recalls/recalls_to_pull.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::BiblioFrameworks; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_to_pull.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => 'manage_recalls' }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; +my $recall_id = $query->param('recall_id'); +if ( $op eq 'cancel' ) { + my $recall = Koha::Recalls->find( $recall_id ); + if ( $recall->in_transit ) { + C4::Items::ModItemTransfer( $recall->item->itemnumber, $recall->item->holdingbranch, $recall->item->homebranch, 'CancelRecall' ); + } + $recall->set_cancelled; + $op = 'list'; +} + +if ( $op eq 'list' ) { + my @recalls = Koha::Recalls->search({ status => [ 'R','O','T' ] }); + my @pull_list; + my %seen_bib; + foreach my $recall ( @recalls ) { + if ( $seen_bib{$recall->biblionumber} ){ + # we've already looked at the recalls on this biblio + next; + } else { + # this is an unseen biblio + $seen_bib{$recall->biblionumber}++; + + # get recall data about this biblio + my @this_bib_recalls = Koha::Recalls->search({ biblionumber => $recall->biblionumber, status => [ 'R','O','T' ] }, { order_by => { -asc => 'recalldate' } }); + my $recalls_count = scalar @this_bib_recalls; + my @unique_patrons = do { my %seen; grep { !$seen{$_->borrowernumber}++ } @this_bib_recalls }; + my $patrons_count = scalar @unique_patrons; + my $first_recall = $this_bib_recalls[0]; + + my $items_count = 0; + my @callnumbers; + my @copynumbers; + my @enumchrons; + my @itemtypes; + my @locations; + my @libraries; + + my @items = Koha::Items->search({ biblionumber => $recall->biblionumber }); + foreach my $item ( @items ) { + if ( $item->can_be_waiting_recall and !$item->checkout ) { + # if item can be pulled to fulfill recall, collect item data + $items_count++; + push( @callnumbers, $item->itemcallnumber ) if ( $item->itemcallnumber ); + push( @copynumbers, $item->copynumber ) if ( $item->copynumber ); + push( @enumchrons, $item->enumchron ) if ( $item->enumchron ); + push( @itemtypes, $item->effective_itemtype ) if ( $item->effective_itemtype ); + push( @locations, $item->location ) if ( $item->location ); + push( @libraries, $item->holdingbranch ) if ( $item->holdingbranch ); + } + } + + if ( $items_count > 0 ) { + # don't push data if there are no items available for this recall + + # get unique values + my @unique_callnumbers = do { my %seen; grep { !$seen{$_}++ } @callnumbers }; + my @unique_copynumbers = do { my %seen; grep { !$seen{$_}++ } @copynumbers }; + my @unique_enumchrons = do { my %seen; grep { !$seen{$_}++ } @enumchrons }; + my @unique_itemtypes = do { my %seen; grep { !$seen{$_}++ } @itemtypes }; + my @unique_locations = do { my %seen; grep { !$seen{$_}++ } @locations }; + my @unique_libraries = do { my %seen; grep { !$seen{$_}++ } @libraries }; + + push( @pull_list, { + biblio => $recall->biblio, + items_count => $items_count, + recalls_count => $recalls_count, + patrons_count => $patrons_count, + pull_count => $items_count <= $recalls_count ? $items_count : $recalls_count, + first_recall => $first_recall, + callnumbers => \@unique_callnumbers, + copynumbers => \@unique_copynumbers, + enumchrons => \@unique_enumchrons, + itemtypes => \@unique_itemtypes, + locations => \@unique_locations, + libraries => \@unique_libraries, + }); + } + } + } + $template->param( + recalls => \@pull_list, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/recalls_waiting.pl b/recalls/recalls_waiting.pl new file mode 100755 index 0000000000..0814ffaa25 --- /dev/null +++ b/recalls/recalls_waiting.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::Recalls; +use Koha::BiblioFrameworks; +use Koha::DateUtils; +use Koha::Patrons; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => "recalls/recalls_waiting.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $query->param('op') || 'list'; + +if ( $op eq 'modify' ) { + my $expire = $query->param('expire') || ''; + my $revert = $query->param('revert') || ''; + my $recall_id = $query->param('recall_id'); + if ( $expire ) { + Koha::Recalls->find( $recall_id )->set_expired({ interface => 'INTRANET' }); + } elsif ( $revert ) { + Koha::Recalls->find( $recall_id )->revert_waiting; + } + $op = 'list'; +} + +if ( $op eq 'list' ) { + my @recalls = Koha::Recalls->search({ status => 'W' }); + my $borrower = Koha::Patrons->find( $loggedinuser ); + my @over; + my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7; + my $today = dt_from_string(); + foreach my $r ( @recalls ){ + my $lastwaitingday = dt_from_string( $r->waitingdate )->add( days => $maxdelay ); + if ( $today > $lastwaitingday ){ + push @over, $r; + } + } + $template->param( + recalls => \@recalls, + over => \@over, + ); +} + +# Checking if there is a Fast Cataloging Framework +$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ); + +# writing the template +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/recalls/request.pl b/recalls/request.pl new file mode 100755 index 0000000000..59a4b4555b --- /dev/null +++ b/recalls/request.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use C4::Search; +use Koha::Recalls; +use Koha::Biblios; + +my $input = CGI->new; +my ($template, $loggedinuser, $cookie)= get_template_and_user( + { + template_name => "recalls/request.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { recalls => "manage_recalls" }, + debug => 1, + } +); + +my $op = $input->param('op') || 'list'; +my @recall_ids = $input->multi_param('recall_ids'); +my $biblionumber = $input->param('biblionumber'); +my $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef }); +my $biblio = Koha::Biblios->find( $biblionumber ); + +if ( $op eq 'cancel_multiple_recalls' ) { + foreach my $id ( @recall_ids ) { + Koha::Recalls->find( $id )->set_cancelled; + } + $op = 'list' +} + +if ( $op eq 'list' ) { + $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef }); + $biblio = Koha::Biblios->find( $biblionumber ); +} + +$template->param( + recalls => $recalls, + recallsview => 1, + biblio => $biblio, + checkboxes => 1, + C4::Search::enabled_staff_search_views, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/reserve/request.pl b/reserve/request.pl index 9a9eb98a5d..15067821cc 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -332,6 +332,10 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) $template->param( $canReserve->{status} => 1); $biblioloopiter{ $canReserve->{status} } = 1; } + elsif ( $canReserve->{status} eq 'recall' ) { + $template->param( $canReserve->{status} => 1 ); + $biblioloopiter{ $canReserve->{status} } = 1; + } else { $biblioloopiter{ $canReserve->{status} } = 1; } diff --git a/svc/checkouts b/svc/checkouts index 30bbee53b1..852827e0d0 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -209,6 +209,27 @@ while ( my $c = $sth->fetchrow_hashref() ) { $materials = $descriptions->{lib} // $c->{materials}; } my @subtitles = split(/ \| /, $c->{'subtitle'} // '' ); + + my $item = Koha::Items->find( $c->{itemnumber} ); + my $recalled = 0; + my $recall = undef; + $recall = $item->check_recalls if $item->can_be_waiting_recall; + if ( defined $recall ) { + if ( $recall->item_level_recall ) { + if ( $recall->itemnumber == $c->{itemnumber} ) { + # item-level recall on this item + $recalled = 1; + } else { + $recalled = 0; + } + } else { + # biblio-level recall, but don't want to mark recalled if the recall has been allocated a different item + if ( !$recall->waiting ) { + $recalled = 1; + } + } + } + my $checkout = { DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, title => $c->{title}, @@ -281,6 +302,7 @@ while ( my $c = $sth->fetchrow_hashref() ) { cardnumber => $c->{cardnumber}, }, issued_today => !$c->{not_issued_today}, + recalled => $recalled, }; if ( $c->{not_issued_today} ) { diff --git a/svc/recall b/svc/recall new file mode 100755 index 0000000000..35c24585ff --- /dev/null +++ b/svc/recall @@ -0,0 +1,89 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI; +use JSON qw(encode_json); + +use C4::Context; +use C4::Auth qw(check_cookie_auth); +use C4::Output qw(output_with_http_headers); +use C4::Circulation qw(AddReturn); +use Koha::Recalls; + +my $input = new CGI; +my $json = encode_json({ success => 0 }); + +my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { recall => 'manage_recalls' } ); + +if ( $auth_status ne "ok" ) { + print $input->header(-type => 'text/plain', -status => '403 Forbidden'); + exit 0; +} + +my $recall_id = $input->param('recall_id'); +my $recall = Koha::Recalls->find( $recall_id ); +unless ( $recall ) { + my $json = encode_json({ success => 0 }); + output_with_http_headers( $input, undef, $json, "json" ); + exit; +} + +my $op = $input->param('action'); + +if ( $op eq 'cancel' ) { + # cancel recall + $recall->set_cancelled; + if ( $recall->cancelled ){ + $json = encode_json({ success => 1 }); + } + +} elsif ( $op eq 'expire' ) { + # expire recall + $recall->set_expired({ interface => 'INTRANET' }); + if ( $recall->expired ){ + $json = encode_json({ success => 1 }); + } + +} elsif ( $op eq 'revert' ) { + # revert recall waiting status + $recall->revert_waiting; + if ( $recall->requested ){ + $json = encode_json({ success => 1 }); + } + +} elsif ( $op eq 'overdue' ) { + # mark recall as overdue + $recall->set_overdue({ interface => 'INTRANET' }); + if ( $recall->overdue ){ + $json = encode_json({ success => 1 }); + } + +} elsif ( $op eq 'transit' ) { + # cancel recall and return item to home library + if ( $recall->in_transit ) { + C4::Items::ModItemTransfer( $recall->item->itemnumber, $recall->item->holdingbranch, $recall->item->homebranch, 'CancelRecall' ); + } + $recall->set_cancelled; + if ( $recall->cancelled ){ + $json = encode_json({ success => 1 }); + } +} + +output_with_http_headers( $input, undef, $json, "json" ); diff --git a/tools/letter.pl b/tools/letter.pl index 68b9eed449..1b6f39ae89 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -249,7 +249,7 @@ sub add_form { {value => 'items.fine', text => 'items.fine'}, add_fields('borrowers'); if ($module eq 'circulation') { - push @{$field_selection}, add_fields('additional_contents'); + push @{$field_selection}, add_fields('additional_contents', 'recalls'); } diff --git a/tools/viewlog.pl b/tools/viewlog.pl index 2d9b56ec78..9f32a9ef76 100755 --- a/tools/viewlog.pl +++ b/tools/viewlog.pl @@ -189,6 +189,15 @@ if ($do_it) { } } + # get recall information + if ( $log->module eq "RECALLS" ) { + if ( $log->object ) { + my $recall = Koha::Recalls->find( $log->object ); + if ( $recall && $output eq 'screen' ) { + $result->{recall} = $recall; + } + } + } push @data, $result; } if ( $output eq "screen" ) { -- 2.39.5