Bug 15516: (follow-up) Tweaks to new feature

Bug 15516: Add ability to create and view hold groups from OPAC

This patch adds a "Treat as hold group" to opac-reserve.pl,
which lets OPAC users create a hold group which can include
1+ bibs and either bib-level holds, or item-level holds, or both.

This patch shows the item-level and bib-level holds in a hold group
for the user's holds in the OPAC. This includes both the opac-user.pl
page and the self-checkout hold display.

Bug 15516: (follow-up) Only show hold groups for multi hold in OPAC
Bug 15516: (follow-up) Only show hold groups for multi hold in staff interface
Bug 15516: Add 'DisplayAddHoldGroups' system preference to toggle ability to add titles to hold groups

These patches add the ability to create hold groups across multiple bibs in the staff interface or OPAC.
These hold groups are fulfilled by the first item checked in across the hold group.

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
David Cook 2024-02-13 05:35:54 +00:00 committed by Lucas Gass
parent 559801d408
commit c1e7da6eed
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
11 changed files with 67 additions and 16 deletions

View File

@ -218,10 +218,8 @@ Return the number of holds, where a hold group is counted as one hold.
sub count_holds {
my ( $self, $search_params ) = @_;
$search_params = {
hold_group_id => undef,
};
$search_params = {} if !$search_params;
$search_params->{hold_group_id} = undef;
my $holds_without_group_count = $self->search($search_params)->count();
$search_params = {

View File

@ -221,6 +221,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('DefaultToLoggedInLibraryNoticesSlips', '0', NULL , 'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'),
('DefaultToLoggedInLibraryOverdueTriggers', '0', NULL , 'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.', 'YesNo'),
('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding staff interface XSLT option must be on','Choice'),
('DisplayAddHoldGroups','1','','Display the ability to create hold groups which are fulfilled by one item','YesNo'),
('DisplayClearScreenButton','no','no|issueslip|issueqslip','If set to ON, a clear screen button will appear on the circulation page.','Choice'),
('displayFacetCount','0',NULL,NULL,'YesNo'),
('DisplayIconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.','YesNo'),

View File

@ -960,6 +960,12 @@ Circulation:
1: Enable
0: "Don't enable"
- "the ability to place holds on different items at the same time in staff interface and OPAC."
-
- pref: DisplayAddHoldGroups
choices:
1: Enable
0: "Don't enable"
- "the ability to create hold groups which are fulfilled by one item"
-
- pref: TransferWhenCancelAllWaitingHolds
choices:

View File

@ -619,14 +619,6 @@
<input name="non_priority" id="non_priority" type="checkbox" />
<span class="hint">A non priority hold doesn't prevent a current checkout from renewing</span>
</li>
[% IF ( Koha.Preference('DisplayAddHoldGroups') && ( multi_hold ) ) %]
<li id="hold_group_list_item">
<label for="hold_group">Treat as hold group: </label>
<input name="hold_group" id="hold_group" type="checkbox" />
<span class="hint">Place a hold on the next available title from this group</span>
</li>
[% END %]
</ol>
</fieldset>
<fieldset class="rows any_specific">
@ -1097,6 +1089,14 @@
<label for="to">Hold expires on date:</label>
<input id="expiration_date" name="expiration_date" id="to" size="10" type="text" class="flatpickr" data-flatpickr-futuredate="true" />
</li>
[% IF ( Koha.Preference('DisplayAddHoldGroups') ) %]
<li id="hold_group_list_item">
<label for="hold_group">Treat as hold group: </label>
<input name="hold_group" id="hold_group" type="checkbox" />
<span class="hint">Place a hold on the next available title from this group</span>
</li>
[% END %]
</ol>
<table id="requesttitles">
<tr>

View File

@ -64,6 +64,22 @@
[% IF HOLD.item_level_hold %]
<p class="hint">Item on hold: [% HOLD.item.barcode | html %]</p>
[% END %]
[% IF HOLD.hold_group_id %]
<div class="group_hold">
<span class="hint">(part of a hold group)</span>
<div class="group_hold_list" style="display:none">
[% group_holds = HOLD.hold_group.holds %]
[% IF ( group_holds.count ) %]
<span class="hint">Containing the following:</span>
<ul>
[% FOREACH hg_member IN group_holds %]
<li>[% INCLUDE 'biblio-title.inc' biblio=hg_member.biblio link=>1 %]</li>
[% END %]
</ul>
[% END %]
</div>
</div>
[% END %]
</td>
<td class="reservedate" data-order="[% HOLD.reservedate | html %]"> [% HOLD.reservedate | $KohaDates %] </td>
<td class="expirationdate" data-order="[% !HOLD.found ? HOLD.expirationdate : '0000-00-00' | html %]">

View File

@ -110,6 +110,18 @@
[% INCLUDE 'csrf-token.inc' %]
<legend class="sr-only">Hold requests</legend>
<input type="hidden" name="op" value="cud-place_reserve" />
[% IF ( Koha.Preference('DisplayAddHoldGroups') && ( multi_hold ) ) %]
<div id="hold_group">
<fieldset class="rows">
<ul>
<li>
<label for="add_to_hold_group_control">Treat as hold group (next available item fulfills all holds):</label>
<input type="checkbox" id="add_to_hold_group_control" name="add_to_hold_group" value="add_to_hold_group" />
</li>
</ul>
</fieldset>
</div>
[% END %]
<!-- These values are set dynamically by js -->
<input type="hidden" name="biblionumbers" id="biblionumbers" />
<input type="hidden" name="selecteditems" id="selections" />

View File

@ -272,7 +272,7 @@
[% IF ( RESERVES.count ) %]
[% WRAPPER tab_item tabname= "opac-user-holds" %]
<span>Holds ([% RESERVES.count | html %])</span>
<span>Holds ([% reserves_count | html %])</span>
[% END %]
[% END %]
[% IF Koha.Preference('UseRecalls') && RECALLS.count %]
@ -1443,4 +1443,5 @@
});
</script>
[% END %]
[% Asset.js("js/holds.js") | $raw %]
[% END %]

