Bug 33497: (follow-up) Adjust relationship name from bug 33493
[koha.git] / catalogue / detail.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
19 use Modern::Perl;
20
21 use CGI qw ( -utf8 );
22 use HTML::Entities;
23 use C4::Auth qw( get_template_and_user );
24 use C4::Context;
25 use C4::Koha qw(
26     GetAuthorisedValues
27     getitemtypeimagelocation
28     GetNormalizedEAN
29     GetNormalizedISBN
30     GetNormalizedOCLCNumber
31     GetNormalizedUPC
32 );
33 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
34 use C4::Output qw( output_html_with_http_headers );
35 use C4::Biblio qw( GetBiblioData GetFrameworkCode );
36 use C4::Items qw( GetAnalyticsCount );
37 use C4::Reserves;
38 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
39 use C4::XISBN qw( get_xisbns );
40 use C4::External::Amazon qw( get_amazon_tld );
41 use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra );
42 use C4::Tags qw( get_tags );
43 use C4::XSLT qw( XSLTParse4Display );
44 use Koha::DateUtils qw( format_sqldatetime );
45 use C4::HTML5Media;
46 use C4::CourseReserves qw( GetItemCourseReservesInfo );
47 use Koha::AuthorisedValues;
48 use Koha::Biblios;
49 use Koha::Biblio::ItemGroup::Items;
50 use Koha::Biblio::ItemGroups;
51 use Koha::CoverImages;
52 use Koha::DateUtils;
53 use Koha::Illrequests;
54 use Koha::Items;
55 use Koha::ItemTypes;
56 use Koha::Patrons;
57 use Koha::Virtualshelves;
58 use Koha::Plugins;
59 use Koha::Recalls;
60 use Koha::SearchEngine::Search;
61 use Koha::SearchEngine::QueryBuilder;
62 use Koha::Serial::Items;
63
64 my $query = CGI->new();
65
66 my $analyze = $query->param('analyze');
67
68 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
69     {
70     template_name   =>  'catalogue/detail.tt',
71         query           => $query,
72         type            => "intranet",
73         flagsrequired   => { catalogue => 1 },
74     }
75 );
76
77 # Determine if we should be offering any enhancement plugin buttons
78 if ( C4::Context->config('enable_plugins') ) {
79     # Only pass plugins that can offer a toolbar button
80     my @plugins = Koha::Plugins->new()->GetPlugins({
81         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
82     });
83     $template->param(
84         plugins => \@plugins,
85     );
86 }
87
88 my $biblionumber = $query->param('biblionumber');
89 $biblionumber = HTML::Entities::encode($biblionumber);
90 my $biblio = Koha::Biblios->find( $biblionumber );
91 $template->param( 'biblio', $biblio );
92
93 unless ( $biblio ) {
94     # biblionumber invalid -> report and exit
95     $template->param( unknownbiblionumber => 1,
96                       biblionumber => $biblionumber );
97     output_html_with_http_headers $query, $cookie, $template->output;
98     exit;
99 }
100
101 my $marc_record = eval { $biblio->metadata->record };
102 my $invalid_marc_record = $@ || !$marc_record;
103 if ($invalid_marc_record) {
104     $template->param( decoding_error => $@ );
105     my $marc_xml = C4::Charset::StripNonXmlChars( $biblio->metadata->metadata );
106
107     $marc_record = eval {
108         MARC::Record::new_from_xml( $marc_xml, 'UTF-8',
109             C4::Context->preference('marcflavour') );
110     };
111 }
112
113 my $op = $query->param('op') || q{};
114 if ( $op eq 'set_item_group' ) {
115     my $item_group_id = $query->param('item_group_id');
116     my @itemnumbers   = $query->multi_param('itemnumber');
117
118     foreach my $item_id (@itemnumbers) {
119         my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
120
121         if ($item_group_item) {
122             $item_group_item->item_group_id($item_group_id);
123         }
124         else {
125             $item_group_item = Koha::Biblio::ItemGroup::Item->new(
126                 {
127                     item_id        => $item_id,
128                     item_group_id  => $item_group_id,
129                 }
130             );
131         }
132
133         $item_group_item->store();
134     }
135 }
136 elsif ( $op eq 'unset_item_group' ) {
137     my $item_group_id   = $query->param('item_group_id');
138     my @itemnumbers = $query->multi_param('itemnumber');
139
140     foreach my $item_id (@itemnumbers) {
141         my $item_group_item = Koha::Biblio::ItemGroup::Items->find( { item_id => $item_id } );
142         $item_group_item->delete() if $item_group_item;
143     }
144 }
145
146 if($query->cookie("holdfor")){
147     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
148     if ( $holdfor_patron ) {
149         $template->param(
150             holdfor        => $query->cookie("holdfor"),
151             holdfor_patron => $holdfor_patron,
152         );
153     }
154 }
155
156 if($query->cookie("searchToOrder")){
157     my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
158     $template->param(
159         searchtoorder_basketno => $basketno,
160         searchtoorder_vendorid => $vendorid
161     );
162 }
163
164 my $fw           = GetFrameworkCode($biblionumber);
165 my $showallitems = $query->param('showallitems');
166 my $marcflavour  = C4::Context->preference("marcflavour");
167
168 $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
169
170 $template->param( ocoins => !$invalid_marc_record ? $biblio->get_coins : undef );
171
172 # some useful variables for enhanced content;
173 # in each case, we're grabbing the first value we find in
174 # the record and normalizing it
175 my $upc = GetNormalizedUPC($marc_record,$marcflavour);
176 my $ean = GetNormalizedEAN($marc_record,$marcflavour);
177 my $oclc = GetNormalizedOCLCNumber($marc_record,$marcflavour);
178 my $isbn = GetNormalizedISBN(undef,$marc_record,$marcflavour);
179 my $content_identifier_exists;
180 if ( $isbn or $ean or $oclc or $upc ) {
181     $content_identifier_exists = 1;
182 }
183
184 $template->param(
185     normalized_upc => $upc,
186     normalized_ean => $ean,
187     normalized_oclc => $oclc,
188     normalized_isbn => $isbn,
189     content_identifier_exists =>  $content_identifier_exists,
190 );
191
192 my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_localization->as_list } };
193 my $params;
194 my $patron = Koha::Patrons->find( $borrowernumber );
195 $params->{ itemlost } = 0 if $patron->category->hidelostitems && !$showallitems;
196 my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','current_branchtransfers'] } );
197
198 # flag indicating existence of at least one item linked via a host record
199 my $hostrecords = $biblio->host_items->count;
200
201 my $dat = &GetBiblioData($biblionumber);
202 $dat->{'count'} = $biblio->items({ host_items => 1 })->count;
203 $dat->{'showncount'} = $items->count;
204 $dat->{'hiddencount'} = $dat->{'count'} - $dat->{'showncount'};
205
206 #is biblio a collection and are bundles enabled
207 my $leader = $marc_record->leader();
208 $dat->{bundlesEnabled} = ( ( substr( $leader, 7, 1 ) eq 'c' )
209       && C4::Context->preference('BundleNotLoanValue') ) ? 1 : 0;
210
211 #coping with subscriptions
212 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
213 my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
214 my @subs;
215
216 foreach my $subscription (@subscriptions) {
217     my %cell;
218     my $serials_to_display;
219     $cell{subscriptionid}    = $subscription->{subscriptionid};
220     $cell{subscriptionnotes} = $subscription->{internalnotes};
221     $cell{missinglist}       = $subscription->{missinglist};
222     $cell{librariannote}     = $subscription->{librariannote};
223     $cell{branchcode}        = $subscription->{branchcode};
224     $cell{hasalert}          = $subscription->{hasalert};
225     $cell{callnumber}        = $subscription->{callnumber};
226     $cell{location}          = $subscription->{location};
227     $cell{closed}            = $subscription->{closed};
228     #get the three latest serials.
229     $serials_to_display = $subscription->{staffdisplaycount};
230     $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display;
231     $cell{staffdisplaycount} = $serials_to_display;
232     $cell{latestserials} =
233       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
234     push @subs, \%cell;
235 }
236
237 # Get component parts details
238 my $showcomp = C4::Context->preference('ShowComponentRecords');
239 my $show_analytics;
240 if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
241     if ( my $components = !$invalid_marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) {
242         $show_analytics = 1 if @{$components}; # just show link when having results
243         $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
244         my $parts;
245         for my $part ( @{$components} ) {
246             $part = C4::Search::new_record_from_zebra( 'biblioserver', $part );
247             my $id = Koha::SearchEngine::Search::extract_biblionumber( $part );
248
249             push @{$parts},
250               XSLTParse4Display(
251                 {
252                     biblionumber => $id,
253                     record       => $part,
254                     xsl_syspref  => "XSLTResultsDisplay",
255                     fix_amps     => 1,
256                 }
257               );
258         }
259         $template->param( ComponentParts => $parts );
260         my ( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query;
261         my $cpq = $comp_query_str . "&sort_by=" . $comp_sort;
262         $template->param( ComponentPartsQuery => $cpq );
263     }
264 } else { # check if we should show analytics anyway
265     $show_analytics = 1 if !$invalid_marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
266     $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
267 }
268
269 # XSLT processing of some stuff
270 my $xslt_variables = { show_analytics_link => $show_analytics };
271 $template->param(
272     XSLTDetailsDisplay => '1',
273     XSLTBloc => XSLTParse4Display({
274         biblionumber   => $biblionumber,
275         record         => $marc_record,
276         xsl_syspref    => "XSLTDetailsDisplay",
277         fix_amps       => 1,
278         xslt_variables => $xslt_variables,
279     }),
280 );
281
282 # Get acquisition details
283 if ( C4::Context->preference('AcquisitionDetails') ) {
284     my $orders = Koha::Acquisition::Orders->search(
285         { biblionumber => $biblionumber },
286         {
287             join => 'basketno',
288             order_by => 'basketno.booksellerid'
289         }
290     );    # GetHistory sorted by aqbooksellerid, but does it make sense?
291
292     $template->param(
293         orders => $orders,
294     );
295 }
296
297 if ( C4::Context->preference('suggestion') ) {
298     my $suggestions = Koha::Suggestions->search(
299         {
300             biblionumber => $biblionumber,
301             archived     => 0,
302         },
303         {
304             order_by => { -desc => 'suggesteddate' }
305         }
306     );
307     my $nb_archived_suggestions = Koha::Suggestions->search({ biblionumber => $biblionumber, archived => 1 })->count;
308     $template->param( suggestions => $suggestions, nb_archived_suggestions => $nb_archived_suggestions );
309 }
310
311 if ( defined $dat->{'itemtype'} ) {
312     $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }->imageurl );
313 }
314
315 my (@itemloop, @otheritemloop, %itemfields);
316
317 my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
318 if ( $mss->count ) {
319     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
320 }
321 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
322 if ( $mss->count ) {
323     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
324 }
325 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
326 if ( $mss->count ) {
327     $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
328 }
329
330 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
331 my %materials_map;
332 if ($mss->count) {
333     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
334     if ($materials_authvals) {
335         foreach my $value (@$materials_authvals) {
336             $materials_map{$value->{authorised_value}} = $value->{lib};
337         }
338     }
339 }
340
341 my $analytics_flag;
342 my $materials_flag; # set this if the items have anything in the materials field
343 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
344 if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
345     $template->param(SeparateHoldings => 1);
346 }
347 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
348 my ( $itemloop_has_images, $otheritemloop_has_images );
349
350 while ( my $item = $items->next ) {
351     my $itembranchcode = $item->$separatebranch;
352
353     my $item_info = $item->unblessed;
354     $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype};
355
356     foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri )) {
357         $itemfields{$_} = 1 if $item->$_;
358     }
359
360     # FIXME The following must be Koha::Item->serial
361     my $serial_item = Koha::Serial::Items->find($item->itemnumber);
362     if ( $serial_item ) {
363         my $serial = Koha::Serials->find($serial_item->serialid);
364         $item_info->{serial} = $serial if $serial;
365         $itemfields{publisheddate} = 1;
366     }
367
368     $item_info->{object} = $item;
369
370     # checking for holds
371     my $holds = $item->current_holds;
372     if ( my $first_hold = $holds->next ) {
373         $item_info->{first_hold} = $first_hold;
374     }
375
376     #item has a host number if its biblio number does not match the current bib
377
378     if ($item->biblionumber ne $biblionumber){
379         $item_info->{hostbiblionumber} = $item->biblionumber;
380         $item_info->{hosttitle} = $item->biblio->title;
381     }
382
383
384     if ( $analyze ) {
385         # count if item is used in analytical bibliorecords
386         # The 'countanalytics' flag is only used in the templates if analyze is set
387         my $countanalytics = GetAnalyticsCount( $item->itemnumber );
388         if ($countanalytics > 0){
389             $analytics_flag=1;
390             $item_info->{countanalytics} = $countanalytics;
391         }
392     }
393
394     if (defined($item->materials) && $item->materials =~ /\S/){
395         $materials_flag = 1;
396         if (defined $materials_map{ $item->materials }) {
397             $item_info->{materials} = $materials_map{ $item->materials };
398         }
399     }
400
401     if ( C4::Context->preference('UseCourseReserves') ) {
402         $item_info->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber );
403     }
404
405     $item_info->{can_be_edited} = $patron->can_edit_items_from( $item->homebranch );
406
407     if ( $item->is_bundle ) {
408         $item_info->{bundled} =
409           $item->bundle_items->search( { itemlost => { '!=' => 0 } } )
410           ->count;
411         $item_info->{bundled_lost} =
412           $item->bundle_items->search( { itemlost => 0 } )->count;
413         $item_info->{is_bundle} = 1;
414     }
415
416     if ($item->in_bundle) {
417         $item_info->{bundle_host} = $item->bundle_host;
418     }
419
420     if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
421         if ($itembranchcode and $itembranchcode eq $currentbranch) {
422             push @itemloop, $item_info;
423             $itemloop_has_images++ if $item->cover_images->count;
424         } else {
425             push @otheritemloop, $item_info;
426             $otheritemloop_has_images++ if $item->cover_images->count;
427         }
428     } else {
429         push @itemloop, $item_info;
430         $itemloop_has_images++ if $item->cover_images->count;
431     }
432 }
433
434 $template->param(
435     itemloop_has_images      => $itemloop_has_images,
436     otheritemloop_has_images => $otheritemloop_has_images,
437 );
438
439 # Display only one tab if one items list is empty
440 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
441     $template->param(SeparateHoldings => 0);
442     if (scalar(@itemloop) == 0) {
443         @itemloop = @otheritemloop;
444     }
445 }
446
447 my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
448     {
449         borrowernumber => $borrowernumber,
450         add_allowed    => 1,
451         public         => 0,
452     }
453 );
454 my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
455     {
456         borrowernumber => $borrowernumber,
457         add_allowed    => 1,
458         public         => 1,
459     }
460 );
461
462
463 $template->param(
464     add_to_some_private_shelves => $some_private_shelves,
465     add_to_some_public_shelves  => $some_public_shelves,
466 );
467
468 $template->param(
469     MARCNOTES               => !$invalid_marc_record ? $biblio->get_marc_notes() : undef,
470     itemdata_ccode          => $itemfields{ccode},
471     itemdata_enumchron      => $itemfields{enumchron},
472     itemdata_uri            => $itemfields{uri},
473     itemdata_copynumber     => $itemfields{copynumber},
474     itemdata_stocknumber    => $itemfields{stocknumber},
475     itemdata_publisheddate  => $itemfields{publisheddate},
476     volinfo                 => $itemfields{enumchron},
477     itemdata_itemnotes      => $itemfields{itemnotes},
478     itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic},
479     z3950_search_params     => C4::Search::z3950_search_args($dat),
480     hostrecords             => $hostrecords,
481     analytics_flag          => $analytics_flag,
482     C4::Search::enabled_staff_search_views,
483     materials => $materials_flag,
484 );
485
486 if (C4::Context->preference("AlternateHoldingsField") && $items->count == 0) {
487     my $fieldspec = C4::Context->preference("AlternateHoldingsField");
488     my $subfields = substr $fieldspec, 3;
489     my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
490     my @alternateholdingsinfo = ();
491     my @holdingsfields = $marc_record->field(substr $fieldspec, 0, 3);
492
493     for my $field (@holdingsfields) {
494         my %holding = ( holding => '' );
495         my $havesubfield = 0;
496         for my $subfield ($field->subfields()) {
497             if ((index $subfields, $$subfield[0]) >= 0) {
498                 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
499                 $holding{'holding'} .= $$subfield[1];
500                 $havesubfield++;
501             }
502         }
503         if ($havesubfield) {
504             push(@alternateholdingsinfo, \%holding);
505         }
506     }
507
508     $template->param(
509         ALTERNATEHOLDINGS   => \@alternateholdingsinfo,
510         );
511 }
512
513 my @results = ( $dat, );
514 foreach ( keys %{$dat} ) {
515     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
516 }
517
518 # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
519 # method query not found?!?!
520 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages"));
521 $template->param(
522     itemloop        => \@itemloop,
523     otheritemloop   => \@otheritemloop,
524     biblionumber        => $biblionumber,
525     ($analyze? 'analyze':'detailview') =>1,
526     subscriptions       => \@subs,
527     subscriptionsnumber => $subscriptionsnumber,
528     subscriptiontitle   => $dat->{title},
529     searchid            => scalar $query->param('searchid'),
530 );
531
532 # Lists
533
534 if (C4::Context->preference("virtualshelves") ) {
535     my $shelves = Koha::Virtualshelves->search(
536         {
537             biblionumber => $biblionumber,
538             public => 1,
539         },
540         {
541             join => 'virtualshelfcontents',
542         }
543     );
544     $template->param( 'shelves' => $shelves );
545 }
546
547 # XISBN Stuff
548 if (C4::Context->preference("FRBRizeEditions")==1) {
549     eval {
550         $template->param(
551             XISBNS => scalar get_xisbns($isbn, $biblionumber)
552         );
553     };
554     if ($@) { warn "XISBN Failed $@"; }
555 }
556
557 if ( C4::Context->preference("LocalCoverImages") == 1 ) {
558     my $images = $biblio->cover_images;
559     $template->param(
560         localimages => $biblio->cover_images->search(
561             {}, { order_by => [ \"COALESCE(itemnumber, 0, 1)", 'timestamp' ] }
562         ),
563     );
564 }
565
566 # HTML5 Media
567 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
568     $template->param( C4::HTML5Media->gethtml5media($marc_record));
569 }
570
571 # Displaying tags
572 my $tag_quantity;
573 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
574     $template->param(
575         TagsEnabled => 1,
576         TagsShowOnDetail => $tag_quantity
577     );
578     $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
579                                 'sort'=>'-weight', limit=>$tag_quantity}));
580 }
581
582 #we only need to pass the number of holds to the template
583 my $holds = $biblio->holds;
584 $template->param( holdcount => $holds->count );
585
586 # Check if there are any ILL requests connected to the biblio
587 my $illrequests =
588     C4::Context->preference('ILLModule')
589   ? Koha::Illrequests->search( { biblio_id => $biblionumber } )
590   : [];
591 $template->param( illrequests => $illrequests );
592
593 my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
594 if ($StaffDetailItemSelection) {
595     # Only enable item selection if user can execute at least one action
596     if (
597         $flags->{superlibrarian}
598         || (
599             ref $flags->{tools} eq 'HASH' && (
600                 $flags->{tools}->{items_batchmod}       # Modify selected items
601                 || $flags->{tools}->{items_batchdel}    # Delete selected items
602             )
603         )
604         || ( ref $flags->{tools} eq '' && $flags->{tools} )
605       )
606     {
607         $template->param(
608             StaffDetailItemSelection => $StaffDetailItemSelection );
609     }
610 }
611
612 # get biblionumbers stored in the cart
613 my @cart_list;
614
615 if($query->cookie("intranet_bib_list")){
616     my $cart_list = $query->cookie("intranet_bib_list");
617     @cart_list = split(/\//, $cart_list);
618     if ( grep {$_ eq $biblionumber} @cart_list) {
619         $template->param( incart => 1 );
620     }
621 }
622
623 if ( C4::Context->preference('UseCourseReserves') ) {
624     my $course_reserves = GetItemCourseReservesInfo( biblionumber => $biblionumber );
625     $template->param( course_reserves => $course_reserves );
626 }
627
628 $template->param(found1 => scalar $query->param('found1') );
629
630 $template->param(biblio => $biblio);
631
632 output_html_with_http_headers $query, $cookie, $template->output;