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 |
use Koha::Util::MARC; |
87 |
use Koha::Util::MARC; |
Lines 105-116
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
105 |
} |
105 |
} |
106 |
); |
106 |
); |
107 |
|
107 |
|
108 |
my @all_items = GetItemsInfo($biblionumber); |
|
|
109 |
if( $specific_item ) { |
110 |
@all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items; |
111 |
$template->param( specific_item => 1 ); |
112 |
} |
113 |
my @items_to_show; |
114 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
108 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
115 |
|
109 |
|
116 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
110 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
Lines 120-125
unless ( $biblio && $record ) {
Link Here
|
120 |
exit; |
114 |
exit; |
121 |
} |
115 |
} |
122 |
|
116 |
|
|
|
117 |
my $items = $biblio->items->search_ordered; |
118 |
if ($specific_item) { |
119 |
$items = $items->search( { itemnumber => scalar $query->param('itemnumber') } ); |
120 |
$template->param( specific_item => 1 ); |
121 |
} |
122 |
|
123 |
unless ( $patron and $patron->category->override_hidden_items ) { |
123 |
unless ( $patron and $patron->category->override_hidden_items ) { |
124 |
# only skip this check if there's a logged in user |
124 |
# only skip this check if there's a logged in user |
125 |
# and its category overrides OpacHiddenItems |
125 |
# and its category overrides OpacHiddenItems |
Lines 127-135
unless ( $patron and $patron->category->override_hidden_items ) {
Link Here
|
127 |
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early |
127 |
print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early |
128 |
exit; |
128 |
exit; |
129 |
} |
129 |
} |
130 |
if ( scalar @all_items >= 1 ) { |
130 |
if ( $items->count >= 1 ) { |
131 |
@items_to_show = Koha::Items->search( { itemnumber => [ map { $_->{itemnumber} } @all_items ] } ) |
131 |
$items = $items->filter_by_visible_in_opac( { patron => $patron } ); |
132 |
->filter_by_visible_in_opac( { patron => $patron } )->as_list; |
|
|
133 |
} |
132 |
} |
134 |
} |
133 |
} |
135 |
|
134 |
|
Lines 495-538
$template->param(
Link Here
|
495 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
494 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
496 |
); |
495 |
); |
497 |
|
496 |
|
498 |
if ( C4::Context->preference('EasyAnalyticalRecords') ) { |
497 |
my $host_items = $biblio->host_items->filter_by_visible_in_opac({ patron => $patron }); |
499 |
# adding items linked via host biblios |
|
|
500 |
my $analyticfield = '773'; |
501 |
if ($marcflavour eq 'MARC21'){ |
502 |
$analyticfield = '773'; |
503 |
} elsif ($marcflavour eq 'UNIMARC') { |
504 |
$analyticfield = '461'; |
505 |
} |
506 |
foreach my $hostfield ( $record->field($analyticfield)) { |
507 |
my $hostbiblionumber = $hostfield->subfield("0"); |
508 |
my $linkeditemnumber = $hostfield->subfield("9"); |
509 |
my @hostitemInfos = GetItemsInfo($hostbiblionumber); |
510 |
foreach my $hostitemInfo (@hostitemInfos){ |
511 |
if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ |
512 |
push(@all_items, $hostitemInfo); |
513 |
} |
514 |
} |
515 |
} |
516 |
} |
517 |
|
498 |
|
518 |
my @items; |
499 |
$items = $biblio->items->search_ordered( |
519 |
|
500 |
{ |
520 |
# Are there items to hide? |
501 |
'me.itemnumber' => { |
521 |
# Hide items |
502 |
-in => [ |
522 |
if ( @items_to_show != @all_items ) { |
503 |
$items->get_column('itemnumber'), |
523 |
for my $itm (@all_items) { |
504 |
$host_items->get_column('itemnumber') |
524 |
next unless any { $itm->{itemnumber} eq $_ } @items_to_show; |
505 |
] |
525 |
if ( C4::Context->preference('hidelostitems') ) { |
|
|
526 |
push @items, $itm unless $itm->{itemlost}; |
527 |
} |
528 |
else { |
529 |
push @items, $itm; |
530 |
} |
506 |
} |
531 |
} |
507 |
} |
532 |
} else { |
508 |
); |
533 |
# Or not |
|
|
534 |
@items = @all_items; |
535 |
} |
536 |
|
509 |
|
537 |
my $dat = &GetBiblioData($biblionumber); |
510 |
my $dat = &GetBiblioData($biblionumber); |
538 |
my $HideMARC = $record_processor->filters->[0]->should_hide_marc( |
511 |
my $HideMARC = $record_processor->filters->[0]->should_hide_marc( |
Lines 591-598
foreach my $subscription (@subscriptions) {
Link Here
|
591 |
push @subs, \%cell; |
564 |
push @subs, \%cell; |
592 |
} |
565 |
} |
593 |
|
566 |
|
594 |
$dat->{'count'} = scalar(@items); |
567 |
$dat->{'count'} = $items->count; |
595 |
|
|
|
596 |
|
568 |
|
597 |
my (%item_reserves, %priority); |
569 |
my (%item_reserves, %priority); |
598 |
my ($show_holds_count, $show_priority); |
570 |
my ($show_holds_count, $show_priority); |
Lines 703-787
if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
Link Here
|
703 |
|
675 |
|
704 |
my $allow_onshelf_holds; |
676 |
my $allow_onshelf_holds; |
705 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
677 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
706 |
if ( not $viewallitems and @items > $max_items_to_display ) { |
678 |
if ( not $viewallitems and $items->count > $max_items_to_display ) { |
707 |
$template->param( |
679 |
$template->param( |
708 |
too_many_items => 1, |
680 |
too_many_items => 1, |
709 |
items_count => scalar( @items ), |
681 |
items_count => $items->count, |
710 |
); |
682 |
); |
711 |
} else { |
683 |
} |
712 |
for my $itm (@items) { |
684 |
else { |
713 |
my $item = Koha::Items->find( $itm->{itemnumber} ); |
685 |
while ( my $item = $items->next ) { |
714 |
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; |
686 |
my $item_info = $item->unblessed; |
715 |
$itm->{priority} = $priority{ $itm->{itemnumber} }; |
687 |
$item->{holds_count} = $item_reserves{ $item->itemnumber }; |
716 |
|
688 |
$item->{priority} = $priority{ $item->itemnumber }; |
717 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) |
689 |
|
718 |
unless $allow_onshelf_holds; |
690 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( |
719 |
|
691 |
{ item => $item, patron => $patron } ) |
720 |
# get collection code description, too |
692 |
unless $allow_onshelf_holds; |
721 |
my $ccode = $itm->{'ccode'}; |
693 |
|
722 |
$itm->{'ccode'} = $collections->{$ccode} if defined($ccode) && $collections && exists( $collections->{$ccode} ); |
694 |
# get collection code description, too |
723 |
my $copynumber = $itm->{'copynumber'}; |
695 |
my $ccode = $item->ccode; |
724 |
$itm->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumbers) && defined($copynumber) && exists( $copynumbers->{$copynumber} ) ); |
696 |
$item_info->{'ccode'} = $collections->{$ccode} |
725 |
if ( defined $itm->{'location'} ) { |
697 |
if defined($ccode) |
726 |
$itm->{'location_description'} = $shelflocations->{ $itm->{'location'} }; |
698 |
&& $collections |
727 |
} |
699 |
&& exists( $collections->{$ccode} ); |
728 |
if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) { |
700 |
|
729 |
$itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); |
701 |
my $copynumber = $item->copynumber; |
730 |
$itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description}; |
702 |
$item_info->{copynumber} = $copynumbers->{$copynumber} |
731 |
} |
703 |
if ( defined($copynumbers) |
732 |
foreach (qw(ccode materials enumchron copynumber itemnotes location_description uri)) { |
704 |
&& defined($copynumber) |
733 |
$itemfields{$_} = 1 if ($itm->{$_}); |
705 |
&& exists( $copynumbers->{$copynumber} ) ); |
734 |
} |
706 |
|
|
|
707 |
if ( defined $item->location ) { |
708 |
$item_info->{'location_description'} = |
709 |
$shelflocations->{ $item->location }; |
710 |
} |
735 |
|
711 |
|
736 |
my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber}); |
712 |
my $itemtype = $item->itemtype; |
737 |
if ( $reserve_status eq "Waiting" ) { $itm->{'waiting'} = 1; } |
713 |
$item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', |
738 |
if ( $reserve_status eq "Reserved" ) { $itm->{'onhold'} = 1; } |
714 |
$itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); |
|
|
715 |
$item_info->{'description'} = |
716 |
$itemtypes->{ $itemtype->itemtype }->{translated_description}; |
739 |
|
717 |
|
740 |
if ( C4::Context->preference('UseRecalls') ) { |
718 |
foreach my $field ( |
741 |
my $pending_recall_count = Koha::Recalls->search( |
719 |
qw(ccode materials enumchron copynumber itemnotes location_description uri) |
742 |
{ |
720 |
) |
743 |
item_id => $itm->{itemnumber}, |
721 |
{ |
744 |
status => 'waiting', |
722 |
$itemfields{$field} = 1 if $item_info->{$field}; |
745 |
} |
723 |
} |
746 |
)->count; |
|
|
747 |
if ( $pending_recall_count ) { $itm->{has_pending_recall} = 1; } |
748 |
} |
749 |
|
724 |
|
750 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); |
725 |
# FIXME The following must be Koha::Item->serial |
751 |
if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { |
726 |
my $serial_item = Koha::Serial::Items->find($item->itemnumber); |
752 |
$itm->{transfertwhen} = $transfertwhen; |
727 |
if ( $serial_item ) { |
753 |
$itm->{transfertfrom} = $transfertfrom; |
728 |
$item_info->{serial} = $serial_item; |
754 |
$itm->{transfertto} = $transfertto; |
729 |
} |
755 |
} |
|
|
756 |
|
730 |
|
757 |
if ( C4::Context->preference('OPACAcquisitionDetails') ) { |
731 |
$item_info->{checkout} = $item->checkout; |
758 |
$itm->{on_order} = 1 |
|
|
759 |
if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order; |
760 |
} |
761 |
|
732 |
|
762 |
if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) { |
733 |
my $reserve_status = |
763 |
$itm->{cover_images} = $item->cover_images; |
734 |
C4::Reserves::GetReserveStatus( $item->itemnumber ); |
764 |
} |
735 |
if ( $reserve_status eq "Waiting" ) { $item_info->{'waiting'} = 1; } |
|
|
736 |
if ( $reserve_status eq "Reserved" ) { $item_info->{'onhold'} = 1; } |
765 |
|
737 |
|
766 |
if ( $item->in_bundle ) { |
738 |
if ( C4::Context->preference('UseRecalls') ) { |
767 |
my $host = $item->bundle_host; |
739 |
my $pending_recall_count = Koha::Recalls->search( |
768 |
$itm->{bundle_host} = $host; |
740 |
{ |
769 |
} |
741 |
item_id => $item->itemnumber, |
|
|
742 |
status => 'waiting', |
743 |
} |
744 |
)->count; |
745 |
if ( $pending_recall_count ) { $item_info->has_pending_recall = 1; } |
746 |
} |
747 |
|
748 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
749 |
GetTransfers( $item->itemnumber ); |
750 |
if ( defined($transfertwhen) && $transfertwhen ne '' ) { |
751 |
$item_info->{transfertwhen} = $transfertwhen; |
752 |
$item_info->{transfertfrom} = $transfertfrom; |
753 |
$item_info->{transfertto} = $transfertto; |
754 |
} |
755 |
|
756 |
if ( C4::Context->preference('OPACAcquisitionDetails') ) { |
757 |
$item_info->{on_order} = 1 |
758 |
if grep { $_ eq $item->itemnumber } @itemnumbers_on_order; |
759 |
} |
760 |
|
761 |
if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) { |
762 |
$item_info->{cover_images} = $item->cover_images; |
763 |
} |
764 |
|
765 |
|
766 |
if ( $item->in_bundle ) { |
767 |
$item_info->{bundle_host} = $item->bundle_host; |
768 |
} |
769 |
|
770 |
if ( C4::Context->preference('UseCourseReserves') ) { |
771 |
$item_info->{course_reserves} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber ); |
772 |
} |
773 |
|
774 |
$item_info->{holding_branch} = $item->holding_branch; |
775 |
$item_info->{home_branch} = $item->home_branch; |
770 |
|
776 |
|
771 |
my $itembranch = $itm->{$separatebranch}; |
777 |
my $itembranch = $item->$separatebranch; |
772 |
if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) { |
778 |
if ( $currentbranch |
773 |
if ($itembranch and $itembranch eq $currentbranch) { |
779 |
and C4::Context->preference('OpacSeparateHoldings') ) |
774 |
push @itemloop, $itm; |
780 |
{ |
|
|
781 |
if ( $itembranch and $itembranch eq $currentbranch ) { |
782 |
push @itemloop, $item_info; |
783 |
$itemloop_has_images++ if $item->cover_images->count; |
784 |
} |
785 |
else { |
786 |
push @otheritemloop, $item_info; |
787 |
$otheritemloop_has_images++ if $item->cover_images->count; |
788 |
} |
789 |
} |
790 |
else { |
791 |
push @itemloop, $item_info; |
775 |
$itemloop_has_images++ if $item->cover_images->count; |
792 |
$itemloop_has_images++ if $item->cover_images->count; |
776 |
} else { |
|
|
777 |
push @otheritemloop, $itm; |
778 |
$otheritemloop_has_images++ if $item->cover_images->count; |
779 |
} |
793 |
} |
780 |
} else { |
|
|
781 |
push @itemloop, $itm; |
782 |
$itemloop_has_images++ if $item->cover_images->count; |
783 |
} |
794 |
} |
784 |
} |
|
|
785 |
} |
795 |
} |
786 |
|
796 |
|
787 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
797 |
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { |
Lines 828-834
my $norequests = ! $biblio->items->filter_by_for_hold->count;
Link Here
|
828 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
838 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
829 |
); |
839 |
); |
830 |
|
840 |
|
831 |
if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { |
841 |
if (C4::Context->preference("AlternateHoldingsField") && $items->count == 0) { |
832 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
842 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
833 |
my $subfields = substr $fieldspec, 3; |
843 |
my $subfields = substr $fieldspec, 3; |
834 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
844 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
Lines 1115-1121
if (C4::Context->preference("OPACShelfBrowser")) {
Link Here
|
1115 |
); |
1125 |
); |
1116 |
|
1126 |
|
1117 |
# in which tab shelf browser should open ? |
1127 |
# in which tab shelf browser should open ? |
1118 |
if (grep { $starting_itemnumber == $_->{itemnumber} } @itemloop) { |
1128 |
if (grep { $starting_itemnumber == $_->itemnumber } @itemloop) { |
1119 |
$template->param(shelfbrowser_tab => 'holdings'); |
1129 |
$template->param(shelfbrowser_tab => 'holdings'); |
1120 |
} else { |
1130 |
} else { |
1121 |
$template->param(shelfbrowser_tab => 'otherholdings'); |
1131 |
$template->param(shelfbrowser_tab => 'otherholdings'); |
Lines 1245-1256
if (C4::Context->preference('OpacHighlightedWords')) {
Link Here
|
1245 |
} |
1255 |
} |
1246 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1256 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1247 |
|
1257 |
|
1248 |
if ( C4::Context->preference('UseCourseReserves') ) { |
|
|
1249 |
foreach my $i ( @items ) { |
1250 |
$i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} ); |
1251 |
} |
1252 |
} |
1253 |
|
1254 |
$template->param( |
1258 |
$template->param( |
1255 |
'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'), |
1259 |
'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay'), |
1256 |
); |
1260 |
); |
1257 |
- |
|
|