Bugzilla – Attachment 120640 Details for
Bug 15565
Place multiple item-level holds at once for the same record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15565: Place multiple holds on one record on OPAC
Bug-15565-Place-multiple-holds-on-one-record-on-OP.patch (text/plain), 7.25 KB, created by
Victor Grousset/tuxayo
on 2021-05-06 19:15:02 UTC
(
hide
)
Description:
Bug 15565: Place multiple holds on one record on OPAC
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2021-05-06 19:15:02 UTC
Size:
7.25 KB
patch
obsolete
>From e503dc9590ef7ef58ee26bef2bd9f53593014602 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 22 Feb 2021 18:08:37 +1300 >Subject: [PATCH] Bug 15565: Place multiple holds on one record on OPAC > >Test plan: See previous commit about the staff interface > >Sponsored-by: Catalyst IT > >Signed-off-by: David Cook <dcook@prosentient.com.au> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > .../bootstrap/en/modules/opac-reserve.tt | 21 ++++++++-- > opac/opac-reserve.pl | 41 +++++++++++++++++++ > 2 files changed, 59 insertions(+), 3 deletions(-) > >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 2cd468650d..4512db0337 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >@@ -339,6 +339,10 @@ > /> > </li> > [% END # / IF bibitemloo.itemholdable %] >+ >+ [% IF lowest_value %] >+ <li id="max_holds" style="display:none;" data-val="[% lowest_value | html %]"><strong>Maximum holds allowed:</strong> [% lowest_value | html %]</li> >+ [% END %] > </ul> > > [% IF bibitemloo.itemholdable %] >@@ -368,7 +372,7 @@ > <tr class="[% itemLoo.backgroundcolor | html %]"> > <td class="copynumber"> > [% IF ( itemLoo.available ) %] >- <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" /> >+ <input type="checkbox" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" /> > [% ELSE %] > <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]" > style="display:none;" /> >@@ -470,6 +474,8 @@ > <script> > // <![CDATA[ > var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection."); >+ var MSG_EXCEEDED_MAX_HOLDS = __("Patron reached the maximum number of holds."); >+ var max_holds = $("#max_holds"); > > // Clear the contents of an input field > $(".clearfield").on("click",function(e){ >@@ -479,8 +485,8 @@ > > // Select the first item available > function select_first_available(id){ >- var radios = $("input:radio[name='checkitem_" + id + "']"); >- $(radios).first().attr("checked", "checked"); >+ var checkboxes = $("input:checkbox[name='checkitem_" + id + "']"); >+ $(checkboxes).first().attr("checked", "checked"); > } > > $(document).ready(function() { >@@ -572,8 +578,10 @@ > // If the checkbox is checked AND we want a specific item, we display the items block > if ( $(checkbox).is(":checked") && select_specific ) { > $(newCopiesRowId).show(); >+ $("#max_holds").show(); > } else { > $(newCopiesRowId).hide(); >+ $("#max_holds").hide(); > } > }; > >@@ -703,6 +711,13 @@ > [% END %] > [% END %] > >+ $(".checkitem").change(function(e){ >+ if ( $(".checkitem:checked").length > max_holds.data('val') ) { >+ e.preventDefault(); >+ alert(MSG_EXCEEDED_MAX_HOLDS); >+ $(this).prop('checked',false); >+ } >+ }); > }); > // ]]> > </script> >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index a6182400ad..585ab9f61c 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -44,6 +44,7 @@ use Koha::Libraries; > use Koha::Patrons; > use Date::Calc qw/Today Date_to_Days/; > use List::MoreUtils qw/uniq/; >+use List::Util qw[min max]; > > my $maxreserves = C4::Context->preference("maxreserves"); > >@@ -214,6 +215,17 @@ if ( $query->param('place_reserve') ) { > $selectedItems = "$bib/$item/$branch/"; > } > >+ my @multi_bibs = $query->multi_param('single_bib'); >+ if ( $query->param('reserve_mode') eq 'multi' and @multi_bibs == 1 ) { >+ # multiple holds on same record >+ my $biblionumber = $query->param('single_bib'); >+ my @itemnumbers = $query->multi_param("checkitem_$biblionumber"); >+ my $branch = $query->param('branch'); >+ foreach my $itemnumber ( @itemnumbers ) { >+ $selectedItems .= "$biblionumber/$itemnumber/$branch/"; >+ } >+ } >+ > $selectedItems =~ s!/$!!; > my @selectedItems = split /\//, $selectedItems, -1; > >@@ -466,6 +478,35 @@ foreach my $biblioNum (@biblionumbers) { > > my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; > >+ # For a librarian to be able to place multiple record holds for a patron for a record, >+ # we must find out what the maximum number of holds they can place for the patron is >+ my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblioNum ); >+ my $remaining_holds_for_record = $max_holds_for_record - $holds->count(); >+ >+ # Determine how many holds the patron can place per day on this biblio record. >+ # Then calculate how many holds the patron can place subtracting holds already placed today >+ my $today_holds = Koha::Holds->search({ >+ borrowernumber => $patron->borrowernumber, >+ reservedate => dt_from_string->date, >+ })->count; >+ >+ my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron ); >+ my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds; >+ my $maxreserves = C4::Context->preference('maxreserves'); >+ >+ $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record; >+ $biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today; >+ >+ # Determine what is the lowest value >+ my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today ); >+ >+ $template->param( >+ max_holds_for_record => $max_holds_for_record, >+ remaining_holds_for_record => $remaining_holds_for_record, >+ lowest_value => $lowestvalue, >+ remaining_holds_allowed_today => $remaining_holds_allowed_today, >+ ); >+ > # Only keep the items that are visible in the opac (i.e. those in %visible_items) > # FIXME: We should get rid of itemInfos altogether and use $visible_items > $biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ]; >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15565
:
47527
|
47551
|
47552
|
50068
|
50069
|
50392
|
50393
|
56229
|
56230
|
56231
|
56232
|
56458
|
56510
|
56511
|
56512
|
56513
|
56514
|
56515
|
56517
|
56518
|
56519
|
56520
|
56521
|
56522
|
56523
|
56524
|
61244
|
61245
|
61246
|
61247
|
61248
|
61576
|
61577
|
61578
|
61579
|
61580
|
64590
|
64591
|
64592
|
64593
|
64594
|
66594
|
66595
|
66596
|
66597
|
66598
|
68759
|
68760
|
68761
|
68762
|
68763
|
71643
|
71644
|
71645
|
71646
|
71647
|
71648
|
72644
|
72645
|
72646
|
72647
|
72648
|
72649
|
78242
|
78243
|
78244
|
78245
|
78246
|
78247
|
78248
|
78266
|
78305
|
78417
|
78418
|
78419
|
78420
|
78421
|
78422
|
78423
|
78424
|
78425
|
78426
|
78712
|
78713
|
78714
|
78715
|
78716
|
78717
|
78718
|
78719
|
78720
|
78815
|
78816
|
78817
|
78818
|
78819
|
78820
|
78821
|
78822
|
78823
|
81419
|
81420
|
81421
|
81422
|
81423
|
81424
|
81425
|
81426
|
81427
|
81431
|
81449
|
81570
|
81571
|
81572
|
81573
|
81574
|
81575
|
81576
|
81577
|
81578
|
81579
|
81580
|
81581
|
82205
|
82206
|
82207
|
82208
|
82209
|
82210
|
82211
|
82212
|
82213
|
82214
|
82215
|
82216
|
82220
|
82221
|
83331
|
83332
|
83333
|
83334
|
83335
|
83336
|
83337
|
83338
|
83339
|
83340
|
83341
|
83342
|
83378
|
83380
|
83381
|
84541
|
84542
|
84543
|
84544
|
84545
|
84546
|
84547
|
84548
|
84549
|
84550
|
84551
|
84552
|
84553
|
87979
|
87980
|
87981
|
87982
|
87983
|
87984
|
87985
|
87986
|
87987
|
87988
|
87989
|
87990
|
87991
|
117128
|
117129
|
117130
|
117131
|
117132
|
117133
|
120365
|
120366
|
120367
|
120639
|
120640
|
120641
|
121941
|
122098
|
162071
|
162072
|
162073
|
162074
|
163052
|
163053
|
163054
|
163055
|
163092
|
163093
|
166005
|
166006
|
166007
|
166008
|
166009