@@ -, +, @@ --- C4/Reserves.pm | 1 + Koha/Biblio.pm | 32 ++++++++++++++ .../prog/en/modules/reserve/request.tt | 25 +++++++++-- koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss | 1 + .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 50 +++++++++++++++++++--- opac/opac-reserve.pl | 21 ++++++++- reserve/request.pl | 25 ++++++++++- t/db_dependent/Reserves/MultiplePerRecord.t | 19 +++++++- 8 files changed, 162 insertions(+), 12 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -4,6 +4,7 @@ package C4::Reserves; # 2006 SAN Ouest Provence # 2007-2010 BibLibre Paul POULAIN # 2011 Catalyst IT +# 2018 Catalyst IT # # This file is part of Koha. # --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -467,6 +467,38 @@ sub has_items_waiting_or_intransit { return 0; } +=head3 allowed_holds + +my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron_obj ); + +Calculates and returns the number of item-level holds a borrower is allowed to place on the record on a single day. + +=cut + +sub allowed_holds { + + my ( $self, $patron ) = @_; + + my $controlbranch = C4::Context->preference('ReservesControlBranch'); + + my $categorycode = $patron->categorycode; + my $branchcode; + $branchcode = $patron->branchcode if ( $controlbranch eq "PatronLibrary" ); + + my $holds_allowed = 0; + foreach my $item ( $self->items()->as_list() ) { + my $itemtype = $item->effective_itemtype(); + $branchcode = $item->homebranch if ( $controlbranch eq "ItemHomeLibrary" ); + + my $rule = C4::Reserves::GetHoldRule( $categorycode, $itemtype, $branchcode ); + my $holds_per_day = $rule ? $rule->{holds_per_day} : 0; + if ( $holds_per_day ) { + $holds_allowed = $holds_per_day if $holds_per_day > $holds_allowed; + } + } + return $holds_allowed; +} + =head3 type =cut --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -249,7 +249,7 @@ [% IF remaining_holds_for_record > 1 %]
[% IF ( bibitemloo.holdable ) %] @@ -302,8 +303,10 @@ [% END # / IF OpacHoldNotes %] + [% IF bibitemloo.itemholdable %] + [% END # / IF bibitemloo.itemholdable %] [% IF bibitemloo.remaining_holds_for_record > 1 %] @@ -325,7 +330,7 @@