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