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