4efffed9b8404f271ec4f05d4977214925da8668
[srvgit] / catalogue / detail.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
19 use Modern::Perl;
20
21 use CGI qw ( -utf8 );
22 use HTML::Entities;
23 use C4::Auth qw( get_template_and_user );
24 use C4::Context;
25 use C4::Koha qw(
26     GetAuthorisedValues
27     getitemtypeimagelocation
28     GetNormalizedEAN
29     GetNormalizedISBN
30     GetNormalizedOCLCNumber
31     GetNormalizedUPC
32 );
33 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
34 use C4::Output qw( output_html_with_http_headers );
35 use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
36 use C4::Items qw( GetAnalyticsCount GetHostItemsInfo GetItemsInfo );
37 use C4::Circulation qw( GetTransfers );
38 use C4::Reserves;
39 use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials );
40 use C4::XISBN qw( get_xisbns );
41 use C4::External::Amazon qw( get_amazon_tld );
42 use C4::Search qw( z3950_search_args enabled_staff_search_views );
43 use C4::Tags qw( get_tags );
44 use C4::XSLT qw( XSLTParse4Display );
45 use Koha::DateUtils qw( format_sqldatetime );
46 use C4::HTML5Media;
47 use C4::CourseReserves qw( GetItemCourseReservesInfo );
48 use Koha::AuthorisedValues;
49 use Koha::Biblios;
50 use Koha::CoverImages;
51 use Koha::Illrequests;
52 use Koha::Items;
53 use Koha::ItemTypes;
54 use Koha::Patrons;
55 use Koha::Virtualshelves;
56 use Koha::Plugins;
57 use Koha::SearchEngine::Search;
58 use Koha::SearchEngine::QueryBuilder;
59
60 my $query = CGI->new();
61
62 my $analyze = $query->param('analyze');
63
64 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
65     {
66     template_name   =>  'catalogue/detail.tt',
67         query           => $query,
68         type            => "intranet",
69         flagsrequired   => { catalogue => 1 },
70     }
71 );
72
73 # Determine if we should be offering any enhancement plugin buttons
74 if ( C4::Context->config('enable_plugins') ) {
75     # Only pass plugins that can offer a toolbar button
76     my @plugins = Koha::Plugins->new()->GetPlugins({
77         method => 'intranet_catalog_biblio_enhancements_toolbar_button'
78     });
79     $template->param(
80         plugins => \@plugins,
81     );
82 }
83
84 my $biblionumber = $query->param('biblionumber');
85 $biblionumber = HTML::Entities::encode($biblionumber);
86 my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
87 my $biblio = Koha::Biblios->find( $biblionumber );
88 $template->param( 'biblio', $biblio );
89
90 if ( not defined $record ) {
91     # biblionumber invalid -> report and exit
92     $template->param( unknownbiblionumber => 1,
93                       biblionumber => $biblionumber );
94     output_html_with_http_headers $query, $cookie, $template->output;
95     exit;
96 }
97
98 eval { $biblio->metadata->record };
99 $template->param( decoding_error => $@ );
100
101 if($query->cookie("holdfor")){
102     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
103     if ( $holdfor_patron ) {
104         $template->param(
105             # FIXME Should pass the patron object
106             holdfor => $query->cookie("holdfor"),
107             holdfor_surname => $holdfor_patron->surname,
108             holdfor_firstname => $holdfor_patron->firstname,
109             holdfor_cardnumber => $holdfor_patron->cardnumber,
110         );
111     }
112 }
113
114 if($query->cookie("searchToOrder")){
115     my ( $basketno, $vendorid ) = split( /\//, $query->cookie("searchToOrder") );
116     $template->param(
117         searchtoorder_basketno => $basketno,
118         searchtoorder_vendorid => $vendorid
119     );
120 }
121
122 my $fw           = GetFrameworkCode($biblionumber);
123 my $showallitems = $query->param('showallitems');
124 my $marcflavour  = C4::Context->preference("marcflavour");
125
126 {
127     # XSLT processing of some stuff
128
129     my $searcher = Koha::SearchEngine::Search->new(
130         { index => $Koha::SearchEngine::BIBLIOS_INDEX }
131     );
132     my $builder = Koha::SearchEngine::QueryBuilder->new(
133         { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
134
135     my $cleaned_title = $biblio->title;
136     $cleaned_title =~ tr|/||;
137     $cleaned_title = $builder->clean_search_term($cleaned_title);
138
139     my $query =
140       ( C4::Context->preference('UseControlNumber') and $record->field('001') )
141       ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
142       : "Host-item:($cleaned_title)";
143     my ( $err, $result, $count );
144     eval {
145         ( $err, $result, $count ) =
146           $searcher->simple_search_compat( $query, 0, 0 );
147
148     };
149     if ($err || $@){
150         warn "Warning from simple_search_compat: $err.$@";
151         $template->param( analytics_error => 1 );
152     }
153
154     my $variables = {
155         show_analytics_link => $count > 0 ? 1 : 0
156     };
157
158     $template->param(
159         XSLTDetailsDisplay => '1',
160         XSLTBloc => XSLTParse4Display(
161             {
162                 biblionumber   => $biblionumber,
163                 record         => $record,
164                 xsl_syspref    => "XSLTDetailsDisplay",
165                 fix_amps       => 1,
166                 xslt_variables => $variables
167             }
168         ),
169     );
170 }
171
172 $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
173
174 # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
175 # Do not propagate it as we already deal with it previously in this script
176 my $coins = eval { $biblio->get_coins };
177 $template->param( ocoins => $coins );
178
179 # some useful variables for enhanced content;
180 # in each case, we're grabbing the first value we find in
181 # the record and normalizing it
182 my $upc = GetNormalizedUPC($record,$marcflavour);
183 my $ean = GetNormalizedEAN($record,$marcflavour);
184 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
185 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
186
187 $template->param(
188     normalized_upc => $upc,
189     normalized_ean => $ean,
190     normalized_oclc => $oclc,
191     normalized_isbn => $isbn,
192 );
193
194 my $marcnotesarray   = $biblio->get_marc_notes({ marcflavour => $marcflavour });
195
196 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
197
198 my $dbh = C4::Context->dbh;
199
200 my @all_items = GetItemsInfo( $biblionumber );
201 my @items;
202 my $patron = Koha::Patrons->find( $borrowernumber );
203 for my $itm (@all_items) {
204     push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems);
205 }
206
207 # flag indicating existence of at least one item linked via a host record
208 my $hostrecords;
209 # adding items linked via host biblios
210 my @hostitems = GetHostItemsInfo($record);
211 if (@hostitems){
212     $hostrecords =1;
213     push (@items,@hostitems);
214 }
215
216 my $dat = &GetBiblioData($biblionumber);
217
218 #coping with subscriptions
219 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
220 my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
221 my @subs;
222
223 foreach my $subscription (@subscriptions) {
224     my %cell;
225     my $serials_to_display;
226     $cell{subscriptionid}    = $subscription->{subscriptionid};
227     $cell{subscriptionnotes} = $subscription->{internalnotes};
228     $cell{missinglist}       = $subscription->{missinglist};
229     $cell{librariannote}     = $subscription->{librariannote};
230     $cell{branchcode}        = $subscription->{branchcode};
231     $cell{hasalert}          = $subscription->{hasalert};
232     $cell{callnumber}        = $subscription->{callnumber};
233     $cell{location}          = $subscription->{location};
234     $cell{closed}            = $subscription->{closed};
235     #get the three latest serials.
236     $serials_to_display = $subscription->{staffdisplaycount};
237     $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display;
238     $cell{staffdisplaycount} = $serials_to_display;
239     $cell{latestserials} =
240       GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
241     push @subs, \%cell;
242 }
243
244
245 # Get acquisition details
246 if ( C4::Context->preference('AcquisitionDetails') ) {
247     my $orders = Koha::Acquisition::Orders->search(
248         { biblionumber => $biblionumber },
249         {
250             join => 'basketno',
251             order_by => 'basketno.booksellerid'
252         }
253     );    # GetHistory sorted by aqbooksellerid, but does it make sense?
254
255     $template->param(
256         orders => $orders,
257     );
258 }
259
260 if ( C4::Context->preference('suggestion') ) {
261     my $suggestions = Koha::Suggestions->search(
262         {
263             biblionumber => $biblionumber,
264             archived     => 0,
265         },
266         {
267             order_by => { -desc => 'suggesteddate' }
268         }
269     );
270     my $nb_archived_suggestions = Koha::Suggestions->search({ biblionumber => $biblionumber, archived => 1 })->count;
271     $template->param( suggestions => $suggestions, nb_archived_suggestions => $nb_archived_suggestions );
272 }
273
274 if ( defined $dat->{'itemtype'} ) {
275     $dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} );
276 }
277
278 $dat->{'count'} = scalar @all_items + @hostitems;
279 $dat->{'showncount'} = scalar @items + @hostitems;
280 $dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
281
282 my $shelflocations =
283   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
284 my $collections =
285   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
286 my $copynumbers =
287   { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
288 my (@itemloop, @otheritemloop, %itemfields);
289
290 my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
291 if ( $mss->count ) {
292     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
293 }
294 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
295 if ( $mss->count ) {
296     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
297 }
298 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
299 if ( $mss->count ) {
300     $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
301 }
302
303 $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
304 my %materials_map;
305 if ($mss->count) {
306     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
307     if ($materials_authvals) {
308         foreach my $value (@$materials_authvals) {
309             $materials_map{$value->{authorised_value}} = $value->{lib};
310         }
311     }
312 }
313
314 my $analytics_flag;
315 my $materials_flag; # set this if the items have anything in the materials field
316 my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef;
317 if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
318     $template->param(SeparateHoldings => 1);
319 }
320 my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch';
321 my ( $itemloop_has_images, $otheritemloop_has_images );
322 foreach my $item (@items) {
323     my $itembranchcode = $item->{$separatebranch};
324
325     $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
326                                                : '';
327
328     $item->{datedue} = format_sqldatetime($item->{datedue});
329
330     #get shelf location and collection code description if they are authorised value.
331     # same thing for copy number
332     my $shelfcode = $item->{'location'};
333     $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
334     my $ccode = $item->{'ccode'};
335     $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
336     my $copynumber = $item->{'copynumber'};
337     $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) );
338     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
339         $itemfields{$_} = 1 if ( $item->{$_} );
340     }
341
342     # checking for holds
343     my $item_object = Koha::Items->find( $item->{itemnumber} );
344     my $holds = $item_object->current_holds;
345     if ( my $first_hold = $holds->next ) {
346         $item->{first_hold} = $first_hold;
347     }
348
349     if ( my $checkout = $item_object->checkout ) {
350         $item->{CheckedOutFor} = $checkout->patron;
351     }
352
353     # Check the transit status
354     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
355     if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
356         $item->{transfertwhen} = $transfertwhen;
357         $item->{transfertfrom} = $transfertfrom;
358         $item->{transfertto}   = $transfertto;
359         $item->{nocancel} = 1;
360     }
361
362     foreach my $f (qw( itemnotes )) {
363         if ($item->{$f}) {
364             $item->{$f} =~ s|\n|<br />|g;
365             $itemfields{$f} = 1;
366         }
367     }
368
369     #item has a host number if its biblio number does not match the current bib
370
371     if ($item->{biblionumber} ne $biblionumber){
372         $item->{hostbiblionumber} = $item->{biblionumber};
373         $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
374     }
375         
376
377     if ( $analyze ) {
378         # count if item is used in analytical bibliorecords
379         # The 'countanalytics' flag is only used in the templates if analyze is set
380         my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
381         if ($countanalytics > 0){
382             $analytics_flag=1;
383             $item->{countanalytics} = $countanalytics;
384         }
385     }
386
387     if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){
388         $materials_flag = 1;
389         if (defined $materials_map{ $item->{materials} }) {
390             $item->{materials} = $materials_map{ $item->{materials} };
391         }
392     }
393
394     if ( C4::Context->preference('UseCourseReserves') ) {
395         $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} );
396     }
397
398     if ( C4::Context->preference('IndependentBranches') ) {
399         my $userenv = C4::Context->userenv();
400         if ( not C4::Context->IsSuperLibrarian()
401             and $userenv->{branch} ne $item->{homebranch} ) {
402             $item->{cannot_be_edited} = 1;
403         }
404     }
405
406     if ( C4::Context->preference("LocalCoverImages") == 1 ) {
407         $item->{cover_images} = $item_object->cover_images;
408     }
409
410     if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
411         if ($itembranchcode and $itembranchcode eq $currentbranch) {
412             push @itemloop, $item;
413             $itemloop_has_images++ if $item_object->cover_images->count;
414         } else {
415             push @otheritemloop, $item;
416             $otheritemloop_has_images++ if $item_object->cover_images->count;
417         }
418     } else {
419         push @itemloop, $item;
420         $itemloop_has_images++ if $item_object->cover_images->count;
421     }
422 }
423
424 $template->param(
425     itemloop_has_images      => $itemloop_has_images,
426     otheritemloop_has_images => $otheritemloop_has_images,
427 );
428
429 # Display only one tab if one items list is empty
430 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
431     $template->param(SeparateHoldings => 0);
432     if (scalar(@itemloop) == 0) {
433         @itemloop = @otheritemloop;
434     }
435 }
436
437 my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
438     {
439         borrowernumber => $borrowernumber,
440         add_allowed    => 1,
441         category       => 1,
442     }
443 );
444 my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
445     {
446         borrowernumber => $borrowernumber,
447         add_allowed    => 1,
448         category       => 2,
449     }
450 );
451
452
453 $template->param(
454     add_to_some_private_shelves => $some_private_shelves,
455     add_to_some_public_shelves  => $some_public_shelves,
456 );
457
458 $template->param(
459     MARCNOTES   => $marcnotesarray,
460     itemdata_ccode      => $itemfields{ccode},
461     itemdata_enumchron  => $itemfields{enumchron},
462     itemdata_uri        => $itemfields{uri},
463     itemdata_copynumber => $itemfields{copynumber},
464     itemdata_stocknumber => $itemfields{stocknumber},
465     itemdata_publisheddate => $itemfields{publisheddate},
466     volinfo                => $itemfields{enumchron},
467         itemdata_itemnotes  => $itemfields{itemnotes},
468         itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic},
469     z3950_search_params    => C4::Search::z3950_search_args($dat),
470         hostrecords         => $hostrecords,
471     analytics_flag    => $analytics_flag,
472     C4::Search::enabled_staff_search_views,
473         materials       => $materials_flag,
474 );
475
476 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
477     my $fieldspec = C4::Context->preference("AlternateHoldingsField");
478     my $subfields = substr $fieldspec, 3;
479     my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
480     my @alternateholdingsinfo = ();
481     my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
482
483     for my $field (@holdingsfields) {
484         my %holding = ( holding => '' );
485         my $havesubfield = 0;
486         for my $subfield ($field->subfields()) {
487             if ((index $subfields, $$subfield[0]) >= 0) {
488                 $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0);
489                 $holding{'holding'} .= $$subfield[1];
490                 $havesubfield++;
491             }
492         }
493         if ($havesubfield) {
494             push(@alternateholdingsinfo, \%holding);
495         }
496     }
497
498     $template->param(
499         ALTERNATEHOLDINGS   => \@alternateholdingsinfo,
500         );
501 }
502
503 my @results = ( $dat, );
504 foreach ( keys %{$dat} ) {
505     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
506 }
507
508 # does not work: my %views_enabled = map { $_ => 1 } $template->query(loop => 'EnableViews');
509 # method query not found?!?!
510 $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages"));
511 $template->param(
512     itemloop        => \@itemloop,
513     otheritemloop   => \@otheritemloop,
514     biblionumber        => $biblionumber,
515     ($analyze? 'analyze':'detailview') =>1,
516     subscriptions       => \@subs,
517     subscriptionsnumber => $subscriptionsnumber,
518     subscriptiontitle   => $dat->{title},
519     searchid            => scalar $query->param('searchid'),
520 );
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 if ( C4::Context->preference('UseCourseReserves') ) {
610     my $course_reserves = GetItemCourseReservesInfo( biblionumber => $biblionumber );
611     $template->param( course_reserves => $course_reserves );
612 }
613
614 $template->param(biblio => $biblio);
615
616 output_html_with_http_headers $query, $cookie, $template->output;