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