|
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 464-469
foreach my $biblioNum (@biblionumbers) {
Link Here
|
| 464 |
|
476 |
|
| 465 |
my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; |
477 |
my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list }; |
| 466 |
|
478 |
|
|
|
479 |
# For a librarian to be able to place multiple record holds for a patron for a record, |
| 480 |
# we must find out what the maximum number of holds they can place for the patron is |
| 481 |
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblioNum ); |
| 482 |
my $remaining_holds_for_record = $max_holds_for_record - $holds->count(); |
| 483 |
|
| 484 |
# Determine how many holds the patron can place per day on this biblio record. |
| 485 |
# Then calculate how many holds the patron can place subtracting holds already placed today |
| 486 |
my $today_holds = Koha::Holds->search({ |
| 487 |
borrowernumber => $patron->borrowernumber, |
| 488 |
reservedate => dt_from_string->date, |
| 489 |
})->count; |
| 490 |
|
| 491 |
my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron ); |
| 492 |
my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds; |
| 493 |
my $maxreserves = C4::Context->preference('maxreserves'); |
| 494 |
|
| 495 |
$biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record; |
| 496 |
$biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today; |
| 497 |
|
| 498 |
# Determine what is the lowest value |
| 499 |
my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today ); |
| 500 |
|
| 501 |
$template->param( |
| 502 |
max_holds_for_record => $max_holds_for_record, |
| 503 |
remaining_holds_for_record => $remaining_holds_for_record, |
| 504 |
lowest_value => $lowestvalue, |
| 505 |
remaining_holds_allowed_today => $remaining_holds_allowed_today, |
| 506 |
); |
| 507 |
|
| 467 |
# Only keep the items that are visible in the opac (i.e. those in %visible_items) |
508 |
# Only keep the items that are visible in the opac (i.e. those in %visible_items) |
| 468 |
# FIXME: We should get rid of itemInfos altogether and use $visible_items |
509 |
# FIXME: We should get rid of itemInfos altogether and use $visible_items |
| 469 |
$biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ]; |
510 |
$biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ]; |
| 470 |
- |
|
|