|
Lines 313-318
if ($patron) {
Link Here
|
| 313 |
my $itemdata_enumchron = 0; |
313 |
my $itemdata_enumchron = 0; |
| 314 |
my $itemdata_ccode = 0; |
314 |
my $itemdata_ccode = 0; |
| 315 |
my @biblioloop = (); |
315 |
my @biblioloop = (); |
|
|
316 |
my $reserveloop = 0; |
| 316 |
my $no_reserves_allowed = 0; |
317 |
my $no_reserves_allowed = 0; |
| 317 |
foreach my $biblionumber (@biblionumbers) { |
318 |
foreach my $biblionumber (@biblionumbers) { |
| 318 |
next unless $biblionumber =~ m|^\d+$|; |
319 |
next unless $biblionumber =~ m|^\d+$|; |
|
Lines 326-389
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 326 |
last; |
327 |
last; |
| 327 |
} |
328 |
} |
| 328 |
|
329 |
|
| 329 |
my $force_hold_level; |
|
|
| 330 |
if ( $patron ) { |
| 331 |
{ # CanBookBeReserved |
| 332 |
my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber ); |
| 333 |
if ( $canReserve->{status} eq 'OK' ) { |
| 334 |
|
| 335 |
#All is OK and we can continue |
| 336 |
} |
| 337 |
elsif ( $canReserve->{status} eq 'noReservesAllowed' || $canReserve->{status} eq 'notReservable' ) { |
| 338 |
$no_reserves_allowed = 1; |
| 339 |
} |
| 340 |
elsif ( $canReserve->{status} eq 'tooManyReserves' ) { |
| 341 |
$exceeded_maxreserves = 1; |
| 342 |
$template->param( maxreserves => $canReserve->{limit} ); |
| 343 |
} |
| 344 |
elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) { |
| 345 |
$exceeded_holds_per_record = 1; |
| 346 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 347 |
} |
| 348 |
elsif ( $canReserve->{status} eq 'ageRestricted' ) { |
| 349 |
$template->param( $canReserve->{status} => 1 ); |
| 350 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 351 |
} |
| 352 |
elsif ( $canReserve->{status} eq 'alreadypossession' ) { |
| 353 |
$template->param( $canReserve->{status} => 1); |
| 354 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 355 |
} |
| 356 |
else { |
| 357 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
# For multiple holds per record, if a patron has previously placed a hold, |
| 362 |
# the patron can only place more holds of the same type. That is, if the |
| 363 |
# patron placed a record level hold, all the holds the patron places must |
| 364 |
# be record level. If the patron placed an item level hold, all holds |
| 365 |
# the patron places must be item level |
| 366 |
my $holds = Koha::Holds->search( |
| 367 |
{ |
| 368 |
borrowernumber => $patron->borrowernumber, |
| 369 |
biblionumber => $biblionumber, |
| 370 |
found => undef, |
| 371 |
} |
| 372 |
); |
| 373 |
$force_hold_level = $holds->forced_hold_level(); |
| 374 |
$biblioloopiter{force_hold_level} = $force_hold_level; |
| 375 |
$template->param( force_hold_level => $force_hold_level ); |
| 376 |
|
| 377 |
# For a librarian to be able to place multiple record holds for a patron for a record, |
| 378 |
# we must find out what the maximum number of holds they can place for the patron is |
| 379 |
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber ); |
| 380 |
my $remaining_holds_for_record = $max_holds_for_record - $holds->count(); |
| 381 |
$biblioloopiter{remaining_holds_for_record} = $max_holds_for_record; |
| 382 |
$template->param( max_holds_for_record => $max_holds_for_record ); |
| 383 |
$template->param( remaining_holds_for_record => $remaining_holds_for_record ); |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count(); |
330 |
my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count(); |
| 388 |
my $totalcount = $count; |
331 |
my $totalcount = $count; |
| 389 |
|
332 |
|
|
Lines 407-412
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 407 |
$biblioloopiter{noitems} = 1; |
350 |
$biblioloopiter{noitems} = 1; |
| 408 |
} |
351 |
} |
| 409 |
|
352 |
|
|
|
353 |
$biblioloopiter{biblionumber} = $biblionumber; |
| 354 |
$biblioloopiter{title} = $biblio->title; |
| 355 |
$biblioloopiter{rank} = $fixedRank; |
| 356 |
|
| 357 |
# get the time for the form name... |
| 358 |
my $time = time(); |
| 359 |
|
| 360 |
$template->param( |
| 361 |
time => $time, |
| 362 |
fixedRank => $fixedRank, |
| 363 |
); |
| 364 |
|
| 365 |
unless( $patron ){ |
| 366 |
|
| 367 |
# existingreserves building |
| 368 |
my @reserveloop; |
| 369 |
my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); |
| 370 |
foreach my $res ( |
| 371 |
sort { |
| 372 |
my $a_found = $a->found() || ''; |
| 373 |
my $b_found = $a->found() || ''; |
| 374 |
$a_found cmp $b_found; |
| 375 |
} @reserves |
| 376 |
) |
| 377 |
{ |
| 378 |
my %reserve; |
| 379 |
if ( $res->is_found() ) { |
| 380 |
$reserve{'holdingbranch'} = $res->item()->holdingbranch(); |
| 381 |
$reserve{'biblionumber'} = $res->item()->biblionumber(); |
| 382 |
$reserve{'barcodenumber'} = $res->item()->barcode(); |
| 383 |
$reserve{'wbrcode'} = $res->branchcode(); |
| 384 |
$reserve{'itemnumber'} = $res->itemnumber(); |
| 385 |
$reserve{'wbrname'} = $res->branch()->branchname(); |
| 386 |
$reserve{'atdestination'} = $res->is_at_destination(); |
| 387 |
$reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ; |
| 388 |
$reserve{'found'} = $res->is_found(); |
| 389 |
$reserve{'inprocessing'} = $res->is_in_processing(); |
| 390 |
$reserve{'intransit'} = $res->is_in_transit(); |
| 391 |
} |
| 392 |
elsif ( $res->priority() > 0 ) { |
| 393 |
if ( my $item = $res->item() ) { |
| 394 |
$reserve{'itemnumber'} = $item->id(); |
| 395 |
$reserve{'barcodenumber'} = $item->barcode(); |
| 396 |
$reserve{'item_level_hold'} = 1; |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
$reserve{'expirationdate'} = $res->expirationdate; |
| 401 |
$reserve{'date'} = $res->reservedate; |
| 402 |
$reserve{'borrowernumber'} = $res->borrowernumber(); |
| 403 |
$reserve{'biblionumber'} = $res->biblionumber(); |
| 404 |
$reserve{'patron'} = $res->borrower; |
| 405 |
$reserve{'notes'} = $res->reservenotes(); |
| 406 |
$reserve{'waiting_date'} = $res->waitingdate(); |
| 407 |
$reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; |
| 408 |
$reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; |
| 409 |
$reserve{'priority'} = $res->priority(); |
| 410 |
$reserve{'lowestPriority'} = $res->lowestPriority(); |
| 411 |
$reserve{'suspend'} = $res->suspend(); |
| 412 |
$reserve{'suspend_until'} = $res->suspend_until(); |
| 413 |
$reserve{'reserve_id'} = $res->reserve_id(); |
| 414 |
$reserve{itemtype} = $res->itemtype(); |
| 415 |
$reserve{branchcode} = $res->branchcode(); |
| 416 |
$reserve{non_priority} = $res->non_priority(); |
| 417 |
$reserve{object} = $res; |
| 418 |
|
| 419 |
push( @reserveloop, \%reserve ); |
| 420 |
} |
| 421 |
|
| 422 |
$biblioloopiter{reserveloop} = \@reserveloop; |
| 423 |
$reserveloop = 1 if (@reserveloop); |
| 424 |
|
| 425 |
push @biblioloop, \%biblioloopiter; |
| 426 |
next; |
| 427 |
} |
| 428 |
|
| 429 |
my $force_hold_level; |
| 430 |
my $items_any_available; |
| 431 |
|
| 432 |
{ # CanBookBeReserved |
| 433 |
my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber ); |
| 434 |
if ( $canReserve->{status} eq 'OK' ) { |
| 435 |
|
| 436 |
#All is OK and we can continue |
| 437 |
} |
| 438 |
elsif ( $canReserve->{status} eq 'noReservesAllowed' || $canReserve->{status} eq 'notReservable' ) { |
| 439 |
$no_reserves_allowed = 1; |
| 440 |
} |
| 441 |
elsif ( $canReserve->{status} eq 'tooManyReserves' ) { |
| 442 |
$exceeded_maxreserves = 1; |
| 443 |
$template->param( maxreserves => $canReserve->{limit} ); |
| 444 |
} |
| 445 |
elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) { |
| 446 |
$exceeded_holds_per_record = 1; |
| 447 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 448 |
} |
| 449 |
elsif ( $canReserve->{status} eq 'ageRestricted' ) { |
| 450 |
$template->param( $canReserve->{status} => 1 ); |
| 451 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 452 |
} |
| 453 |
elsif ( $canReserve->{status} eq 'alreadypossession' ) { |
| 454 |
$template->param( $canReserve->{status} => 1); |
| 455 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 456 |
} |
| 457 |
else { |
| 458 |
$biblioloopiter{ $canReserve->{status} } = 1; |
| 459 |
} |
| 460 |
} |
| 461 |
|
| 462 |
# Add the valid pickup locations |
| 463 |
my @pickup_locations = $biblio->pickup_locations({ patron => $patron }); |
| 464 |
$biblioloopiter{pickup_locations} = \@pickup_locations; |
| 465 |
$biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ]; |
| 466 |
|
| 467 |
# For multiple holds per record, if a patron has previously placed a hold, |
| 468 |
# the patron can only place more holds of the same type. That is, if the |
| 469 |
# patron placed a record level hold, all the holds the patron places must |
| 470 |
# be record level. If the patron placed an item level hold, all holds |
| 471 |
# the patron places must be item level |
| 472 |
my $holds = Koha::Holds->search( |
| 473 |
{ |
| 474 |
borrowernumber => $patron->borrowernumber, |
| 475 |
biblionumber => $biblionumber, |
| 476 |
found => undef, |
| 477 |
} |
| 478 |
); |
| 479 |
$force_hold_level = $holds->forced_hold_level(); |
| 480 |
$biblioloopiter{force_hold_level} = $force_hold_level; |
| 481 |
$template->param( force_hold_level => $force_hold_level ); |
| 482 |
|
| 483 |
# For a librarian to be able to place multiple record holds for a patron for a record, |
| 484 |
# we must find out what the maximum number of holds they can place for the patron is |
| 485 |
my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber ); |
| 486 |
my $remaining_holds_for_record = $max_holds_for_record - $holds->count(); |
| 487 |
$biblioloopiter{remaining_holds_for_record} = $max_holds_for_record; |
| 488 |
$template->param( max_holds_for_record => $max_holds_for_record ); |
| 489 |
$template->param( remaining_holds_for_record => $remaining_holds_for_record ); |
| 490 |
|
| 491 |
my @bibitemloop; |
| 492 |
|
| 410 |
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers |
493 |
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers |
| 411 |
## this is important when we have analytic items which may be on another record |
494 |
## this is important when we have analytic items which may be on another record |
| 412 |
my ( $iteminfos_of ); |
495 |
my ( $iteminfos_of ); |
|
Lines 431-437
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 431 |
} |
514 |
} |
| 432 |
}; |
515 |
}; |
| 433 |
|
516 |
|
| 434 |
my @bibitemloop; |
517 |
|
| 435 |
|
518 |
|
| 436 |
my @available_itemtypes; |
519 |
my @available_itemtypes; |
| 437 |
foreach my $biblioitemnumber (@biblioitemnumbers) { |
520 |
foreach my $biblioitemnumber (@biblioitemnumbers) { |
|
Lines 463-471
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 463 |
# to pass this value further inside down to IsAvailableForItemLevelRequest to |
546 |
# to pass this value further inside down to IsAvailableForItemLevelRequest to |
| 464 |
# it's complicated logic to analyse. |
547 |
# it's complicated logic to analyse. |
| 465 |
# (before this loop was inside that sub loop so it was O(n^2) ) |
548 |
# (before this loop was inside that sub loop so it was O(n^2) ) |
| 466 |
my $items_any_available; |
549 |
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron }); |
| 467 |
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron }) |
|
|
| 468 |
if $patron; |
| 469 |
|
550 |
|
| 470 |
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) { |
551 |
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) { |
| 471 |
my $item = $iteminfos_of->{$itemnumber}; |
552 |
my $item = $iteminfos_of->{$itemnumber}; |
|
Lines 563-596
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 563 |
} |
644 |
} |
| 564 |
} |
645 |
} |
| 565 |
|
646 |
|
| 566 |
if ( $patron ) { |
647 |
my $patron_unblessed = $patron->unblessed; |
| 567 |
my $patron_unblessed = $patron->unblessed; |
648 |
my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); |
| 568 |
my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); |
649 |
|
|
|
650 |
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); |
| 569 |
|
651 |
|
| 570 |
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); |
652 |
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; |
| 571 |
|
653 |
|
| 572 |
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; |
654 |
my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status}; |
|
|
655 |
$item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); |
| 573 |
|
656 |
|
| 574 |
my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status}; |
657 |
$item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } ); |
| 575 |
$item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); |
|
|
| 576 |
|
658 |
|
| 577 |
$item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } ); |
659 |
if ( |
|
|
660 |
!$item->{cantreserve} |
| 661 |
&& !$exceeded_maxreserves |
| 662 |
&& $can_item_be_reserved eq 'OK' |
| 663 |
# items_any_available defined outside of the current loop, |
| 664 |
# so we avoiding loop inside IsAvailableForItemLevelRequest: |
| 665 |
&& IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available) |
| 666 |
) |
| 667 |
{ |
| 668 |
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API |
| 669 |
my $pickup_locations = $item_object->pickup_locations({ patron => $patron }); |
| 670 |
$item->{pickup_locations_count} = $pickup_locations->count; |
| 671 |
if ( $item->{pickup_locations_count} > 0 ) { |
| 672 |
$num_available++; |
| 673 |
$item->{available} = 1; |
| 674 |
# pass the holding branch for use as default |
| 675 |
my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next; |
| 676 |
$item->{default_pickup_location} = $default_pickup_location; |
| 677 |
} |
| 678 |
else { |
| 679 |
$item->{available} = 0; |
| 680 |
$item->{not_holdable} = "no_valid_pickup_location"; |
| 681 |
} |
| 578 |
|
682 |
|
| 579 |
if ( |
683 |
push( @available_itemtypes, $item->{itype} ); |
| 580 |
!$item->{cantreserve} |
684 |
} |
| 581 |
&& !$exceeded_maxreserves |
685 |
elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { |
| 582 |
&& $can_item_be_reserved eq 'OK' |
686 |
# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules |
| 583 |
# items_any_available defined outside of the current loop, |
687 |
# with the exception of itemAlreadyOnHold because, you know, the item is already on hold |
| 584 |
# so we avoiding loop inside IsAvailableForItemLevelRequest: |
688 |
if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) { |
| 585 |
&& IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available) |
|
|
| 586 |
) |
| 587 |
{ |
| 588 |
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API |
689 |
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API |
| 589 |
my $pickup_locations = $item_object->pickup_locations({ patron => $patron }); |
690 |
my $pickup_locations = $item_object->pickup_locations({ patron => $patron }); |
| 590 |
$item->{pickup_locations_count} = $pickup_locations->count; |
691 |
$item->{pickup_locations_count} = $pickup_locations->count; |
| 591 |
if ( $item->{pickup_locations_count} > 0 ) { |
692 |
if ( $item->{pickup_locations_count} > 0 ) { |
| 592 |
$num_available++; |
693 |
$item->{override} = 1; |
| 593 |
$item->{available} = 1; |
694 |
$num_override++; |
| 594 |
# pass the holding branch for use as default |
695 |
# pass the holding branch for use as default |
| 595 |
my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next; |
696 |
my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next; |
| 596 |
$item->{default_pickup_location} = $default_pickup_location; |
697 |
$item->{default_pickup_location} = $default_pickup_location; |
|
Lines 599-646
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 599 |
$item->{available} = 0; |
700 |
$item->{available} = 0; |
| 600 |
$item->{not_holdable} = "no_valid_pickup_location"; |
701 |
$item->{not_holdable} = "no_valid_pickup_location"; |
| 601 |
} |
702 |
} |
|
|
703 |
} else { $num_alreadyheld++ } |
| 602 |
|
704 |
|
| 603 |
push( @available_itemtypes, $item->{itype} ); |
705 |
push( @available_itemtypes, $item->{itype} ); |
| 604 |
} |
706 |
} |
| 605 |
elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { |
|
|
| 606 |
# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules |
| 607 |
# with the exception of itemAlreadyOnHold because, you know, the item is already on hold |
| 608 |
if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) { |
| 609 |
# Send the pickup locations count to the UI, the pickup locations will be pulled using the API |
| 610 |
my $pickup_locations = $item_object->pickup_locations({ patron => $patron }); |
| 611 |
$item->{pickup_locations_count} = $pickup_locations->count; |
| 612 |
if ( $item->{pickup_locations_count} > 0 ) { |
| 613 |
$item->{override} = 1; |
| 614 |
$num_override++; |
| 615 |
# pass the holding branch for use as default |
| 616 |
my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next; |
| 617 |
$item->{default_pickup_location} = $default_pickup_location; |
| 618 |
} |
| 619 |
else { |
| 620 |
$item->{available} = 0; |
| 621 |
$item->{not_holdable} = "no_valid_pickup_location"; |
| 622 |
} |
| 623 |
} else { $num_alreadyheld++ } |
| 624 |
|
| 625 |
push( @available_itemtypes, $item->{itype} ); |
| 626 |
} |
| 627 |
|
707 |
|
| 628 |
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked |
708 |
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked |
| 629 |
|
709 |
|
| 630 |
# Show serial enumeration when needed |
710 |
# Show serial enumeration when needed |
| 631 |
if ($item->{enumchron}) { |
711 |
if ($item->{enumchron}) { |
| 632 |
$itemdata_enumchron = 1; |
712 |
$itemdata_enumchron = 1; |
| 633 |
} |
713 |
} |
| 634 |
# Show collection when needed |
714 |
# Show collection when needed |
| 635 |
if ($item->{ccode}) { |
715 |
if ($item->{ccode}) { |
| 636 |
$itemdata_ccode = 1; |
716 |
$itemdata_ccode = 1; |
| 637 |
} |
|
|
| 638 |
} |
717 |
} |
| 639 |
|
718 |
|
| 640 |
push @{ $biblioitem->{itemloop} }, $item; |
719 |
push @{ $biblioitem->{itemloop} }, $item; |
| 641 |
} |
720 |
} |
| 642 |
|
721 |
|
| 643 |
# While we can't override an alreay held item, we should be able to override the others |
722 |
# While we can't override an already held item, we should be able to override the others |
| 644 |
# Unless all items are already held |
723 |
# Unless all items are already held |
| 645 |
if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioitem->{itemloop} } ) ) { |
724 |
if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioitem->{itemloop} } ) ) { |
| 646 |
# That is, if all items require an override |
725 |
# That is, if all items require an override |
|
Lines 657-758
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 657 |
|
736 |
|
| 658 |
@available_itemtypes = uniq( @available_itemtypes ); |
737 |
@available_itemtypes = uniq( @available_itemtypes ); |
| 659 |
$template->param( available_itemtypes => \@available_itemtypes ); |
738 |
$template->param( available_itemtypes => \@available_itemtypes ); |
|
|
739 |
$template->param(bibitemloop => \@bibitemloop); |
| 660 |
|
740 |
|
| 661 |
# existingreserves building |
|
|
| 662 |
my @reserveloop; |
| 663 |
my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); |
| 664 |
foreach my $res ( |
| 665 |
sort { |
| 666 |
my $a_found = $a->found() || ''; |
| 667 |
my $b_found = $a->found() || ''; |
| 668 |
$a_found cmp $b_found; |
| 669 |
} @reserves |
| 670 |
) |
| 671 |
{ |
| 672 |
my %reserve; |
| 673 |
if ( $res->is_found() ) { |
| 674 |
$reserve{'holdingbranch'} = $res->item()->holdingbranch(); |
| 675 |
$reserve{'biblionumber'} = $res->item()->biblionumber(); |
| 676 |
$reserve{'barcodenumber'} = $res->item()->barcode(); |
| 677 |
$reserve{'wbrcode'} = $res->branchcode(); |
| 678 |
$reserve{'itemnumber'} = $res->itemnumber(); |
| 679 |
$reserve{'wbrname'} = $res->branch()->branchname(); |
| 680 |
$reserve{'atdestination'} = $res->is_at_destination(); |
| 681 |
$reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ; |
| 682 |
$reserve{'found'} = $res->is_found(); |
| 683 |
$reserve{'inprocessing'} = $res->is_in_processing(); |
| 684 |
$reserve{'intransit'} = $res->is_in_transit(); |
| 685 |
} |
| 686 |
elsif ( $res->priority() > 0 ) { |
| 687 |
if ( my $item = $res->item() ) { |
| 688 |
$reserve{'itemnumber'} = $item->id(); |
| 689 |
$reserve{'barcodenumber'} = $item->barcode(); |
| 690 |
$reserve{'item_level_hold'} = 1; |
| 691 |
} |
| 692 |
} |
| 693 |
|
| 694 |
$reserve{'expirationdate'} = $res->expirationdate; |
| 695 |
$reserve{'date'} = $res->reservedate; |
| 696 |
$reserve{'borrowernumber'} = $res->borrowernumber(); |
| 697 |
$reserve{'biblionumber'} = $res->biblionumber(); |
| 698 |
$reserve{'patron'} = $res->borrower; |
| 699 |
$reserve{'notes'} = $res->reservenotes(); |
| 700 |
$reserve{'waiting_date'} = $res->waitingdate(); |
| 701 |
$reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; |
| 702 |
$reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; |
| 703 |
$reserve{'priority'} = $res->priority(); |
| 704 |
$reserve{'lowestPriority'} = $res->lowestPriority(); |
| 705 |
$reserve{'suspend'} = $res->suspend(); |
| 706 |
$reserve{'suspend_until'} = $res->suspend_until(); |
| 707 |
$reserve{'reserve_id'} = $res->reserve_id(); |
| 708 |
$reserve{itemtype} = $res->itemtype(); |
| 709 |
$reserve{branchcode} = $res->branchcode(); |
| 710 |
$reserve{non_priority} = $res->non_priority(); |
| 711 |
$reserve{object} = $res; |
| 712 |
|
| 713 |
push( @reserveloop, \%reserve ); |
| 714 |
} |
| 715 |
|
| 716 |
# get the time for the form name... |
| 717 |
my $time = time(); |
| 718 |
|
| 719 |
$template->param( |
| 720 |
time => $time, |
| 721 |
fixedRank => $fixedRank, |
| 722 |
); |
| 723 |
|
| 724 |
# display infos |
| 725 |
$template->param( |
| 726 |
bibitemloop => \@bibitemloop, |
| 727 |
itemdata_enumchron => $itemdata_enumchron, |
| 728 |
itemdata_ccode => $itemdata_ccode, |
| 729 |
date => $date, |
| 730 |
biblionumber => $biblionumber, |
| 731 |
findborrower => $findborrower, |
| 732 |
biblio => $biblio, |
| 733 |
holdsview => 1, |
| 734 |
C4::Search::enabled_staff_search_views, |
| 735 |
); |
| 736 |
|
| 737 |
$biblioloopiter{biblionumber} = $biblionumber; |
| 738 |
$biblioloopiter{title} = $biblio->title; |
| 739 |
$biblioloopiter{rank} = $fixedRank; |
| 740 |
$biblioloopiter{reserveloop} = \@reserveloop; |
| 741 |
|
| 742 |
if (@reserveloop) { |
| 743 |
$template->param( reserveloop => \@reserveloop ); |
| 744 |
} |
| 745 |
|
| 746 |
if ( $patron ) { |
| 747 |
# Add the valid pickup locations |
| 748 |
my @pickup_locations = $biblio->pickup_locations({ patron => $patron }); |
| 749 |
$biblioloopiter{pickup_locations} = \@pickup_locations; |
| 750 |
$biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ]; |
| 751 |
} |
| 752 |
|
741 |
|
| 753 |
push @biblioloop, \%biblioloopiter; |
742 |
push @biblioloop, \%biblioloopiter; |
| 754 |
} |
743 |
} |
| 755 |
|
744 |
|
|
|
745 |
# display infos |
| 746 |
$template->param( |
| 747 |
reserveloop => 1, |
| 748 |
itemdata_enumchron => $itemdata_enumchron, |
| 749 |
itemdata_ccode => $itemdata_ccode, |
| 750 |
date => $date, |
| 751 |
biblionumber => $biblionumber, |
| 752 |
findborrower => $findborrower, |
| 753 |
holdsview => 1, |
| 754 |
C4::Search::enabled_staff_search_views, |
| 755 |
); |
| 756 |
|
| 756 |
$template->param( biblioloop => \@biblioloop ); |
757 |
$template->param( biblioloop => \@biblioloop ); |
| 757 |
$template->param( no_reserves_allowed => $no_reserves_allowed ); |
758 |
$template->param( no_reserves_allowed => $no_reserves_allowed ); |
| 758 |
$template->param( biblionumbers => join('/', @biblionumbers) ); |
759 |
$template->param( biblionumbers => join('/', @biblionumbers) ); |
| 759 |
- |
|
|