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