From f3b51d2062da886e93f1d8a90deab636b1115f6e 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 | 9 +++++++++ opac/opac-user.pl | 1 + 7 files changed, 44 insertions(+), 2 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 5daded0745..5c581b2f3e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -59,6 +59,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 date: 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 8bb46e8ff7..0085fc5516 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -159,6 +159,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 11275fab5f..8e55022b79 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -242,7 +242,7 @@ [% IF ( RESERVES.count ) %] [% END %] [% IF Koha.Preference('UseRecalls') && RECALLS.count %] @@ -1393,4 +1393,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 7feec7e2fc..6eefa057a0 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 @@ -535,6 +535,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 17ee1a5139..9a5d59c5ce 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -191,6 +191,7 @@ foreach my $biblioNumber (@biblionumbers) { # # if ( $query->param('place_reserve') ) { + my $add_to_hold_group = $query->param('add_to_hold_group'); my $reserve_cnt = 0; if ($maxreserves) { $reserve_cnt = $patron->holds->count_holds; @@ -224,6 +225,7 @@ if ( $query->param('place_reserve') ) { } my $failed_holds = 0; + my $hold_group; while (@selectedItems) { my $biblioNum = shift(@selectedItems); my $itemNum = shift(@selectedItems); @@ -308,6 +310,12 @@ 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, @@ -321,6 +329,7 @@ if ( $query->param('place_reserve') ) { itemnumber => $itemNum, found => $found, itemtype => $itemtype, + hold_group_id => $hold_group ? $hold_group->id : undef, } ); $failed_holds++ unless $reserve_id; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index ba45ddd237..555f700d6a 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -330,6 +330,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