Lines 45-51
use C4::Biblio qw(
Link Here
|
45 |
GetMarcSubjects |
45 |
GetMarcSubjects |
46 |
GetMarcUrls |
46 |
GetMarcUrls |
47 |
); |
47 |
); |
48 |
use C4::Items qw( GetItemsInfo ); |
|
|
49 |
use C4::Circulation qw( GetTransfers ); |
48 |
use C4::Circulation qw( GetTransfers ); |
50 |
use C4::Tags qw( get_tags ); |
49 |
use C4::Tags qw( get_tags ); |
51 |
use C4::XISBN qw( get_xisbns ); |
50 |
use C4::XISBN qw( get_xisbns ); |
Lines 82-87
use Koha::Plugins;
Link Here
|
82 |
use Koha::Ratings; |
81 |
use Koha::Ratings; |
83 |
use Koha::Recalls; |
82 |
use Koha::Recalls; |
84 |
use Koha::Reviews; |
83 |
use Koha::Reviews; |
|
|
84 |
use Koha::Serial::Items; |
85 |
use Koha::SearchEngine::Search; |
85 |
use Koha::SearchEngine::Search; |
86 |
use Koha::SearchEngine::QueryBuilder; |
86 |
use Koha::SearchEngine::QueryBuilder; |
87 |
|
87 |
|
Lines 103-114
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
103 |
} |
103 |
} |
104 |
); |
104 |
); |
105 |
|
105 |
|
106 |
my @all_items = GetItemsInfo($biblionumber); |
|
|
107 |
if( $specific_item ) { |
108 |
@all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items; |
109 |
$template->param( specific_item => 1 ); |
110 |
} |
111 |
my @items_to_show; |
112 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
106 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
113 |
|
107 |
|
114 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
108 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
Lines 118-123
unless ( $biblio && $record ) {
Link Here
|
118 |
exit; |
112 |
exit; |
119 |
} |
113 |
} |
120 |
|
114 |
|
|
|
115 |
my $items = $biblio->items; |
116 |
if ($specific_item) { |
117 |
$items->search( { itemnumber => scalar $query->param('itemnumber') } ); |
118 |
$template->param( specific_item => 1 ); |
119 |
} |
120 |
|
121 |
unless ( $patron and $patron->category->override_hidden_items ) { |
121 |
unless ( $patron and $patron->category->override_hidden_items ) { |
122 |
# only skip this check if there's a logged in user |
122 |
# only skip this check if there's a logged in user |
123 |
# and its category overrides OpacHiddenItems |
123 |
# and its category overrides OpacHiddenItems |
Lines 125-133
unless ( $patron and $patron->category->override_hidden_items ) {
Link Here
|
125 |
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early |
125 |
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early |
126 |
exit; |
126 |
exit; |
127 |
} |
127 |
} |
128 |
if ( scalar @all_items >= 1 ) { |
128 |
if ( $items->count >= 1 ) { |
129 |
@items_to_show = Koha::Items->search( { itemnumbers => [ map { $_->{itemnumber} } @all_items ] } ) |
129 |
$items = $items->filter_by_visible_in_opac( { patron => $patron } ); |
130 |
->filter_by_visible_in_opac( { patron => $patron } ); |
|
|
131 |
} |
130 |
} |
132 |
} |
131 |
} |
133 |
|
132 |
|
Lines 490-533
$template->param(
Link Here
|
490 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
489 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
491 |
); |
490 |
); |
492 |
|
491 |
|
493 |
if ( C4::Context->preference('EasyAnalyticalRecords') ) { |
492 |
my $host_items = $biblio->host_items->filter_by_visible_in_opac({ patron => $patron }); |
494 |
# adding items linked via host biblios |
|
|
495 |
my $analyticfield = '773'; |
496 |
if ($marcflavour eq 'MARC21'){ |
497 |
$analyticfield = '773'; |
498 |
} elsif ($marcflavour eq 'UNIMARC') { |
499 |
$analyticfield = '461'; |
500 |
} |
501 |
foreach my $hostfield ( $record->field($analyticfield)) { |
502 |
my $hostbiblionumber = $hostfield->subfield("0"); |
503 |
my $linkeditemnumber = $hostfield->subfield("9"); |
504 |
my @hostitemInfos = GetItemsInfo($hostbiblionumber); |
505 |
foreach my $hostitemInfo (@hostitemInfos){ |
506 |
if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ |
507 |
push(@all_items, $hostitemInfo); |
508 |
} |
509 |
} |
510 |
} |
511 |
} |
512 |
|
513 |
my @items; |
514 |
|
493 |
|
515 |
# Are there items to hide? |
494 |
$items = $biblio->items->search( |
516 |
# Hide items |
495 |
{ |
517 |
if ( @items_to_show != @all_items ) { |
496 |
itemnumber => { |
518 |
for my $itm (@all_items) { |
497 |
-in => [ |
519 |
next unless any { $itm->{itemnumber} eq $_ } @items_to_show; |
498 |
$items->get_column('itemnumber'), |
520 |
if ( C4::Context->preference('hidelostitems') ) { |
499 |
$host_items->get_column('itemnumber') |
521 |
push @items, $itm unless $itm->{itemlost}; |
500 |
] |
522 |
} |
|
|
523 |
else { |
524 |
push @items, $itm; |
525 |
} |
501 |
} |
526 |
} |
502 |
} |
527 |
} else { |
503 |
); |
528 |
# Or not |
|
|
529 |
@items = @all_items; |
530 |
} |
531 |
|
504 |
|
532 |
my $dat = &GetBiblioData($biblionumber); |
505 |
my $dat = &GetBiblioData($biblionumber); |
533 |
my $HideMARC = $record_processor->filters->[0]->should_hide_marc( |
506 |
my $HideMARC = $record_processor->filters->[0]->should_hide_marc( |
Lines 586-593
foreach my $subscription (@subscriptions) {
Link Here
|
586 |
push @subs, \%cell; |
559 |
push @subs, \%cell; |
587 |
} |
560 |
} |
588 |
|
561 |
|
589 |
$dat->{'count'} = scalar(@items); |
562 |
$dat->{'count'} = $items->count; |
590 |
|
|
|
591 |
|
563 |
|
592 |
my (%item_reserves, %priority); |
564 |
my (%item_reserves, %priority); |
593 |
my ($show_holds_count, $show_priority); |
565 |
my ($show_holds_count, $show_priority); |
Lines 696-775
if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
Link Here
|
696 |
|
668 |
|
697 |
my $allow_onshelf_holds; |
669 |
my $allow_onshelf_holds; |
698 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
670 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
699 |
if ( not $viewallitems and @items > $max_items_to_display ) { |
671 |
if ( not $viewallitems and $items->count > $max_items_to_display ) { |
700 |
$template->param( |
672 |
$template->param( |
701 |
too_many_items => 1, |
673 |
too_many_items => 1, |
702 |
items_count => scalar( @items ), |
674 |
items_count => $items->count, |
703 |
); |
675 |
); |
704 |
} else { |
676 |
} |
705 |
for my $itm (@items) { |
677 |
else { |
706 |
my $item = Koha::Items->find( $itm->{itemnumber} ); |
678 |
while ( my $item = $items->next ) { |
707 |
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; |
679 |
my $item_info = $item->unblessed; |
708 |
$itm->{priority} = $priority{ $itm->{itemnumber} }; |
680 |
$item->{holds_count} = $item_reserves{ $item->itemnumber }; |
709 |
|
681 |
$item->{priority} = $priority{ $item->itemnumber }; |
710 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) |
682 |
|
711 |
unless $allow_onshelf_holds; |
683 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( |
712 |
|
684 |
{ item => $item, patron => $patron } ) |
713 |
# get collection code description, too |
685 |
unless $allow_onshelf_holds; |
714 |
my $ccode = $itm->{'ccode'}; |
686 |
|
715 |
$itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} ); |
687 |
# get collection code description, too |
716 |
my $copynumber = $itm->{'copynumber'}; |
688 |
my $ccode = $item->ccode; |
717 |
$itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) ); |
689 |
$item_info->{'ccode'} = $collections->{$ccode} |
718 |
if ( defined $itm->{'location'} ) { |
690 |
if defined($ccode) |
719 |
$itm->{'location_description'} = $shelflocations->{ $itm->{'location'} }; |
691 |
&& $collections |
720 |
} |
692 |
&& exists( $collections->{$ccode} ); |
721 |
if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { |
693 |
|
722 |
$itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); |
694 |
my $copynumber = $item->copynumber; |
723 |
$itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description}; |
695 |
$item_info->{copynumber} = $copynumbers->{$copynumber} |
724 |
} |
696 |
if ( defined($copynumbers) |
725 |
foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) { |
697 |
&& defined($copynumber) |
726 |
$itemfields{$_} = 1 if ($itm->{$_}); |
698 |
&& exists( $copynumbers->{$copynumber} ) ); |
727 |
} |
699 |
|
|
|
700 |
if ( defined $item->location ) { |
701 |
$item_info->{'location_description'} = |
702 |
$shelflocations->{ $item->location }; |
703 |
} |
728 |
|
704 |
|
729 |
my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber}); |
705 |
my $itemtype = $item->itemtype; |
730 |
if ( $reserve_status eq "Waiting" ) { $itm->{'waiting'} = 1; } |
706 |
$item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', |
731 |
if ( $reserve_status eq "Reserved" ) { $itm->{'onhold'} = 1; } |
707 |
$itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); |
|
|
708 |
$item_info->{'description'} = |
709 |
$itemtypes->{ $itemtype->itemtype }->{translated_description}; |
732 |
|
710 |
|
733 |
if ( C4::Context->preference('UseRecalls') ) { |
711 |
foreach my $field ( |
734 |
my $pending_recall_count = Koha::Recalls->search( |
712 |
qw(ccode materials enumchron copynumber itemnotes location_description uri) |
735 |
{ |
713 |
) |
736 |
item_id => $itm->{itemnumber}, |
714 |
{ |
737 |
status => 'waiting', |
715 |
$itemfields{$field} = 1 if $item_info->{$field}; |
738 |
} |
716 |
} |
739 |
)->count; |
|
|
740 |
if ( $pending_recall_count ) { $itm->{has_pending_recall} = 1; } |
741 |
} |
742 |
|
717 |
|
743 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); |
718 |
# FIXME The following must be Koha::Item->serial |
744 |
if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { |
719 |
my $serial_item = Koha::Serial::Items->find($item->itemnumber); |
745 |
$itm->{transfertwhen} = $transfertwhen; |
720 |
if ( $serial_item ) { |
746 |
$itm->{transfertfrom} = $transfertfrom; |
721 |
$item_info->{serial} = $serial_item; |
747 |
$itm->{transfertto} = $transfertto; |
722 |
} |
748 |
} |
|
|
749 |
|
723 |
|
750 |
if ( C4::Context->preference('OPACAcquisitionDetails') ) { |
724 |
$item_info->{checkout} = $item->checkout; |
751 |
$itm->{on_order} = 1 |
725 |
|
752 |
if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order; |
726 |
my $reserve_status = |
753 |
} |
727 |
C4::Reserves::GetReserveStatus( $item->itemnumber ); |
|
|
728 |
if ( $reserve_status eq "Waiting" ) { $item_info->{'waiting'} = 1; } |
729 |
if ( $reserve_status eq "Reserved" ) { $item_info->{'onhold'} = 1; } |
730 |
|
731 |
my $recall_status; |
732 |
if ( C4::Context->preference('UseRecalls') ) { |
733 |
my $pending_recall_count = Koha::Recalls->search( |
734 |
{ |
735 |
item_id => $item->itemnumber, |
736 |
status => 'waiting', |
737 |
} |
738 |
)->count; |
739 |
if ( $pending_recall_count ) { $item_info->has_pending_recall = 1; } |
740 |
} |
741 |
|
742 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
743 |
GetTransfers( $item->itemnumber ); |
744 |
if ( defined($transfertwhen) && $transfertwhen ne '' ) { |
745 |
$item_info->{transfertwhen} = $transfertwhen; |
746 |
$item_info->{transfertfrom} = $transfertfrom; |
747 |
$item_info->{transfertto} = $transfertto; |
748 |
} |
749 |
|
750 |
if ( C4::Context->preference('OPACAcquisitionDetails') ) { |
751 |
$item_info->{on_order} = 1 |
752 |
if grep { $_ eq $item->itemnumber } @itemnumbers_on_order; |
753 |
} |
754 |
|
755 |
if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) { |
756 |
$item_info->{cover_images} = $item->cover_images; |
757 |
} |
754 |
|
758 |
|
755 |
if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) { |
|
|
756 |
$itm->{cover_images} = $item->cover_images; |
757 |
} |
758 |
|
759 |
|
759 |
my $itembranch = $itm->{$separatebranch}; |
760 |
if ( C4::Context->preference('UseCourseReserves') ) { |
760 |
if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) { |
761 |
$item_info->{course_reserves} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber ); |
761 |
if ($itembranch and $itembranch eq $currentbranch) { |
762 |
} |
762 |
push @itemloop, $itm; |
763 |
|
|
|
764 |
$item_info->{holding_branch} = $item->holding_branch; |
765 |
$item_info->{home_branch} = $item->home_branch; |
766 |
|
767 |
my $itembranch = $item->$separatebranch; |
768 |
if ( $currentbranch |
769 |
and C4::Context->preference('OpacSeparateHoldings') ) |
770 |
{ |
771 |
if ( $itembranch and $itembranch eq $currentbranch ) { |
772 |
push @itemloop, $item_info; |
773 |
$itemloop_has_images++ if $item->cover_images->count; |
774 |
} |
775 |
else { |
776 |
push @otheritemloop, $item_info; |
777 |
$otheritemloop_has_images++ if $item->cover_images->count; |
778 |
} |
779 |
} |
780 |
else { |
781 |
push @itemloop, $item_info; |
763 |
$itemloop_has_images++ if $item->cover_images->count; |
782 |
$itemloop_has_images++ if $item->cover_images->count; |
764 |
} else { |
|
|
765 |
push @otheritemloop, $itm; |
766 |
$otheritemloop_has_images++ if $item->cover_images->count; |
767 |
} |
783 |
} |
768 |
} else { |
|
|
769 |
push @itemloop, $itm; |
770 |
$itemloop_has_images++ if $item->cover_images->count; |
771 |
} |
784 |
} |
772 |
} |
|
|
773 |
} |
785 |
} |
774 |
|
786 |
|
775 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
787 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
Lines 816-822
my $norequests = ! $biblio->items->filter_by_for_hold->count;
Link Here
|
816 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
828 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
817 |
); |
829 |
); |
818 |
|
830 |
|
819 |
if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { |
831 |
if (C4::Context->preference("AlternateHoldingsField") && $items->count == 0) { |
820 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
832 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
821 |
my $subfields = substr $fieldspec, 3; |
833 |
my $subfields = substr $fieldspec, 3; |
822 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
834 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
Lines 1103-1109
if (C4::Context->preference("OPACShelfBrowser")) {
Link Here
|
1103 |
); |
1115 |
); |
1104 |
|
1116 |
|
1105 |
# in which tab shelf browser should open ? |
1117 |
# in which tab shelf browser should open ? |
1106 |
if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) { |
1118 |
if (grep { $starting_itemnumber == $_->itemnumber } @itemloop) { |
1107 |
$template->param(shelfbrowser_tab => 'holdings'); |
1119 |
$template->param(shelfbrowser_tab => 'holdings'); |
1108 |
} else { |
1120 |
} else { |
1109 |
$template->param(shelfbrowser_tab => 'otherholdings'); |
1121 |
$template->param(shelfbrowser_tab => 'otherholdings'); |
Lines 1231-1242
if (C4::Context->preference('OpacHighlightedWords')) {
Link Here
|
1231 |
} |
1243 |
} |
1232 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1244 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1233 |
|
1245 |
|
1234 |
if ( C4::Context->preference('UseCourseReserves') ) { |
|
|
1235 |
foreach my $i ( @items ) { |
1236 |
$i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} ); |
1237 |
} |
1238 |
} |
1239 |
|
1240 |
$template->param( |
1246 |
$template->param( |
1241 |
'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'), |
1247 |
'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'), |
1242 |
); |
1248 |
); |
1243 |
- |
|
|