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