Bug 29284: (follow-up) Improve error logging to prevent warns
[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 GetMarcBiblio );
36 use C4::Items qw( GetAnalyticsCount GetHostItemsInfo GetItemsInfo );
37 use C4::Circulation qw( GetTransfers );
38 use C4::Reserves;
39 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
40 use C4::XISBN qw( get_xisbns );
41 use C4::External::Amazon qw( get_amazon_tld );
42 use C4::Search qw( z3950_search_args enabled_staff_search_views );
43 use C4::Tags qw( get_tags );
44 use C4::XSLT qw( XSLTParse4Display );
45 use Koha::DateUtils qw( format_sqldatetime );
46 use C4::HTML5Media;
47 use C4::CourseReserves qw( GetItemCourseReservesInfo );
48 use Koha::AuthorisedValues;
49 use Koha::Biblios;
50 use Koha::CoverImages;
51 use Koha::Illrequests;
52 use Koha::Items;
53 use Koha::ItemTypes;
54 use Koha::Patrons;
55 use Koha::Virtualshelves;
56 use Koha::Plugins;
57 use Koha::SearchEngine::Search;
58 use Koha::SearchEngine::QueryBuilder;
59
60 my $query = CGI->new();
61
62 my $analyze = $query->param('analyze');
63
64 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
65     {
66     template_name   =>  'catalogue/detail.tt',
67         query           => $query,
68         type            => "intranet",
69         flagsrequired   => { catalogue => 1 },
70     }
71 );
72
73 # Determine if we should be offering any enhancement plugin buttons
74 if ( C4::Context->config('enable_plugins') ) {
75     # Only pass plugins that can offer a toolbar button
76     my @plugins = Koha::Plugins->new()->GetPlugins({
77         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
78     });
79     $template->param(
80         plugins => \@plugins,
81     );
82 }
83
84 my $biblionumber = $query->param('biblionumber');
85 $biblionumber = HTML::Entities::encode($biblionumber);
86 my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
87 my $biblio = Koha::Biblios->find( $biblionumber );
88 $template->param( 'biblio', $biblio );
89
90 if ( not defined $record ) {
91     # biblionumber invalid -> report and exit
92     $template->param( unknownbiblionumber => 1,
93                       biblionumber => $biblionumber );
94     output_html_with_http_headers $query, $cookie, $template->output;
95     exit;
96 }
97
98 eval { $biblio->metadata->record };
99 $template->param( decoding_error => $@ );
100
101 if($query->cookie("holdfor")){
102     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
103     if ( $holdfor_patron ) {
104         $template->param(
105             # FIXME Should pass the patron object
106             holdfor => $query->cookie("holdfor"),
107             holdfor_surname => $holdfor_patron->surname,
108             holdfor_firstname => $holdfor_patron->firstname,
109             holdfor_cardnumber => $holdfor_patron->cardnumber,
110         );
111     }
112 }
113
114 if($query->cookie("searchToOrder")){
115     my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
116     $template->param(
117         searchtoorder_basketno => $basketno,
118         searchtoorder_vendorid => $vendorid
119     );
120 }
121
122 my $fw           = GetFrameworkCode($biblionumber);
123 my $showallitems = $query->param('showallitems');
124 my $marcflavour  = C4::Context->preference("marcflavour");
125
126 {
127     # XSLT processing of some stuff
128
129     my $searcher = Koha::SearchEngine::Search->new(
130         { index => $Koha::SearchEngine::BIBLIOS_INDEX }
131     );
132     my $builder = Koha::SearchEngine::QueryBuilder->new(
133         { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
134
135     my $cleaned_title = $biblio->title;
136     $cleaned_title =~ tr|/||;
137     $cleaned_title = $builder->clean_search_term($cleaned_title);
138
139     my $query =
140       ( C4::Context->preference('UseControlNumber') and $record->field('001') )
141       ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
142       : "Host-item:($cleaned_title)";
143     my ( $err, $result, $count );
144     eval {
145         ( $err, $result, $count ) =
146           $searcher->simple_search_compat( $query, 0, 0 );
147
148     };
149     if ($err || $@){
150         my $error = q{};
151         $error .= $err if $err;
152         $error .= $@ if $@;
153         warn "Warning from simple_search_compat: $error";
154         $template->param( analytics_error => 1 );
155     }
156
157     my $variables = {
158         show_analytics_link => defined $count && $count > 0 ? 1 : 0
159     };
160
161     $template->param(
162         XSLTDetailsDisplay => '1',
163         XSLTBloc => XSLTParse4Display(
164             {
165                 biblionumber   => $biblionumber,
166                 record         => $record,
167                 xsl_syspref    => "XSLTDetailsDisplay",
168                 fix_amps       => 1,
169                 xslt_variables => $variables
170             }
171         ),
172     );
173 }
174
175 $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
176
177 # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
178 # Do not propagate it as we already deal with it previously in this script
179 my $coins = eval { $biblio->get_coins };
180 $template->param( ocoins => $coins );
181
182 # some useful variables for enhanced content;
183 # in each case, we're grabbing the first value we find in
184 # the record and normalizing it
185 my $upc = GetNormalizedUPC($record,$marcflavour);
186 my $ean = GetNormalizedEAN($record,$marcflavour);
187 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
188 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
189
190 $template->param(
191     normalized_upc => $upc,
192     normalized_ean => $ean,
193     normalized_oclc => $oclc,
194     normalized_isbn => $isbn,
195 );
196
197 my $marcnotesarray   = $biblio->get_marc_notes({ marcflavour => $marcflavour });
198
199 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
200
201 my $dbh = C4::Context->dbh;
202
203 my @all_items = GetItemsInfo( $biblionumber );
204 my @items;
205 my $patron = Koha::Patrons->find( $borrowernumber );
206 for my $itm (@all_items) {
207     push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems);
208 }
209
210 # flag indicating existence of at least one item linked via a host record
211 my $hostrecords;
212 # adding items linked via host biblios
213 my @hostitems = GetHostItemsInfo($record);
214 if (@hostitems){
215     $hostrecords =1;
216     push (@items,@hostitems);
217 }
218
219 my $dat = &GetBiblioData($biblionumber);
220
221 #coping with subscriptions
222 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
223 my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
224 my @subs;
225
226 foreach my $subscription (@subscriptions) {
227     my %cell;
228     my $serials_to_display;
229     $cell{subscriptionid}    = $subscription->{subscriptionid};
230     $cell{subscriptionnotes} = $subscription->{internalnotes};
231     $cell{missinglist}       = $subscription->{missinglist};
232     $cell{librariannote}     = $subscription->{librariannote};
233     $cell{branchcode}        = $subscription->{branchcode};
234     $cell{hasalert}          = $subscription->{hasalert};
235     $cell{callnumber}        = $subscription->{callnumber};
236     $cell{location}          = $subscription->{location};
237     $cell{closed}            = $subscription->{closed};
238     #get the three latest serials.
239     $serials_to_display = $subscription->{staffdisplaycount};
240     $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display;
241     $cell{staffdisplaycount} = $serials_to_display;
242     $cell{latestserials} =
243       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
244     push @subs, \%cell;
245 }
246
247
248 # Get acquisition details
249 if ( C4::Context->preference('AcquisitionDetails') ) {
250     my $orders = Koha::Acquisition::Orders->search(
251         { biblionumber => $biblionumber },
252         {
253             join => 'basketno',
254             order_by => 'basketno.booksellerid'
255         }
256     );    # GetHistory sorted by aqbooksellerid, but does it make sense?
257
258     $template->param(
259         orders => $orders,
260     );
261 }
262
263 if ( C4::Context->preference('suggestion') ) {
264     my $suggestions = Koha::Suggestions->search(
265         {
266             biblionumber => $biblionumber,
267             archived     => 0,
268         },
269         {
270             order_by => { -desc => 'suggesteddate' }
271         }
272     );
273     my $nb_archived_suggestions = Koha::Suggestions->search({ biblionumber => $biblionumber, archived => 1 })->count;
274     $template->param( suggestions => $suggestions, nb_archived_suggestions => $nb_archived_suggestions );
275 }
276
277 if ( defined $dat->{'itemtype'} ) {
278     $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
279 }
280
281 $dat->{'count'} = scalar @all_items + @hostitems;
282 $dat->{'showncount'} = scalar @items + @hostitems;
283 $dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
284
285 my $shelflocations =
286   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
287 my $collections =
288   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
289 my $copynumbers =
290   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
291 my (@itemloop, @otheritemloop, %itemfields);
292
293 my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
294 if ( $mss->count ) {
295     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
296 }
297 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
298 if ( $mss->count ) {
299     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
300 }
301 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
302 if ( $mss->count ) {
303     $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
304 }
305
306 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
307 my %materials_map;
308 if ($mss->count) {
309     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
310     if ($materials_authvals) {
311         foreach my $value (@$materials_authvals) {
312             $materials_map{$value->{authorised_value}} = $value->{lib};
313         }
314     }
315 }
316
317 my $analytics_flag;
318 my $materials_flag; # set this if the items have anything in the materials field
319 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
320 if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
321     $template->param(SeparateHoldings => 1);
322 }
323 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
324 my ( $itemloop_has_images, $otheritemloop_has_images );
325 foreach my $item (@items) {
326     my $itembranchcode = $item->{$separatebranch};
327
328     $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
329                                                : '';
330
331     $item->{datedue} = format_sqldatetime($item->{datedue});
332
333     #get shelf location and collection code description if they are authorised value.
334     # same thing for copy number
335     my $shelfcode = $item->{'location'};
336     $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
337     my $ccode = $item->{'ccode'};
338     $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
339     my $copynumber = $item->{'copynumber'};
340     $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) );
341     foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri publisheddate)) { # Warning when removing GetItemsInfo - publisheddate (at least) is not part of the items table
342         $itemfields{$_} = 1 if ( $item->{$_} );
343     }
344
345     # checking for holds
346     my $item_object = Koha::Items->find( $item->{itemnumber} );
347     my $holds = $item_object->current_holds;
348     if ( my $first_hold = $holds->next ) {
349         $item->{first_hold} = $first_hold;
350     }
351
352     if ( my $checkout = $item_object->checkout ) {
353         $item->{CheckedOutFor} = $checkout->patron;
354     }
355
356     # Check the transit status
357     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
358     if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
359         $item->{transfertwhen} = $transfertwhen;
360         $item->{transfertfrom} = $transfertfrom;
361         $item->{transfertto}   = $transfertto;
362         $item->{nocancel} = 1;
363     }
364
365     foreach my $f (qw( itemnotes )) {
366         if ($item->{$f}) {
367             $item->{$f} =~ s|\n|<br />|g;
368             $itemfields{$f} = 1;
369         }
370     }
371
372     #item has a host number if its biblio number does not match the current bib
373
374     if ($item->{biblionumber} ne $biblionumber){
375         $item->{hostbiblionumber} = $item->{biblionumber};
376         $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
377     }
378         
379
380     if ( $analyze ) {
381         # count if item is used in analytical bibliorecords
382         # The 'countanalytics' flag is only used in the templates if analyze is set
383         my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
384         if ($countanalytics > 0){
385             $analytics_flag=1;
386             $item->{countanalytics} = $countanalytics;
387         }
388     }
389
390     if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){
391         $materials_flag = 1;
392         if (defined $materials_map{ $item->{materials} }) {
393             $item->{materials} = $materials_map{ $item->{materials} };
394         }
395     }
396
397     if ( C4::Context->preference('UseCourseReserves') ) {
398         $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
399     }
400
401     if ( C4::Context->preference('IndependentBranches') ) {
402         my $userenv = C4::Context->userenv();
403         if ( not C4::Context->IsSuperLibrarian()
404             and $userenv->{branch} ne $item->{homebranch} ) {
405             $item->{cannot_be_edited} = 1;
406         }
407     }
408
409     if ( C4::Context->preference("LocalCoverImages") == 1 ) {
410         $item->{cover_images} = $item_object->cover_images;
411     }
412
413     if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
414         if ($itembranchcode and $itembranchcode eq $currentbranch) {
415             push @itemloop, $item;
416             $itemloop_has_images++ if $item_object->cover_images->count;
417         } else {
418             push @otheritemloop, $item;
419             $otheritemloop_has_images++ if $item_object->cover_images->count;
420         }
421     } else {
422         push @itemloop, $item;
423         $itemloop_has_images++ if $item_object->cover_images->count;
424     }
425 }
426
427 $template->param(
428     itemloop_has_images      => $itemloop_has_images,
429     otheritemloop_has_images => $otheritemloop_has_images,
430 );
431
432 # Display only one tab if one items list is empty
433 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
434     $template->param(SeparateHoldings => 0);
435     if (scalar(@itemloop) == 0) {
436         @itemloop = @otheritemloop;
437     }
438 }
439
440 my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
441     {
442         borrowernumber => $borrowernumber,
443         add_allowed    => 1,
444         category       => 1,
445     }
446 );
447 my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
448     {
449         borrowernumber => $borrowernumber,
450         add_allowed    => 1,
451         category       => 2,
452     }
453 );
454
455
456 $template->param(
457     add_to_some_private_shelves => $some_private_shelves,
458     add_to_some_public_shelves  => $some_public_shelves,
459 );
460
461 $template->param(
462     MARCNOTES   => $marcnotesarray,
463     itemdata_ccode      => $itemfields{ccode},
464     itemdata_enumchron  => $itemfields{enumchron},
465     itemdata_uri        => $itemfields{uri},
466     itemdata_copynumber => $itemfields{copynumber},
467     itemdata_stocknumber => $itemfields{stocknumber},
468     itemdata_publisheddate => $itemfields{publisheddate},
469     volinfo                => $itemfields{enumchron},
470         itemdata_itemnotes  => $itemfields{itemnotes},
471         itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic},
472     z3950_search_params    => C4::Search::z3950_search_args($dat),
473         hostrecords         => $hostrecords,
474     analytics_flag    => $analytics_flag,
475     C4::Search::enabled_staff_search_views,
476         materials       => $materials_flag,
477 );
478
479 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
480     my $fieldspec = C4::Context->preference("AlternateHoldingsField");
481     my $subfields = substr $fieldspec, 3;
482     my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
483     my @alternateholdingsinfo = ();
484     my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
485
486     for my $field (@holdingsfields) {
487         my %holding = ( holding => '' );
488         my $havesubfield = 0;
489         for my $subfield ($field->subfields()) {
490             if ((index $subfields, $$subfield[0]) >= 0) {
491                 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
492                 $holding{'holding'} .= $$subfield[1];
493                 $havesubfield++;
494             }
495         }
496         if ($havesubfield) {
497             push(@alternateholdingsinfo, \%holding);
498         }
499     }
500
501     $template->param(
502         ALTERNATEHOLDINGS   => \@alternateholdingsinfo,
503         );
504 }
505
506 my @results = ( $dat, );
507 foreach ( keys %{$dat} ) {
508     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
509 }
510
511 # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
512 # method query not found?!?!
513 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages"));
514 $template->param(
515     itemloop        => \@itemloop,
516     otheritemloop   => \@otheritemloop,
517     biblionumber        => $biblionumber,
518     ($analyze? 'analyze':'detailview') =>1,
519     subscriptions       => \@subs,
520     subscriptionsnumber => $subscriptionsnumber,
521     subscriptiontitle   => $dat->{title},
522     searchid            => scalar $query->param('searchid'),
523 );
524
525 # Lists
526
527 if (C4::Context->preference("virtualshelves") ) {
528     my $shelves = Koha::Virtualshelves->search(
529         {
530             biblionumber => $biblionumber,
531             category => 2,
532         },
533         {
534             join => 'virtualshelfcontents',
535         }
536     );
537     $template->param( 'shelves' => $shelves );
538 }
539
540 # XISBN Stuff
541 if (C4::Context->preference("FRBRizeEditions")==1) {
542     eval {
543         $template->param(
544             XISBNS => scalar get_xisbns($isbn, $biblionumber)
545         );
546     };
547     if ($@) { warn "XISBN Failed $@"; }
548 }
549
550 if ( C4::Context->preference("LocalCoverImages") == 1 ) {
551     my $images = $biblio->cover_images;
552     $template->param( localimages => $biblio->cover_images );
553 }
554
555 # HTML5 Media
556 if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
557     $template->param( C4::HTML5Media->gethtml5media($record));
558 }
559
560 # Displaying tags
561 my $tag_quantity;
562 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
563     $template->param(
564         TagsEnabled => 1,
565         TagsShowOnDetail => $tag_quantity
566     );
567     $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
568                                 'sort'=>'-weight', limit=>$tag_quantity}));
569 }
570
571 #we only need to pass the number of holds to the template
572 my $holds = $biblio->holds;
573 $template->param( holdcount => $holds->count );
574
575 # Check if there are any ILL requests connected to the biblio
576 my $illrequests =
577     C4::Context->preference('ILLModule')
578   ? Koha::Illrequests->search( { biblio_id => $biblionumber } )
579   : [];
580 $template->param( illrequests => $illrequests );
581
582 my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
583 if ($StaffDetailItemSelection) {
584     # Only enable item selection if user can execute at least one action
585     if (
586         $flags->{superlibrarian}
587         || (
588             ref $flags->{tools} eq 'HASH' && (
589                 $flags->{tools}->{items_batchmod}       # Modify selected items
590                 || $flags->{tools}->{items_batchdel}    # Delete selected items
591             )
592         )
593         || ( ref $flags->{tools} eq '' && $flags->{tools} )
594       )
595     {
596         $template->param(
597             StaffDetailItemSelection => $StaffDetailItemSelection );
598     }
599 }
600
601 # get biblionumbers stored in the cart
602 my @cart_list;
603
604 if($query->cookie("intranet_bib_list")){
605     my $cart_list = $query->cookie("intranet_bib_list");
606     @cart_list = split(/\//, $cart_list);
607     if ( grep {$_ eq $biblionumber} @cart_list) {
608         $template->param( incart => 1 );
609     }
610 }
611
612 if ( C4::Context->preference('UseCourseReserves') ) {
613     my $course_reserves = GetItemCourseReservesInfo( biblionumber => $biblionumber );
614     $template->param( course_reserves => $course_reserves );
615 }
616
617 $template->param(biblio => $biblio);
618
619 output_html_with_http_headers $query, $cookie, $template->output;