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