From 911f0f04b9664d777ba2cbbf657dec07029a5bd7 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 18 Jun 2021 07:32:25 +0000 Subject: [PATCH] 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. Signed-off-by: Michal Denar Signed-off-by: Michal Denar --- .../bootstrap/en/includes/holds-table.inc | 16 ++++++++++++++++ .../bootstrap/en/modules/opac-reserve.tt | 10 ++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 3 ++- .../bootstrap/en/modules/sco/sco-main.tt | 2 +- koha-tmpl/opac-tmpl/bootstrap/js/holds.js | 5 +++++ opac/opac-reserve.pl | 12 +++++++++++- opac/opac-user.pl | 1 + 7 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/holds.js diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc index 0a35aa715d..82691389b9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -64,6 +64,22 @@ [% IF HOLD.item_level_hold %]

Item on hold: [% HOLD.item.barcode | html %]

[% END %] + [% IF HOLD.hold_group_id %] +
+ (part of a hold group) + +
+ [% END %] [% HOLD.reservedate | $KohaDates %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 7b1e9d3708..5072e189c9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -145,6 +145,16 @@
Hold requests +
+
+
    +
  • + + +
  • +
+
+
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 996e466fc7..dc8338418e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -287,7 +287,7 @@ [% IF ( RESERVES.count ) %] [% WRAPPER tab_item tabname= "opac-user-holds" %] - Holds ([% RESERVES.count | html %]) + Holds ([% reserves_count | html %]) [% END %] [% END %] [% IF Koha.Preference('UseRecalls') && RECALLS.count %] @@ -1467,4 +1467,5 @@ }); [% END %] + [% Asset.js("js/holds.js") | $raw %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 5f8e8eee3e..8a6e7d3ee0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -616,6 +616,6 @@ }); - + [% Asset.js("js/holds.js") | $raw %] [% IF ( Koha.Preference('SCOUserJS') ) %][% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/holds.js b/koha-tmpl/opac-tmpl/bootstrap/js/holds.js new file mode 100644 index 0000000000..734c544adf --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/js/holds.js @@ -0,0 +1,5 @@ +$(document).ready(function(){ + $("div.group_hold").click(function(){ + $(this).find("div.group_hold_list").toggle(); + }); +}); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 0d7890d0e5..edb9f86a17 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -180,7 +180,8 @@ $template->param( branch => $branch ); # # if ( $query->param('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; } @@ -213,6 +214,7 @@ if ( $query->param('place_reserve') ) { } my @failed_holds; + my $hold_group; while (@selectedItems) { my $biblioNum = shift(@selectedItems); my $itemNum = shift(@selectedItems); @@ -306,6 +308,13 @@ if ( $query->param('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, @@ -320,6 +329,7 @@ if ( $query->param('place_reserve') ) { found => undef, itemtype => $itemtype, item_group_id => $item_group_id, + hold_group_id => $hold_group ? $hold_group->id : undef, } ); if( $reserve_id ){ diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 5c7296b201..ed2c4a8589 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -339,6 +339,7 @@ my $reserves = $patron->holds->filter_out_has_cancellation_requests; $template->param( RESERVES => $reserves, + reserves_count => $reserves->count_holds, showpriority => $show_priority, ); -- 2.30.2