Merge remote-tracking branch 'kc/new/bug_5995' into kcmaster
[koha.git] / reserve / request.pl
1 #!/usr/bin/perl
2
3
4 #writen 2/1/00 by chris@katipo.oc.nz
5 # Copyright 2000-2002 Katipo Communications
6 # Parts Copyright 2011 Catalyst IT
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23 =head1 request.pl
24
25 script to place reserves/requests
26
27 =cut
28
29 use strict;
30 use warnings;
31 use C4::Branch; # GetBranches get_branchinfos_of
32 use CGI;
33 use List::MoreUtils qw/uniq/;
34 use Date::Calc qw/Date_to_Days/;
35 use C4::Output;
36 use C4::Auth;
37 use C4::Reserves;
38 use C4::Biblio;
39 use C4::Items;
40 use C4::Koha;
41 use C4::Circulation;
42 use C4::Dates qw/format_date/;
43 use C4::Members;
44 use C4::Search;         # enabled_staff_search_views
45
46 my $dbh = C4::Context->dbh;
47 my $sth;
48 my $input = new CGI;
49 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
50     {
51         template_name   => "reserve/request.tmpl",
52         query           => $input,
53         type            => "intranet",
54         authnotrequired => 0,
55         flagsrequired   => { reserveforothers => 'place_holds' },
56     }
57 );
58
59 my $multihold = $input->param('multi_hold');
60 $template->param(multi_hold => $multihold);
61 my $showallitems = $input->param('showallitems');
62
63 # get Branches and Itemtypes
64 my $branches = GetBranches();
65 my $itemtypes = GetItemTypes();
66
67 my $default = C4::Context->userenv->{branch};
68 my @values;
69 my %label_of;
70
71 foreach my $branchcode (sort keys %{$branches} ) {
72     push @values, $branchcode;
73     $label_of{$branchcode} = $branches->{$branchcode}->{branchname};
74 }
75 my $CGIbranch = CGI::scrolling_list(
76                                     -name     => 'pickup',
77                                     -id          => 'pickup',
78                                     -values   => \@values,
79                                     -default  => $default,
80                                     -labels   => \%label_of,
81                                     -size     => 1,
82                                     -multiple => 0,
83                                    );
84
85 # Select borrowers infos
86 my $findborrower = $input->param('findborrower');
87 $findborrower = '' unless defined $findborrower;
88 $findborrower =~ s|,| |g;
89 my $borrowernumber_hold = $input->param('borrowernumber') || '';
90 my $borrowerslist;
91 my $messageborrower;
92 my $warnings;
93 my $messages;
94
95 my $date = C4::Dates->today('iso');
96 my $action = $input->param('action');
97 $action ||= q{};
98
99 if ( $action eq 'move' ) {
100   my $where = $input->param('where');
101   my $borrowernumber = $input->param('borrowernumber');
102   my $biblionumber = $input->param('biblionumber');
103   AlterPriority( $where, $borrowernumber, $biblionumber );
104 } elsif ( $action eq 'cancel' ) {
105   my $borrowernumber = $input->param('borrowernumber');
106   my $biblionumber = $input->param('biblionumber');
107   CancelReserve( $biblionumber, '', $borrowernumber );
108 } elsif ( $action eq 'setLowestPriority' ) {
109   my $borrowernumber = $input->param('borrowernumber');
110   my $biblionumber   = $input->param('biblionumber');
111   ToggleLowestPriority( $borrowernumber, $biblionumber );
112 }
113
114 if ($findborrower) {
115     my ( $count, $borrowers ) =
116       SearchMember($findborrower, 'cardnumber', 'web' );
117
118     my @borrowers = @$borrowers;
119
120     if ( !@borrowers ) {
121         $messageborrower = "'$findborrower'";
122     }
123     elsif ( @borrowers == 1 ) {
124         $borrowernumber_hold = $borrowers[0]->{'borrowernumber'};
125     }
126     else {
127         $borrowerslist = \@borrowers;
128     }
129 }
130
131 # If we have the borrowernumber because we've performed an action, then we
132 # don't want to try to place another reserve.
133 if ($borrowernumber_hold && !$action) {
134     my $borrowerinfo = GetMemberDetails( $borrowernumber_hold );
135     my $diffbranch;
136     my @getreservloop;
137     my $count_reserv = 0;
138     my $maxreserves;
139
140 #   we check the reserves of the borrower, and if he can reserv a document
141 # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
142
143     my $number_reserves =
144       GetReserveCount( $borrowerinfo->{'borrowernumber'} );
145
146     if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) {
147                 $warnings = 1;
148         $maxreserves = 1;
149     }
150
151     # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
152     my $expiry_date = $borrowerinfo->{dateexpiry};
153     my $expiry = 0; # flag set if patron account has expired
154     if ($expiry_date and $expiry_date ne '0000-00-00' and
155             Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
156                 $messages = $expiry = 1;
157     }
158
159     # check if the borrower make the reserv in a different branch
160     if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
161                 $messages = 1;
162         $diffbranch = 1;
163     }
164
165     $template->param(
166                 borrowernumber      => $borrowerinfo->{'borrowernumber'},
167                 borrowersurname     => $borrowerinfo->{'surname'},
168                 borrowerfirstname   => $borrowerinfo->{'firstname'},
169                 borrowerstreetaddress   => $borrowerinfo->{'address'},
170                 borrowercity        => $borrowerinfo->{'city'},
171                 borrowerphone       => $borrowerinfo->{'phone'},
172                 borrowermobile      => $borrowerinfo->{'mobile'},
173                 borrowerfax         => $borrowerinfo->{'fax'},
174                 borrowerphonepro    => $borrowerinfo->{'phonepro'},
175                 borroweremail       => $borrowerinfo->{'email'},
176                 borroweremailpro    => $borrowerinfo->{'emailpro'},
177                 borrowercategory    => $borrowerinfo->{'category'},
178                 borrowerreservs     => $count_reserv,
179                 cardnumber          => $borrowerinfo->{'cardnumber'},
180                 maxreserves         => $maxreserves,
181                 expiry              => $expiry,
182                 diffbranch          => $diffbranch,
183                                 messages            => $messages,
184                                 warnings            => $warnings
185     );
186 }
187
188 $template->param( messageborrower => $messageborrower );
189
190 my $CGIselectborrower;
191 if ($borrowerslist) {
192     my @values;
193     my %labels;
194
195     foreach my $borrower (
196         sort {
197                 $a->{surname}
198               . $a->{firstname} cmp $b->{surname}
199               . $b->{firstname}
200         } @{$borrowerslist}
201       )
202     {
203         push @values, $borrower->{borrowernumber};
204
205         $labels{ $borrower->{borrowernumber} } = sprintf(
206             '%s, %s ... (%s - %s) ... %s',
207             $borrower->{surname} ||'',    $borrower->{firstname} || '',
208             $borrower->{cardnumber} || '', $borrower->{categorycode} || '',
209             $borrower->{address} || '',
210         );
211     }
212
213     $CGIselectborrower = CGI::scrolling_list(
214         -name     => 'borrowernumber',
215         -values   => \@values,
216         -labels   => \%labels,
217         -size     => 7,
218         -multiple => 0,
219     );
220 }
221
222 # FIXME launch another time GetMemberDetails perhaps until
223 my $borrowerinfo = GetMemberDetails( $borrowernumber_hold );
224
225 my @biblionumbers = ();
226 my $biblionumbers = $input->param('biblionumbers');
227 if ($multihold) {
228     @biblionumbers = split '/', $biblionumbers;
229 } else {
230     push @biblionumbers, $input->param('biblionumber');
231 }
232
233 my $itemdata_enumchron = 0;
234 my @biblioloop = ();
235 foreach my $biblionumber (@biblionumbers) {
236
237     my %biblioloopiter = ();
238         my $maxreserves;
239
240     my $dat          = GetBiblioData($biblionumber);
241
242     unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) {
243                 $warnings = 1;
244         $maxreserves = 1;
245     }
246     # get existing reserves .....
247     my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
248     my $totalcount = $count;
249     my $alreadyreserved;
250
251     foreach my $res (@$reserves) {
252         if ( defined $res->{found} && $res->{found} eq 'W' ) {
253             $count--;
254         }
255
256         if ( defined $borrowerinfo && ($borrowerinfo->{borrowernumber} eq $res->{borrowernumber}) ) {
257             $warnings = 1;
258             $alreadyreserved = 1;
259             $biblioloopiter{warn} = 1;
260             $biblioloopiter{alreadyres} = 1;
261         }
262     }
263
264     $template->param( alreadyreserved => $alreadyreserved,
265                       messages => $messages,
266                       warnings => $warnings,
267                                           maxreserves=>$maxreserves
268                                           );
269
270
271     # FIXME think @optionloop, is maybe obsolete, or  must be switchable by a systeme preference fixed rank or not
272     # make priorities options
273
274     my @optionloop;
275     for ( 1 .. $count + 1 ) {
276         push(
277              @optionloop,
278              {
279               num      => $_,
280               selected => ( $_ == $count + 1 ),
281              }
282             );
283     }
284     # adding a fixed value for priority options
285     my $fixedRank = $count+1;
286
287     my @branchcodes;
288     my %itemnumbers_of_biblioitem;
289     my @itemnumbers;
290
291     ## $items is array of 'item' table numbers
292     if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){
293         @itemnumbers  = @$items;
294     }
295         my @hostitems = get_hostitemnumbers_of($biblionumber);
296         if (@hostitems){
297                 $template->param('hostitemsflag' => 1);
298                 push(@itemnumbers, @hostitems);
299         }
300
301     if (!@itemnumbers) {
302         $template->param('noitems' => 1);
303         $biblioloopiter{noitems} = 1;
304     }
305
306     ## Hash of item number to 'item' table fields
307     my $iteminfos_of = GetItemInfosOf(@itemnumbers);
308
309     ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
310     ## when by definition all of the itemnumber have the same biblioitemnumber
311     foreach my $itemnumber (@itemnumbers) {
312         my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber};
313         push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
314     }
315
316     ## Should be same as biblionumber
317     my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
318
319     my $notforloan_label_of = get_notforloan_label_of();
320
321     ## Hash of biblioitemnumber to 'biblioitem' table records
322     my $biblioiteminfos_of  = GetBiblioItemInfosOf(@biblioitemnumbers);
323
324     my @bibitemloop;
325
326     foreach my $biblioitemnumber (@biblioitemnumbers) {
327         my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
328         my $num_available = 0;
329         my $num_override  = 0;
330         my $hiddencount   = 0;
331
332         $biblioitem->{description} =
333           $itemtypes->{ $biblioitem->{itemtype} }{description};
334         if($biblioitem->{biblioitemnumber} ne $biblionumber){
335                 $biblioitem->{hostitemsflag}=1;
336         }
337         $biblioloopiter{description} = $biblioitem->{description};
338         $biblioloopiter{itypename} = $biblioitem->{description};
339         $biblioloopiter{imageurl} =
340           getitemtypeimagelocation('intranet', $itemtypes->{$biblioitem->{itemtype}}{imageurl});
341
342         foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } )    {
343             my $item = $iteminfos_of->{$itemnumber};
344
345             unless (C4::Context->preference('item-level_itypes')) {
346                 $item->{itype} = $biblioitem->{itemtype};
347             }
348
349             $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
350             $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
351             $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
352
353             # if the holdingbranch is different than the homebranch, we show the
354             # holdingbranch of the document too
355             if ( $item->{homebranch} ne $item->{holdingbranch} ) {
356                 $item->{holdingbranchname} =
357                   $branches->{ $item->{holdingbranch} }{branchname};
358             }
359
360                 if($item->{biblionumber} ne $biblionumber){
361                         $item->{hostitemsflag}=1;
362                         $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
363                 }
364                 
365             #   add information
366             $item->{itemcallnumber} = $item->{itemcallnumber};
367
368             # if the item is currently on loan, we display its return date and
369             # change the background color
370             my $issues= GetItemIssue($itemnumber);
371             if ( $issues->{'date_due'} ) {
372                 $item->{date_due} = format_date($issues->{'date_due'});
373                 $item->{backgroundcolor} = 'onloan';
374             }
375
376             # checking reserve
377             my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemnumber);
378             my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
379
380             if ( defined $reservedate ) {
381                 $item->{backgroundcolor} = 'reserved';
382                 $item->{reservedate}     = format_date($reservedate);
383                 $item->{ReservedForBorrowernumber}     = $reservedfor;
384                 $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
385                 $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
386                 $item->{ExpectedAtLibrary}     = $branches->{$expectedAt}{branchname};
387
388             }
389
390             # Management of the notforloan document
391             if ( $item->{notforloan} ) {
392                 $item->{backgroundcolor} = 'other';
393                 $item->{notforloanvalue} =
394                   $notforloan_label_of->{ $item->{notforloan} };
395             }
396
397             # Management of lost or long overdue items
398             if ( $item->{itemlost} ) {
399
400                 # FIXME localized strings should never be in Perl code
401                 $item->{message} =
402                   $item->{itemlost} == 1 ? "(lost)"
403                     : $item->{itemlost} == 2 ? "(long overdue)"
404                       : "";
405                 $item->{backgroundcolor} = 'other';
406                 if (GetHideLostItemsPreference($borrowernumber) && !$showallitems) {
407                     $item->{hide} = 1;
408                     $hiddencount++;
409                 }
410             }
411
412             # Check the transit status
413             my ( $transfertwhen, $transfertfrom, $transfertto ) =
414               GetTransfers($itemnumber);
415
416             if ( defined $transfertwhen && $transfertwhen ne '' ) {
417                 $item->{transfertwhen} = format_date($transfertwhen);
418                 $item->{transfertfrom} =
419                   $branches->{$transfertfrom}{branchname};
420                 $item->{transfertto} = $branches->{$transfertto}{branchname};
421                 $item->{nocancel} = 1;
422             }
423
424             # If there is no loan, return and transfer, we show a checkbox.
425             $item->{notforloan} = $item->{notforloan} || 0;
426
427             # if independent branches is on we need to check if the person can reserve
428             # for branches they arent logged in to
429             if ( C4::Context->preference("IndependantBranches") ) {
430                 if (! C4::Context->preference("canreservefromotherbranches")){
431                     # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
432                     my $userenv = C4::Context->userenv;
433                     if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
434                         $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
435                     }
436                 }
437             }
438
439             my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
440
441             my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
442             my $policy_holdallowed = 1;
443
444             $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
445
446             if ( $branchitemrule->{'holdallowed'} == 0 ||
447                  ( $branchitemrule->{'holdallowed'} == 1 &&
448                      $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
449                 $policy_holdallowed = 0;
450             }
451             
452             if (
453                    $policy_holdallowed
454                 && !$item->{cantreserve}
455                 && IsAvailableForItemLevelRequest($itemnumber)
456                 && CanItemBeReserved(
457                     $borrowerinfo->{borrowernumber}, $itemnumber
458                 )
459               )
460             {
461                 $item->{available} = 1;
462                 $num_available++;
463             }
464             elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
465
466 # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
467                 $item->{override} = 1;
468                 $num_override++;
469             }
470
471             # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
472
473             # FIXME: move this to a pm
474             my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
475             $sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
476             while (my $wait_hashref = $sth2->fetchrow_hashref) {
477                 $item->{waitingdate} = format_date($wait_hashref->{waitingdate});
478             }
479
480             # Show serial enumeration when needed
481             if ($item->{enumchron}) {
482                 $itemdata_enumchron = 1;
483             }
484
485             push @{ $biblioitem->{itemloop} }, $item;
486         }
487
488         if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override
489             $template->param( override_required => 1 );
490         } elsif ( $num_available == 0 ) {
491             $template->param( none_available => 1 );
492             $template->param( warnings => 1 );
493             $biblioloopiter{warn} = 1;
494             $biblioloopiter{none_avail} = 1;
495         }
496         $template->param( hiddencount => $hiddencount);
497
498         push @bibitemloop, $biblioitem;
499     }
500
501     # existingreserves building
502     my @reserveloop;
503     ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
504     foreach my $res ( sort {
505             my $a_found = $a->{found} || '';
506             my $b_found = $a->{found} || '';
507             $a_found cmp $b_found;
508         } @$reserves ) {
509         my %reserve;
510         my @optionloop;
511         for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
512             push(
513                  @optionloop,
514                  {
515                   num      => $i,
516                   selected => ( $i == $res->{priority} ),
517                  }
518                 );
519         }
520
521         if ( defined $res->{'found'} && $res->{'found'} eq 'W' || $res->{'found'} eq 'T' ) {
522             my $item = $res->{'itemnumber'};
523             $item = GetBiblioFromItemNumber($item,undef);
524             $reserve{'wait'}= 1;
525             $reserve{'holdingbranch'}=$item->{'holdingbranch'};
526             $reserve{'biblionumber'}=$item->{'biblionumber'};
527             $reserve{'barcodenumber'}   = $item->{'barcode'};
528             $reserve{'wbrcode'} = $res->{'branchcode'};
529             $reserve{'itemnumber'}  = $res->{'itemnumber'};
530             $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
531             if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
532                 $reserve{'atdestination'} = 1;
533             }
534             # set found to 1 if reserve is waiting for patron pickup
535             $reserve{'found'} = 1 if $res->{'found'} eq 'W';
536             $reserve{'intransit'} = 1 if $res->{'found'} eq 'T';
537         } elsif ($res->{priority} > 0) {
538             if (defined($res->{itemnumber})) {
539                 my $item = GetItem($res->{itemnumber});
540                 $reserve{'itemnumber'}  = $res->{'itemnumber'};
541                 $reserve{'barcodenumber'}   = $item->{'barcode'};
542                 $reserve{'item_level_hold'} = 1;
543             }
544         }
545
546         #     get borrowers reserve info
547         my $reserveborrowerinfo = GetMemberDetails( $res->{'borrowernumber'}, 0);
548         if (C4::Context->preference('HidePatronName')){
549             $reserve{'hidename'} = 1;
550             $reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
551         }
552         $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} )
553             unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' );
554         $reserve{'date'}           = format_date( $res->{'reservedate'} );
555         $reserve{'borrowernumber'} = $res->{'borrowernumber'};
556         $reserve{'biblionumber'}   = $res->{'biblionumber'};
557         $reserve{'borrowernumber'} = $res->{'borrowernumber'};
558         $reserve{'firstname'}      = $reserveborrowerinfo->{'firstname'};
559         $reserve{'surname'}        = $reserveborrowerinfo->{'surname'};
560         $reserve{'notes'}          = $res->{'reservenotes'};
561         $reserve{'wait'}           =
562           ( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
563         $reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' );
564         $reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' );
565         $reserve{'voldesc'}         = $res->{'volumeddesc'};
566         $reserve{'ccode'}           = $res->{'ccode'};
567         $reserve{'barcode'}         = $res->{'barcode'};
568         $reserve{'priority'}    = $res->{'priority'};
569         $reserve{'lowestPriority'}    = $res->{'lowestPriority'};
570         $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
571         $reserve{'optionloop'} = \@optionloop;
572
573         push( @reserveloop, \%reserve );
574     }
575
576     # get the time for the form name...
577     my $time = time();
578
579     $template->param(
580                      CGIbranch   => $CGIbranch,
581
582                      time        => $time,
583                      fixedRank   => $fixedRank,
584                     );
585
586     # display infos
587     $template->param(
588                      optionloop        => \@optionloop,
589                      bibitemloop       => \@bibitemloop,
590                      itemdata_enumchron => $itemdata_enumchron,
591                      date              => $date,
592                      biblionumber      => $biblionumber,
593                      findborrower      => $findborrower,
594                      title             => $dat->{title},
595                      author            => $dat->{author},
596                      holdsview => 1,
597                      C4::Search::enabled_staff_search_views,
598                     );
599     if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
600         $template->param(
601                      borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
602                      borrower_branchcode => $borrowerinfo->{'branchcode'},
603         );
604     }
605     $template->param(CGIselectborrower => $CGIselectborrower) if defined $CGIselectborrower;
606
607     $biblioloopiter{biblionumber} = $biblionumber;
608     $biblioloopiter{title} = $dat->{title};
609     $biblioloopiter{rank} = $fixedRank;
610     $biblioloopiter{reserveloop} = \@reserveloop;
611
612     if (@reserveloop) {
613         $template->param( reserveloop => \@reserveloop );
614     }
615
616     push @biblioloop, \%biblioloopiter;
617 }
618
619 $template->param( biblioloop => \@biblioloop );
620 $template->param( biblionumbers => $biblionumbers );
621 $template->param( DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar() );
622
623 if ($multihold) {
624     $template->param( multi_hold => 1 );
625 }
626
627 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
628     $template->param( reserve_in_future => 1 );
629 }
630
631 # printout the page
632 output_html_with_http_headers $input, $cookie, $template->output;