|
Lines 464-569
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 464 |
# it's complicated logic to analyse. |
464 |
# it's complicated logic to analyse. |
| 465 |
# (before this loop was inside that sub loop so it was O(n^2) ) |
465 |
# (before this loop was inside that sub loop so it was O(n^2) ) |
| 466 |
my $items_any_available; |
466 |
my $items_any_available; |
| 467 |
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron }) |
467 |
if ( $patron ) { |
| 468 |
if $patron; |
468 |
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron }); |
| 469 |
|
469 |
|
| 470 |
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) { |
470 |
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) { |
| 471 |
my $item = $iteminfos_of->{$itemnumber}; |
471 |
my $item = $iteminfos_of->{$itemnumber}; |
| 472 |
my $do_check; |
472 |
my $do_check; |
| 473 |
if ( $patron ) { |
473 |
if ( $patron ) { |
| 474 |
$do_check = $patron->do_check_for_previous_checkout($item) if $wants_check; |
474 |
$do_check = $patron->do_check_for_previous_checkout($item) if $wants_check; |
| 475 |
if ( $do_check && $wants_check ) { |
475 |
if ( $do_check && $wants_check ) { |
| 476 |
$item->{checked_previously} = $do_check; |
476 |
$item->{checked_previously} = $do_check; |
| 477 |
if ( $multi_hold ) { |
477 |
if ( $multi_hold ) { |
| 478 |
$biblioloopiter{checked_previously} = $do_check; |
478 |
$biblioloopiter{checked_previously} = $do_check; |
| 479 |
} else { |
479 |
} else { |
| 480 |
$template->param( checked_previously => $do_check ); |
480 |
$template->param( checked_previously => $do_check ); |
|
|
481 |
} |
| 481 |
} |
482 |
} |
| 482 |
} |
483 |
} |
| 483 |
} |
484 |
$item->{force_hold_level} = $force_hold_level; |
| 484 |
$item->{force_hold_level} = $force_hold_level; |
|
|
| 485 |
|
485 |
|
| 486 |
unless (C4::Context->preference('item-level_itypes')) { |
486 |
unless (C4::Context->preference('item-level_itypes')) { |
| 487 |
$item->{itype} = $biblioitem->{itemtype}; |
487 |
$item->{itype} = $biblioitem->{itemtype}; |
| 488 |
} |
488 |
} |
| 489 |
|
489 |
|
| 490 |
$item->{itypename} = $itemtypes->{ $item->{itype} }{description}; |
490 |
$item->{itypename} = $itemtypes->{ $item->{itype} }{description}; |
| 491 |
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} ); |
491 |
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} ); |
| 492 |
$item->{homebranch} = $item->{homebranch}; |
492 |
$item->{homebranch} = $item->{homebranch}; |
| 493 |
|
493 |
|
| 494 |
# if the holdingbranch is different than the homebranch, we show the |
494 |
# if the holdingbranch is different than the homebranch, we show the |
| 495 |
# holdingbranch of the document too |
495 |
# holdingbranch of the document too |
| 496 |
if ( $item->{homebranch} ne $item->{holdingbranch} ) { |
496 |
if ( $item->{homebranch} ne $item->{holdingbranch} ) { |
| 497 |
$item->{holdingbranch} = $item->{holdingbranch}; |
497 |
$item->{holdingbranch} = $item->{holdingbranch}; |
| 498 |
} |
498 |
} |
| 499 |
|
499 |
|
| 500 |
if($item->{biblionumber} ne $biblionumber){ |
500 |
if($item->{biblionumber} ne $biblionumber){ |
| 501 |
$item->{hostitemsflag} = 1; |
501 |
$item->{hostitemsflag} = 1; |
| 502 |
$item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title; |
502 |
$item->{hosttitle} = Koha::Biblios->find( $item->{biblionumber} )->title; |
| 503 |
} |
503 |
} |
| 504 |
|
504 |
|
| 505 |
# if the item is currently on loan, we display its return date and |
505 |
# if the item is currently on loan, we display its return date and |
| 506 |
# change the background color |
506 |
# change the background color |
| 507 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
507 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); |
| 508 |
if ( $issue ) { |
508 |
if ( $issue ) { |
| 509 |
$item->{date_due} = $issue->date_due; |
509 |
$item->{date_due} = $issue->date_due; |
| 510 |
$item->{backgroundcolor} = 'onloan'; |
510 |
$item->{backgroundcolor} = 'onloan'; |
| 511 |
} |
511 |
} |
| 512 |
|
512 |
|
| 513 |
# checking reserve |
513 |
# checking reserve |
| 514 |
my $item_object = Koha::Items->find( $itemnumber ); |
514 |
my $item_object = Koha::Items->find( $itemnumber ); |
| 515 |
my $holds = $item_object->current_holds; |
515 |
my $holds = $item_object->current_holds; |
| 516 |
if ( my $first_hold = $holds->next ) { |
516 |
if ( my $first_hold = $holds->next ) { |
| 517 |
my $p = Koha::Patrons->find( $first_hold->borrowernumber ); |
517 |
my $p = Koha::Patrons->find( $first_hold->borrowernumber ); |
| 518 |
|
518 |
|
| 519 |
$item->{backgroundcolor} = 'reserved'; |
519 |
$item->{backgroundcolor} = 'reserved'; |
| 520 |
$item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template |
520 |
$item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template |
| 521 |
$item->{ReservedFor} = $p; |
521 |
$item->{ReservedFor} = $p; |
| 522 |
$item->{ExpectedAtLibrary} = $first_hold->branchcode; |
522 |
$item->{ExpectedAtLibrary} = $first_hold->branchcode; |
| 523 |
$item->{waitingdate} = $first_hold->waitingdate; |
523 |
$item->{waitingdate} = $first_hold->waitingdate; |
| 524 |
} |
524 |
} |
| 525 |
|
525 |
|
| 526 |
# Management of the notforloan document |
526 |
# Management of the notforloan document |
| 527 |
if ( $item->{notforloan} ) { |
527 |
if ( $item->{notforloan} ) { |
| 528 |
$item->{backgroundcolor} = 'other'; |
528 |
$item->{backgroundcolor} = 'other'; |
| 529 |
} |
529 |
} |
| 530 |
|
530 |
|
| 531 |
# Management of lost or long overdue items |
531 |
# Management of lost or long overdue items |
| 532 |
if ( $item->{itemlost} ) { |
532 |
if ( $item->{itemlost} ) { |
| 533 |
$item->{backgroundcolor} = 'other'; |
533 |
$item->{backgroundcolor} = 'other'; |
| 534 |
if ($logged_in_patron->category->hidelostitems && !$showallitems) { |
534 |
if ($logged_in_patron->category->hidelostitems && !$showallitems) { |
| 535 |
$item->{hide} = 1; |
535 |
$item->{hide} = 1; |
| 536 |
$hiddencount++; |
536 |
$hiddencount++; |
|
|
537 |
} |
| 537 |
} |
538 |
} |
| 538 |
} |
|
|
| 539 |
|
539 |
|
| 540 |
# Check the transit status |
540 |
# Check the transit status |
| 541 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
541 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
| 542 |
GetTransfers($itemnumber); |
542 |
GetTransfers($itemnumber); |
| 543 |
|
543 |
|
| 544 |
if ( defined $transfertwhen && $transfertwhen ne '' ) { |
544 |
if ( defined $transfertwhen && $transfertwhen ne '' ) { |
| 545 |
$item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 }); |
545 |
$item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 }); |
| 546 |
$item->{transfertfrom} = $transfertfrom; |
546 |
$item->{transfertfrom} = $transfertfrom; |
| 547 |
$item->{transfertto} = $transfertto; |
547 |
$item->{transfertto} = $transfertto; |
| 548 |
$item->{nocancel} = 1; |
548 |
$item->{nocancel} = 1; |
| 549 |
} |
549 |
} |
| 550 |
|
550 |
|
| 551 |
# If there is no loan, return and transfer, we show a checkbox. |
551 |
# If there is no loan, return and transfer, we show a checkbox. |
| 552 |
$item->{notforloan} ||= 0; |
552 |
$item->{notforloan} ||= 0; |
| 553 |
|
553 |
|
| 554 |
# if independent branches is on we need to check if the person can reserve |
554 |
# if independent branches is on we need to check if the person can reserve |
| 555 |
# for branches they arent logged in to |
555 |
# for branches they arent logged in to |
| 556 |
if ( C4::Context->preference("IndependentBranches") ) { |
556 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 557 |
if (! C4::Context->preference("canreservefromotherbranches")){ |
557 |
if (! C4::Context->preference("canreservefromotherbranches")){ |
| 558 |
# can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve |
558 |
# can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve |
| 559 |
my $userenv = C4::Context->userenv; |
559 |
my $userenv = C4::Context->userenv; |
| 560 |
unless ( C4::Context->IsSuperLibrarian ) { |
560 |
unless ( C4::Context->IsSuperLibrarian ) { |
| 561 |
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} ); |
561 |
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} ); |
|
|
562 |
} |
| 562 |
} |
563 |
} |
| 563 |
} |
564 |
} |
| 564 |
} |
|
|
| 565 |
|
565 |
|
| 566 |
if ( $patron ) { |
|
|
| 567 |
my $patron_unblessed = $patron->unblessed; |
566 |
my $patron_unblessed = $patron->unblessed; |
| 568 |
my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); |
567 |
my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed); |
| 569 |
|
568 |
|
|
Lines 623-631
foreach my $biblionumber (@biblionumbers) {
Link Here
|
| 623 |
if ($item->{ccode}) { |
622 |
if ($item->{ccode}) { |
| 624 |
$itemdata_ccode = 1; |
623 |
$itemdata_ccode = 1; |
| 625 |
} |
624 |
} |
| 626 |
} |
|
|
| 627 |
|
625 |
|
| 628 |
push @{ $biblioitem->{itemloop} }, $item; |
626 |
push @{ $biblioitem->{itemloop} }, $item; |
|
|
627 |
|
| 628 |
} |
| 629 |
} |
629 |
} |
| 630 |
|
630 |
|
| 631 |
# While we can't override an alreay held item, we should be able to override the others |
631 |
# While we can't override an alreay held item, we should be able to override the others |
| 632 |
- |
|
|