Bug 24295: Remove GetTransfers from opac-reserve.pl
[koha.git] / opac / opac-reserve.pl
1 #!/usr/bin/perl
2
3
4 # Copyright Katipo Communications 2002
5 # Copyright Koha Development team 2012
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22 use Modern::Perl;
23
24 use CGI qw ( -utf8 );
25 use C4::Auth qw( get_template_and_user );
26 use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
27 use C4::Circulation qw( GetBranchItemRule );
28 use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
29 use C4::Biblio qw( GetBiblioData GetFrameworkCode );
30 use C4::Output qw( output_html_with_http_headers );
31 use C4::Context;
32 use C4::Members;
33 use C4::Overdues;
34
35 use Koha::AuthorisedValues;
36 use Koha::Biblios;
37 use Koha::CirculationRules;
38 use Koha::Items;
39 use Koha::ItemTypes;
40 use Koha::Checkouts;
41 use Koha::Libraries;
42 use Koha::Patrons;
43 use List::MoreUtils qw( uniq );
44
45 my $maxreserves = C4::Context->preference("maxreserves");
46
47 my $query = CGI->new;
48
49 # if OPACHoldRequests (for placing holds) is disabled, leave immediately
50 if ( ! C4::Context->preference('OPACHoldRequests') ) {
51     print $query->redirect("/cgi-bin/koha/errors/404.pl");
52     exit;
53 }
54
55 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
56     {
57         template_name   => "opac-reserve.tt",
58         query           => $query,
59         type            => "opac",
60     }
61 );
62
63 my ($show_holds_count, $show_priority);
64 for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
65     m/holds/o and $show_holds_count = 1;
66     m/priority/ and $show_priority = 1;
67 }
68
69 my $patron = Koha::Patrons->find( $borrowernumber, { prefetch => ['categorycode'] } );
70 my $category = $patron->category;
71
72 my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
73 unless ( $can_place_hold_if_available_at_pickup ) {
74     my @patron_categories = split ',', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
75     if ( @patron_categories ) {
76         my $categorycode = $patron->categorycode;
77         $can_place_hold_if_available_at_pickup = grep { $_ eq $categorycode } @patron_categories;
78     }
79 }
80
81 # check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
82 if ( $category->effective_BlockExpiredPatronOpacActions ) {
83
84     if ( $patron->is_expired ) {
85
86         # cannot reserve, their card has expired and the rules set mean this is not allowed
87         $template->param( message => 1, expired_patron => 1 );
88         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
89         exit;
90     }
91 }
92
93 # Pass through any reserve charge
94 my $reservefee = $category->reservefee;
95 if ( $reservefee > 0){
96     $template->param( RESERVE_CHARGE => $reservefee);
97 }
98
99 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
100
101 # There are two ways of calling this script, with a single biblio num
102 # or multiple biblio nums.
103 my $biblionumbers = $query->param('biblionumbers');
104 my $reserveMode = $query->param('reserve_mode');
105 if ($reserveMode && ($reserveMode eq 'single')) {
106     my $bib = $query->param('single_bib');
107     $biblionumbers = "$bib/";
108 }
109 if (! $biblionumbers) {
110     $biblionumbers = $query->param('biblionumber');
111 }
112
113 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
114     $template->param(message=>1, no_biblionumber=>1);
115     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
116     exit;
117 }
118
119 # Pass the numbers to the page so they can be fed back
120 # when the hold is confirmed. TODO: Not necessary?
121 $template->param( biblionumbers => $biblionumbers );
122
123 # Each biblio number is suffixed with '/', e.g. "1/2/3/"
124 my @biblionumbers = split /\//, $biblionumbers;
125 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
126     # TODO: New message?
127     $template->param(message=>1, no_biblionumber=>1);
128     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
129     exit;
130 }
131
132
133 # pass the pickup branch along....
134 my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
135 $template->param( branch => $branch );
136
137 #
138 #
139 # Build hashes of the requested biblio(item)s and items.
140 #
141 #
142
143 my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
144 foreach my $biblioNumber (@biblionumbers) {
145
146     my $biblioData = GetBiblioData($biblioNumber);
147     $biblioDataHash{$biblioNumber} = $biblioData;
148
149     my $biblio = Koha::Biblios->find( $biblioNumber );
150     next unless $biblio;
151
152     my $marcrecord = $biblio->metadata->record;
153
154     my $items = Koha::Items->search_ordered(
155         [
156             biblionumber => $biblioNumber,
157             'me.itemnumber' => {
158                 -in => [
159                     $biblio->host_items->get_column('itemnumber')
160                 ]
161             }
162         ],
163         { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] }
164     )->filter_by_visible_in_opac({ patron => $patron });
165
166     $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
167
168     # Compute the priority rank.
169     $biblioData->{object} = $biblio;
170     my $holds = $biblio->holds;
171     my $rank = $holds->count;
172     $biblioData->{reservecount} = 1;    # new reserve
173     while ( my $hold = $holds->next ) {
174         if ( $hold->is_waiting ) {
175             $rank--;
176         }
177         else {
178             $biblioData->{reservecount}++;
179         }
180     }
181     $biblioData->{rank} = $rank + 1;
182 }
183
184 #
185 #
186 # If this is the second time through this script, it
187 # means we are carrying out the hold request, possibly
188 # with a specific item for each biblionumber.
189 #
190 #
191 if ( $query->param('place_reserve') ) {
192     my $reserve_cnt = 0;
193     if ($maxreserves) {
194         $reserve_cnt = $patron->holds->count;
195     }
196
197     # List is composed of alternating biblio/item/branch
198     my $selectedItems = $query->param('selecteditems');
199
200     if ($query->param('reserve_mode') eq 'single') {
201         # This indicates non-JavaScript mode, so there was
202         # only a single biblio number selected.
203         my $bib = $query->param('single_bib');
204         my $item = $query->param("checkitem_$bib");
205         if ($item eq 'any') {
206             $item = '';
207         }
208         my $branch = $query->param('branch');
209         $selectedItems = "$bib/$item/$branch/";
210     }
211
212     $selectedItems =~ s!/$!!;
213     my @selectedItems = split /\//, $selectedItems, -1;
214
215     # Make sure there is a biblionum/itemnum/branch triplet for each item.
216     # The itemnum can be 'any', meaning next available.
217     my $selectionCount = @selectedItems;
218     if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
219         $template->param(message=>1, bad_data=>1);
220         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
221         exit;
222     }
223
224     my $failed_holds = 0;
225     while (@selectedItems) {
226         my $biblioNum = shift(@selectedItems);
227         my $itemNum   = shift(@selectedItems);
228         my $branch    = shift(@selectedItems);    # i.e., branch code, not name
229
230         my $canreserve = 0;
231
232         my $singleBranchMode = Koha::Libraries->search->count == 1;
233         if ( $singleBranchMode || ! C4::Context->preference("OPACAllowUserToChooseBranch") )
234         {    # single branch mode or disabled user choosing
235             $branch = $patron->branchcode;
236         }
237
238         # FIXME We shouldn't need to fetch the item here
239         my $item = $itemNum ? Koha::Items->find( $itemNum ) : undef;
240         # When choosing a specific item, the default pickup library should be dictated by the default hold policy
241         if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $item ) {
242             my $type = $item->effective_itemtype;
243             my $rule = GetBranchItemRule( $patron->branchcode, $type );
244
245             if ( $rule->{hold_fulfillment_policy} eq 'any' || $rule->{hold_fulfillment_policy} eq 'patrongroup' ) {
246                 $branch = $patron->branchcode;
247             } elsif ( $rule->{hold_fulfillment_policy} eq 'holdgroup' ){
248                 $branch = $item->homebranch;
249             } else {
250                 my $policy = $rule->{hold_fulfillment_policy};
251                 $branch = $item->$policy;
252             }
253         }
254
255 #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
256         if ( $item ) {
257             my $hostbiblioNum = $item->biblio->biblionumber;
258             if ( $hostbiblioNum ne $biblioNum ) {
259                 $biblioNum = $hostbiblioNum;
260             }
261         }
262
263         my $biblioData = $biblioDataHash{$biblioNum};
264         my $found;
265
266         # Check for user supplied reserve date
267         my $startdate;
268         if (   C4::Context->preference('AllowHoldDateInFuture')
269             && C4::Context->preference('OPACAllowHoldDateInFuture') )
270         {
271             $startdate = $query->param("reserve_date_$biblioNum");
272         }
273
274         my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
275
276         my $itemtype = $query->param('itemtype') || undef;
277         $itemtype = undef if $itemNum;
278
279         my $rank = $biblioData->{rank};
280         my $patron = Koha::Patrons->find( $borrowernumber );
281         if ( $item ) {
282             $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
283         }
284         else {
285             $canreserve = 1
286               if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
287
288             # Inserts a null into the 'itemnumber' field of 'reserves' table.
289             $itemNum = undef;
290         }
291         my $notes = $query->param('notes_'.$biblioNum)||'';
292
293         if (   $maxreserves
294             && $reserve_cnt >= $maxreserves )
295         {
296             $canreserve = 0;
297         }
298
299         unless ( $can_place_hold_if_available_at_pickup ) {
300             my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
301             my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
302             my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } });
303             if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
304                 $canreserve = 0
305             }
306         }
307
308         # Here we actually do the reserveration. Stage 3.
309         if ($canreserve) {
310             my $reserve_id = AddReserve(
311                 {
312                     branchcode       => $branch,
313                     borrowernumber   => $borrowernumber,
314                     biblionumber     => $biblioNum,
315                     priority         => $rank,
316                     reservation_date => $startdate,
317                     expiration_date  => $patron_expiration_date,
318                     notes            => $notes,
319                     title            => $biblioData->{title},
320                     itemnumber       => $itemNum,
321                     found            => $found,
322                     itemtype         => $itemtype,
323                 }
324             );
325             $failed_holds++ unless $reserve_id;
326             ++$reserve_cnt;
327         }
328     }
329
330     print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
331     exit;
332 }
333
334 #
335 #
336 # Here we check that the borrower can actually make reserves Stage 1.
337 #
338 #
339 my $noreserves     = 0;
340 my $maxoutstanding = C4::Context->preference("maxoutstanding");
341 $template->param( noreserve => 1 ) unless $maxoutstanding;
342 my $amountoutstanding = $patron->account->balance;
343 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
344     my $amount = sprintf "%.02f", $amountoutstanding;
345     $template->param( message => 1 );
346     $noreserves = 1;
347     $template->param( too_much_oweing => $amount );
348 }
349
350 if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
351     $noreserves = 1;
352     $template->param(
353         message => 1,
354         GNA     => 1
355     );
356 }
357
358 if ( $patron->lost && ($patron->lost == 1) ) {
359     $noreserves = 1;
360     $template->param(
361         message => 1,
362         lost    => 1
363     );
364 }
365
366 if ( $patron->is_debarred ) {
367     $noreserves = 1;
368     $template->param(
369         message          => 1,
370         debarred         => 1,
371         debarred_comment => $patron->debarredcomment,
372         debarred_date    => $patron->debarred,
373     );
374 }
375
376 my $holds = $patron->holds;
377 my $reserves_count = $holds->count;
378 $template->param( RESERVES => $holds->unblessed );
379 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
380     $template->param( message => 1 );
381     $noreserves = 1;
382     $template->param( too_many_reserves => $holds->count );
383 }
384
385 unless ( $noreserves ) {
386     my $requested_reserves_count = scalar( @biblionumbers );
387     if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
388         $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
389     }
390 }
391
392 unless ($noreserves) {
393     $template->param( select_item_types => 1 );
394 }
395
396
397 #
398 #
399 # Build the template parameters that will show the info
400 # and items for each biblionumber.
401 #
402 #
403
404 my $biblioLoop = [];
405 my $numBibsAvailable = 0;
406 my $itemdata_enumchron = 0;
407 my $itemdata_ccode = 0;
408 my $anyholdable = 0;
409 my $itemLevelTypes = C4::Context->preference('item-level_itypes');
410 my $pickup_locations = Koha::Libraries->search({ pickup_location => 1 });
411 $template->param('item_level_itypes' => $itemLevelTypes);
412
413 my $patron_unblessed = $patron->unblessed;
414 foreach my $biblioNum (@biblionumbers) {
415
416     # Init the bib item with the choices for branch pickup
417     my %biblioLoopIter;
418
419     # Get relevant biblio data.
420     my $biblioData = $biblioDataHash{$biblioNum};
421     if (! $biblioData) {
422         $template->param(message=>1, bad_biblionumber=>$biblioNum);
423         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
424         exit;
425     }
426
427     my @not_available_at = ();
428     my $biblio = $biblioData->{object};
429     foreach my $library ( $pickup_locations->as_list ) {
430         push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to => $library });
431     }
432
433     my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
434     $biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
435     $biblioLoopIter{title} = $biblioData->{title};
436     $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
437     $biblioLoopIter{medium} = $biblioData->{medium};
438     $biblioLoopIter{part_number} = $biblioData->{part_number};
439     $biblioLoopIter{part_name} = $biblioData->{part_name};
440     $biblioLoopIter{author} = $biblioData->{author};
441     $biblioLoopIter{rank} = $biblioData->{rank};
442     $biblioLoopIter{reservecount} = $biblioData->{reservecount};
443     $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
444     $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
445
446     if (!$itemLevelTypes && $biblioData->{itemtype}) {
447         $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
448         $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
449     }
450
451
452
453     $biblioLoopIter{itemLoop} = [];
454     my $numCopiesAvailable = 0;
455     my $numCopiesOPACAvailable = 0;
456     # iterating through all items first to check if any of them available
457     # to pass this value further inside down to IsAvailableForItemLevelRequest to
458     # it's complicated logic to analyse.
459     # (before this loop was inside that sub loop so it was O(n^2) )
460     my $items_any_available;
461     $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron;
462     foreach my $item (@{$biblioData->{items}}) {
463
464         my $item_info = $item->unblessed;
465         $item_info->{holding_branch} = $item->holding_branch;
466         $item_info->{home_branch}    = $item->home_branch;
467         if ($itemLevelTypes) {
468             my $itemtype = $item->itemtype;
469             $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac',
470                 $itemtypes->{ $itemtype->itemtype }->{'imageurl'} );
471             $item_info->{'translated_description'} =
472               $itemtypes->{ $itemtype->itemtype }->{translated_description};
473         }
474
475         # checking for holds
476         my $holds = $item->current_holds;
477         if ( my $first_hold = $holds->next ) {
478             $item_info->{first_hold} = $first_hold;
479         }
480
481         $item_info->{checkout} = $item->checkout;
482
483         # Check of the transferred documents
484         my $transfer = $item->get_transfer;
485         if ( $transfer && $transfer->in_transit ) {
486             $item_info->{transfertwhen} = $transfer->datesent;
487             $item_info->{transfertfrom} = $transfer->frombranch;
488             $item_info->{transfertto} = $transfer->tobranch;
489             $item_info->{nocancel} = 1;
490         }
491
492         # if the items belongs to a host record, show link to host record
493         if ( $item_info->{biblionumber} ne $biblioNum ) {
494             $item_info->{hostbiblionumber} = $item->biblionumber;
495             $item_info->{hosttitle}        = Koha::Biblios->find( $item_info->{biblionumber} )->title;
496         }
497
498         my $branch = GetReservesControlBranch( $item_info, $patron_unblessed );
499
500         # items_any_available defined outside of the current loop,
501         # so we avoiding loop inside IsAvailableForItemLevelRequest:
502         my $policy_holdallowed =
503             CanItemBeReserved( $patron, $item )->{status} eq 'OK' &&
504             IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);
505
506         if ($policy_holdallowed) {
507             my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
508             if ( $opac_hold_policy ne 'N' ) { # If Y or F
509                 $item_info->{available} = 1;
510                 $numCopiesOPACAvailable++;
511                 $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
512             }
513             $numCopiesAvailable++;
514
515             unless ( $can_place_hold_if_available_at_pickup ) {
516                 my $items_in_this_library = Koha::Items->search({ biblionumber => $item->biblionumber, holdingbranch => $item->holdingbranch });
517                 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
518                 if ( $items_in_this_library->count > $nb_of_items_issued ) {
519                     push @not_available_at, $item->holdingbranch;
520                 }
521             }
522         }
523
524         # Show serial enumeration when needed
525         if ($item_info->{enumchron}) {
526             $itemdata_enumchron = 1;
527         }
528         # Show collection when needed
529         if ($item_info->{ccode}) {
530             $itemdata_ccode = 1;
531         }
532
533         push @{$biblioLoopIter{itemLoop}}, $item_info;
534     }
535     $template->param(
536         itemdata_enumchron => $itemdata_enumchron,
537         itemdata_ccode     => $itemdata_ccode,
538     );
539
540     if ($numCopiesAvailable > 0) {
541         $numBibsAvailable++;
542         $biblioLoopIter{bib_available} = 1;
543         $biblioLoopIter{holdable} = 1;
544         $biblioLoopIter{itemholdable} = 1 if $numCopiesOPACAvailable;
545     }
546     if ($biblioLoopIter{already_reserved}) {
547         $biblioLoopIter{holdable} = undef;
548         $biblioLoopIter{itemholdable} = undef;
549     }
550     if ( $biblioLoopIter{holdable} ) {
551         @not_available_at = uniq @not_available_at;
552         $biblioLoopIter{not_available_at} = \@not_available_at ;
553     }
554
555     unless ( $can_place_hold_if_available_at_pickup ) {
556         @not_available_at = uniq @not_available_at;
557         $biblioLoopIter{not_available_at} = \@not_available_at ;
558         # The record is not holdable is not available at any of the libraries
559         if ( Koha::Libraries->search->count == @not_available_at ) {
560             $biblioLoopIter{holdable} = 0;
561         }
562     }
563
564     my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
565     $biblioLoopIter{holdable} &&= $status eq 'OK';
566     $biblioLoopIter{$status} = 1;
567
568     if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
569         # build the allowed item types loop
570         my $rs = $biblio->items->search_ordered(
571             undef,
572             {   select => [ { distinct => 'itype' } ],
573                 as     => 'item_type'
574             }
575         );
576
577         my @item_types =
578           grep { CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $_ } )->{status} eq 'OK' }
579           $rs->get_column('item_type');
580
581         $biblioLoopIter{allowed_item_types} = \@item_types;
582     }
583
584     if ( $status eq 'recall' ) {
585         $biblioLoopIter{recall} = 1;
586     }
587
588     # For multiple holds per record, if a patron has previously placed a hold,
589     # the patron can only place more holds of the same type. That is, if the
590     # patron placed a record level hold, all the holds the patron places must
591     # be record level. If the patron placed an item level hold, all holds
592     # the patron places must be item level
593     my $forced_hold_level = Koha::Holds->search(
594         {
595             borrowernumber => $borrowernumber,
596             biblionumber   => $biblioNum,
597             found          => undef,
598         }
599     )->forced_hold_level();
600     if ($forced_hold_level) {
601         $biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
602         $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
603         $biblioLoopIter{forced_hold_level} = $forced_hold_level;
604     }
605
606
607     push @$biblioLoop, \%biblioLoopIter;
608
609     $anyholdable = 1 if $biblioLoopIter{holdable};
610 }
611
612 unless ($pickup_locations->count) {
613     $numBibsAvailable = 0;
614     $anyholdable = 0;
615     $template->param(
616         message => 1,
617         no_pickup_locations => 1
618     );
619 }
620
621 if ( $numBibsAvailable == 0 || $anyholdable == 0) {
622     $template->param( none_available => 1 );
623 }
624
625 if (scalar @biblionumbers > 1) {
626     $template->param( multi_hold => 1);
627 }
628
629 my $show_notes=C4::Context->preference('OpacHoldNotes');
630 $template->param(OpacHoldNotes=>$show_notes);
631
632 # display infos
633 $template->param(bibitemloop => $biblioLoop);
634 # can set reserve date in future
635 if (
636     C4::Context->preference( 'AllowHoldDateInFuture' ) &&
637     C4::Context->preference( 'OPACAllowHoldDateInFuture' )
638     ) {
639     $template->param(
640             reserve_in_future         => 1,
641     );
642 }
643
644 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };