+ [% END %]
[% IF bibitemloo.itemholdable %]
@@ -368,7 +372,7 @@
[% IF ( itemLoo.available ) %]
-
+
[% ELSE %]
@@ -470,6 +474,8 @@
--- a/opac/opac-reserve.pl
+++ a/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} } ];
--