From 7ab0d559f7f10a292f46724204ec7df107e6d867 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 4 Aug 2022 15:20:59 +1200 Subject: [PATCH] Bug 15516: Allow to reserve first available item from a group of titles It can be useful, for instance, if a library has the same title from different publishers (so 1 title but several biblio records) but the user only wants a copy of the book, regardless of the publisher. Test plan: 0. Run updatedatabase.pl and misc/devel/update_dbix_class_files.pl 1. Go to intranet search, display some results, click on some checkboxes and click on 'Place hold' button at the top of the results. 2. Search for a patron 3. Check the 'Treat as hold group' checkbox 4. Click on 'Place hold' 5. In the next screen you should see all the holds you placed with the additional text '(part of a hold group)' in Details column. 6. Click on the "hold group" link. A modal window should appear with the content of the hold group (a list of holds) 7. Check in an item of one of the reserved biblios and confirm the hold 8. The hold status is changed to Waiting, and all other holds are deleted. The other holds will also be removed from the holds queue. 9. Confirm tests pass - t/db_dependent/Koha/Holds.t - t/db_dependent/Reserves/HoldGroup.t Note: the "hold group" link is displayed in the following pages: - reserve/request.pl - circ/circulation.pl - members/moremember.pl - circ/pendingreserves.pl - circ/view_holdsqueue.pl Note: A hold group is counted as only one hold Sponsored-by: Catalyst IT Signed-off-by: Michal Denar Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Michal Denar --- circ/circulation.pl | 2 +- circ/view_holdsqueue.pl | 10 +++++ .../prog/en/includes/hold-group-modal.inc | 14 +++++++ .../prog/en/includes/holds_table.inc | 3 ++ .../prog/en/modules/circ/circulation.tt | 3 ++ .../prog/en/modules/circ/pendingreserves.tt | 6 +++ .../prog/en/modules/circ/view_holdsqueue.tt | 6 +++ .../prog/en/modules/members/moremember.tt | 2 + .../prog/en/modules/reserve/hold-group.tt | 31 ++++++++++++++ .../prog/en/modules/reserve/request.tt | 15 ++++++- koha-tmpl/intranet-tmpl/prog/js/hold-group.js | 8 ++++ koha-tmpl/intranet-tmpl/prog/js/holds.js | 11 +++++ members/moremember.pl | 4 +- opac/opac-reserve.pl | 2 +- reserve/hold-group.pl | 42 +++++++++++++++++++ reserve/placerequest.pl | 42 ++++++++++++------- reserve/request.pl | 3 +- svc/holds | 1 + t/db_dependent/Koha/Holds.t | 2 +- 19 files changed, 183 insertions(+), 24 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/hold-group-modal.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reserve/hold-group.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/js/hold-group.js create mode 100755 reserve/hold-group.pl diff --git a/circ/circulation.pl b/circ/circulation.pl index 5d432b4f80..ffc52b90ad 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -598,7 +598,7 @@ if ($patron) { my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); # FIXME must be Koha::Patron->holds my $waiting_holds = $holds->waiting; $template->param( - holds_count => $holds->count(), + holds_count => $holds->count_holds, WaitingHolds => $waiting_holds, ); diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl index 7bc73f6da6..4cb5b021ab 100755 --- a/circ/view_holdsqueue.pl +++ b/circ/view_holdsqueue.pl @@ -55,6 +55,16 @@ if ($run_report) { locationslimit => $locationslimit } ); + for my $item (@$items) { + my $related_hold = Koha::Holds->search( + { + borrowernumber => $item->{borrowernumber}, reservedate => $item->{reservedate}, + biblionumber => $item->{biblionumber} + }, + { order_by => 'reservedate' } + )->next; + $item->{hold_group_id} = $related_hold ? $related_hold->hold_group_id : undef; + } $template->param( branchlimit => $branchlimit, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/hold-group-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/hold-group-modal.inc new file mode 100644 index 0000000000..8f0f9f7e50 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/hold-group-modal.inc @@ -0,0 +1,14 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 70ff63bf36..cb98efbccf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -260,6 +260,9 @@ [%- IF hold.non_priority -%]
Non priority hold [%- END -%] + [%- IF hold.hold_group_id -%] +
(part of a hold group)
+ [%- END -%] [%- IF ( CAN_user_reserveforothers_modify_holds_priority ) -%] [%- UNLESS hold.found -%] 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 f6cddb1d60..439d2726d2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1074,6 +1074,8 @@ [% END %] [% INCLUDE modals/cancel_booking.inc %] +[% INCLUDE 'hold-group-modal.inc' %] + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'select2.inc' %] @@ -1113,6 +1115,7 @@ [% Asset.js("js/cancel_booking_modal.js") | $raw %] [% Asset.js("js/combobox.js") | $raw %] [% INCLUDE 'js-biblio-format.inc' %] + [% Asset.js("js/hold-group.js") | $raw %]