View File

@ -522,6 +522,7 @@
});
});
</script>
[% Asset.js("js/holds.js") | $raw %]
[% IF ( Koha.Preference('SCOUserJS') ) %]
<script>
[% Koha.Preference('SCOUserJS') | $raw %]

View File

@ -0,0 +1,5 @@
$(document).ready(function () {
$("div.group_hold").click(function () {
$(this).find("div.group_hold_list").toggle();
});
});

View File

@ -160,7 +160,8 @@ $template->param( branch => $branch );
#
#
if ( $op eq 'cud-place_reserve' ) {
my $reserve_cnt = 0;
my $add_to_hold_group = $query->param('add_to_hold_group');
my $reserve_cnt = 0;
if ($maxreserves) {
$reserve_cnt = $patron->holds->count_holds;
}
@ -194,6 +195,7 @@ if ( $op eq 'cud-place_reserve' ) {
}
my @failed_holds;
my $hold_group;
while (@selectedItems) {
my $biblioNum = shift(@selectedItems);
my $itemNum = shift(@selectedItems);
@ -290,6 +292,13 @@ if ( $op eq 'cud-place_reserve' ) {
# Here we actually do the reserveration. Stage 3.
if ($canreserve) {
if ($add_to_hold_group) {
#NOTE: We wait to create a hold group until we know that we can actually place a hold/reserve
if ( !$hold_group ) {
$hold_group = Koha::HoldGroup->new->store;
}
}
my $reserve_id = AddReserve(
{
branchcode => $branch,
@ -304,6 +313,7 @@ if ( $op eq 'cud-place_reserve' ) {
found => undef,
itemtype => $itemtype,
item_group_id => $item_group_id,
hold_group_id => $hold_group ? $hold_group->id : undef,
}
);
if ($reserve_id) {

View File

@ -347,8 +347,9 @@ $template->param( show_barcode => 1 ) if $show_barcode;
my $reserves = $patron->holds->filter_out_has_cancellation_requests;
$template->param(
RESERVES => $reserves,
showpriority => $show_priority,
RESERVES => $reserves,
reserves_count => $reserves->count_holds,
showpriority => $show_priority,
);
if ( C4::Context->preference('UseRecalls') ) {