Lines 44-49
use Koha::Libraries;
Link Here
|
44 |
use Koha::Patrons; |
44 |
use Koha::Patrons; |
45 |
use Date::Calc qw/Today Date_to_Days/; |
45 |
use Date::Calc qw/Today Date_to_Days/; |
46 |
use List::MoreUtils qw/uniq/; |
46 |
use List::MoreUtils qw/uniq/; |
|
|
47 |
use List::Util qw[min max]; |
47 |
|
48 |
|
48 |
my $maxreserves = C4::Context->preference("maxreserves"); |
49 |
my $maxreserves = C4::Context->preference("maxreserves"); |
49 |
|
50 |
|
Lines 214-219
if ( $query->param('place_reserve') ) {
Link Here
|
214 |
$selectedItems = "$bib/$item/$branch/"; |
215 |
$selectedItems = "$bib/$item/$branch/"; |
215 |
} |
216 |
} |
216 |
|
217 |
|
|
|
218 |
my @multi_bibs = $query->multi_param('single_bib'); |
219 |
if ( $query->param('reserve_mode') eq 'multi' and @multi_bibs == 1 ) { |
220 |
# multiple holds on same record |
221 |
my $biblionumber = $query->param('single_bib'); |
222 |
my @itemnumbers = $query->multi_param("checkitem_$biblionumber"); |
223 |
my $branch = $query->param('branch'); |
224 |
foreach my $itemnumber ( @itemnumbers ) { |
225 |
$selectedItems .= "$biblionumber/$itemnumber/$branch/"; |
226 |
} |
227 |
} |
228 |
|
217 |
$selectedItems =~ s!/$!!; |
229 |
$selectedItems =~ s!/$!!; |
218 |
my @selectedItems = split /\//, $selectedItems, -1; |
230 |
my @selectedItems = split /\//, $selectedItems, -1; |
219 |
|
231 |
|
Lines 466-471
foreach my $biblioNum (@biblionumbers) {
Link Here
|
466 |
|
478 |
|
467 |
my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; |
479 |
my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; |
468 |
|
480 |
|
|
|
481 |
# For a librarian to be able to place multiple record holds for a patron for a record, |
482 |
# we must find out what the maximum number of holds they can place for the patron is |
483 |
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblioNum ); |
484 |
my $remaining_holds_for_record = $max_holds_for_record - $holds->count(); |
485 |
|
486 |
# Determine how many holds the patron can place per day on this biblio record. |
487 |
# Then calculate how many holds the patron can place subtracting holds already placed today |
488 |
my $today_holds = Koha::Holds->search({ |
489 |
borrowernumber => $patron->borrowernumber, |
490 |
reservedate => dt_from_string->date, |
491 |
})->count; |
492 |
|
493 |
my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron ); |
494 |
my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds; |
495 |
my $maxreserves = C4::Context->preference('maxreserves'); |
496 |
|
497 |
$biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record; |
498 |
$biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today; |
499 |
|
500 |
# Determine what is the lowest value |
501 |
my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today ); |
502 |
|
503 |
$template->param( |
504 |
max_holds_for_record => $max_holds_for_record, |
505 |
remaining_holds_for_record => $remaining_holds_for_record, |
506 |
lowest_value => $lowestvalue, |
507 |
remaining_holds_allowed_today => $remaining_holds_allowed_today, |
508 |
); |
509 |
|
469 |
# Only keep the items that are visible in the opac (i.e. those in %visible_items) |
510 |
# Only keep the items that are visible in the opac (i.e. those in %visible_items) |
470 |
# FIXME: We should get rid of itemInfos altogether and use $visible_items |
511 |
# FIXME: We should get rid of itemInfos altogether and use $visible_items |
471 |
$biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ]; |
512 |
$biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ]; |
472 |
- |
|
|