Merge remote-tracking branch 'origin/new/bug_7412'
[koha.git] / circ / returns.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #           2006 SAN-OP
5 #           2007-2010 BibLibre, Paul POULAIN
6 #           2010 Catalyst IT
7 #           2011 PTFS-Europe Ltd.
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24 =head1 returns.pl
25
26 script to execute returns of books
27
28 =cut
29
30 use strict;
31 use warnings;
32
33 use CGI;
34 use DateTime;
35 use C4::Context;
36 use C4::Auth qw/:DEFAULT get_session/;
37 use C4::Output;
38 use C4::Circulation;
39 use C4::Print;
40 use C4::Reserves;
41 use C4::Biblio;
42 use C4::Items;
43 use C4::Members;
44 use C4::Branch; # GetBranches GetBranchName
45 use C4::Koha;   # FIXME : is it still useful ?
46 use C4::RotatingCollections;
47 use Koha::DateUtils;
48 use Koha::Calendar;
49
50 my $query = new CGI;
51
52 if (!C4::Context->userenv){
53     my $sessionID = $query->cookie("CGISESSID");
54     my $session = get_session($sessionID);
55     if ($session->param('branch') eq 'NO_LIBRARY_SET'){
56         # no branch set we can't return
57         print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
58         exit;
59     }
60
61
62 #getting the template
63 my ( $template, $librarian, $cookie ) = get_template_and_user(
64     {
65         template_name   => "circ/returns.tmpl",
66         query           => $query,
67         type            => "intranet",
68         authnotrequired => 0,
69         flagsrequired   => { circulate => "circulate_remaining_permissions" },
70     }
71 );
72
73 #####################
74 #Global vars
75 my $branches = GetBranches();
76 my $printers = GetPrinters();
77
78 my $printer = C4::Context->userenv ? C4::Context->userenv->{'branchprinter'} : "";
79 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
80
81 my $userenv_branch = C4::Context->userenv->{'branch'} || '';
82 #
83 # Some code to handle the error if there is no branch or printer setting.....
84 #
85
86 # Set up the item stack ....
87 my %returneditems;
88 my %riduedate;
89 my %riborrowernumber;
90 my @inputloop;
91 foreach ( $query->param ) {
92     my $counter;
93     if (/ri-(\d*)/) {
94         $counter = $1;
95         if ($counter > 20) {
96             next;
97         }
98     }
99     else {
100         next;
101     }
102
103     my %input;
104     my $barcode        = $query->param("ri-$counter");
105     my $duedate        = $query->param("dd-$counter");
106     my $borrowernumber = $query->param("bn-$counter");
107     $counter++;
108
109     # decode barcode    ## Didn't we already decode them before passing them back last time??
110     $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
111     $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
112
113     ######################
114     #Are these lines still useful ?
115     $returneditems{$counter}    = $barcode;
116     $riduedate{$counter}        = $duedate;
117     $riborrowernumber{$counter} = $borrowernumber;
118
119     #######################
120     $input{counter}        = $counter;
121     $input{barcode}        = $barcode;
122     $input{duedate}        = $duedate;
123     $input{borrowernumber} = $borrowernumber;
124     push( @inputloop, \%input );
125 }
126
127 ############
128 # Deal with the requests....
129
130 if ($query->param('WT-itemNumber')){
131         updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
132 }
133
134 if ( $query->param('resbarcode') ) {
135     my $item           = $query->param('itemnumber');
136     my $borrowernumber = $query->param('borrowernumber');
137     my $resbarcode     = $query->param('resbarcode');
138     my $diffBranchReturned = $query->param('diffBranch');
139     my $iteminfo   = GetBiblioFromItemNumber($item);
140     # fix up item type for display
141     $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'};
142     my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
143 # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
144 # i.e., whether to apply waiting status
145     ModReserveAffect( $item, $borrowernumber, $diffBranchSend);
146 #   check if we have other reserves for this document, if we have a return send the message of transfer
147     my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
148
149     my ($borr) = GetMemberDetails( $nextreservinfo, 0 );
150     my $name   = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
151     if ( $messages->{'transfert'} ) {
152         $template->param(
153             itemtitle      => $iteminfo->{'title'},
154             itemnumber     => $iteminfo->{'itemnumber'},
155             itembiblionumber => $iteminfo->{'biblionumber'},
156             iteminfo       => $iteminfo->{'author'},
157             tobranchname   => GetBranchName($messages->{'transfert'}),
158             name           => $name,
159             borrowernumber => $borrowernumber,
160             borcnum        => $borr->{'cardnumber'},
161             borfirstname   => $borr->{'firstname'},
162             borsurname     => $borr->{'surname'},
163             diffbranch     => 1,
164         );
165     }
166 }
167
168 my $borrower;
169 my $returned = 0;
170 my $messages;
171 my $issueinformation;
172 my $itemnumber;
173 my $barcode     = $query->param('barcode');
174 my $exemptfine  = $query->param('exemptfine');
175 my $dropboxmode = $query->param('dropboxmode');
176 my $dotransfer  = $query->param('dotransfer');
177 my $canceltransfer = $query->param('canceltransfer');
178 my $dest = $query->param('dest');
179 my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch );
180 #dropbox: get last open day (today - 1)
181 my $today       = DateTime->now( time_zone => C4::Context->tz());
182 my $dropboxdate = $calendar->addDate($today, -1);
183 if ($dotransfer){
184 # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
185     my $transferitem = $query->param('transferitem');
186     my $tobranch     = $query->param('tobranch');
187     ModItemTransfer($transferitem, $userenv_branch, $tobranch); 
188 }
189
190 if ($canceltransfer){
191     $itemnumber=$query->param('itemnumber');
192     DeleteTransfer($itemnumber);
193     if($dest eq "ttr"){
194         print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl");
195         exit;
196     } else {
197         $template->param( transfercancelled => 1);
198     }
199 }
200
201 # actually return book and prepare item table.....
202 if ($barcode) {
203     $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
204     $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
205     $itemnumber = GetItemnumberFromBarcode($barcode);
206
207     if ( C4::Context->preference("InProcessingToShelvingCart") ) {
208         my $item = GetItem( $itemnumber );
209         if ( $item->{'location'} eq 'PROC' ) {
210             $item->{'location'} = 'CART';
211             ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
212         }
213     }
214
215 #
216 # save the return
217 #
218     ( $returned, $messages, $issueinformation, $borrower ) =
219       AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
220     my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
221     $homeorholdingbranchreturn ||= 'homebranch';
222
223     # get biblio description
224     my $biblio = GetBiblioFromItemNumber($itemnumber);
225     # fix up item type for display
226     $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
227
228     $template->param(
229         title            => $biblio->{'title'},
230         homebranch       => $biblio->{'homebranch'},
231         homebranchname   => GetBranchName( $biblio->{$homeorholdingbranchreturn} ),
232         author           => $biblio->{'author'},
233         itembarcode      => $biblio->{'barcode'},
234         itemtype         => $biblio->{'itemtype'},
235         ccode            => $biblio->{'ccode'},
236         itembiblionumber => $biblio->{'biblionumber'},    
237         additional_materials => $biblio->{'materials'}
238     );
239
240     my %input = (
241         counter => 0,
242         first   => 1,
243         barcode => $barcode,
244     );
245
246     if ($returned) {
247         my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
248         my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
249         $returneditems{0}      = $barcode;
250         $riborrowernumber{0}   = $borrower->{'borrowernumber'};
251         $riduedate{0}          = $duedate;
252         $input{borrowernumber} = $borrower->{'borrowernumber'};
253         $input{duedate}        = $duedate;
254         $input{return_overdue} = 1 if (DateTime->compare($issueinformation->{date_due}, $time_now) == -1);
255         push( @inputloop, \%input );
256
257         if ( C4::Context->preference("FineNotifyAtCheckin") ) {
258             my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrower->{'borrowernumber'} );
259             if ($fines > 0) {
260                 $template->param( fines => sprintf("%.2f",$fines) );
261                 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
262             }
263         }
264         
265         if (C4::Context->preference("WaitingNotifyAtCheckin") ) {
266             #Check for waiting holds
267             my @reserves = GetReservesFromBorrowernumber($borrower->{'borrowernumber'});
268             my $waiting_holds;
269             foreach my $num_res (@reserves) {
270                 if ( $num_res->{'found'} eq 'W' && $num_res->{'branchcode'} eq $userenv_branch) {
271                     $waiting_holds++;
272                 }
273             } 
274             if ($waiting_holds > 0) {
275                 $template->param(
276                     waiting_holds       => $waiting_holds,
277                     holdsborrowernumber => $borrower->{'borrowernumber'},
278                     holdsfirstname => $borrower->{'firstname'},
279                     holdssurname => $borrower->{'surname'},
280                 );
281             }
282         }
283     }
284     elsif ( !$messages->{'BadBarcode'} ) {
285         $input{duedate}   = 0;
286         $returneditems{0} = $barcode;
287         $riduedate{0}     = 0;
288         push( @inputloop, \%input );
289     }
290 }
291 $template->param( inputloop => \@inputloop );
292
293 my $found    = 0;
294 my $waiting  = 0;
295 my $reserved = 0;
296
297 # new op dev : we check if the document must be returned to his homebranch directly,
298 #  if the document is transfered, we have warning message .
299
300 if ( $messages->{'WasTransfered'} ) {
301     $template->param(
302         found          => 1,
303         transfer       => 1,
304         itemnumber     => $itemnumber,
305     );
306 }
307
308 if ( $messages->{'NeedsTransfer'} ){
309     $template->param(
310         found          => 1,
311         needstransfer  => 1,
312         itemnumber     => $itemnumber,
313     );
314 }
315
316 if ( $messages->{'Wrongbranch'} ){
317     $template->param(
318         wrongbranch => 1,
319     );
320 }
321
322 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
323
324 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
325     $template->param(
326         WrongTransfer  => 1,
327         TransferWaitingAt => $messages->{'WrongTransfer'},
328         WrongTransferItem => $messages->{'WrongTransferItem'},
329         itemnumber => $itemnumber,
330     );
331
332     my $reserve    = $messages->{'ResFound'};
333     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
334     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
335     my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
336     $template->param(
337             wname           => $name,
338             wborfirstname   => $borr->{'firstname'},
339             wborsurname     => $borr->{'surname'},
340             wbortitle       => $borr->{'title'},
341             wborphone       => $borr->{'phone'},
342             wboremail       => $borr->{'email'},
343             wboraddress     => $borr->{'address'},
344             wboraddress2    => $borr->{'address2'},
345             wborcity        => $borr->{'city'},
346             wborzip         => $borr->{'zipcode'},
347             wborrowernumber => $reserve->{'borrowernumber'},
348             wborcnum        => $borr->{'cardnumber'},
349             wtransfertFrom  => $userenv_branch,
350     );
351 }
352
353 #
354 # reserve found and item arrived at the expected branch
355 #
356 if ( $messages->{'ResFound'}) {
357     my $reserve    = $messages->{'ResFound'};
358     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
359     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
360
361     if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
362         if ( $reserve->{'ResFound'} eq "Waiting" ) {
363             $template->param(
364                 waiting      => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
365             );
366         } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
367             $template->param(
368                 intransit    => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
369                 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
370                 resbarcode   => $barcode,
371                 reserved     => 1,
372             );
373         }
374
375         # same params for Waiting or Reserved
376         $template->param(
377             found          => 1,
378             currentbranch  => $branches->{$userenv_branch}->{'branchname'},
379             destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
380             name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
381             borfirstname   => $borr->{'firstname'},
382             borsurname     => $borr->{'surname'},
383             bortitle       => $borr->{'title'},
384             borphone       => $borr->{'phone'},
385             boremail       => $borr->{'email'},
386             boraddress     => $borr->{'address'},
387             boraddress2    => $borr->{'address2'},
388             borcity        => $borr->{'city'},
389             borzip         => $borr->{'zipcode'},
390             borcnum        => $borr->{'cardnumber'},
391             debarred       => $borr->{'debarred'},
392             gonenoaddress  => $borr->{'gonenoaddress'},
393             barcode        => $barcode,
394             destbranch     => $reserve->{'branchcode'},
395             borrowernumber => $reserve->{'borrowernumber'},
396             itemnumber     => $reserve->{'itemnumber'},
397             reservenotes   => $reserve->{'reservenotes'},
398         );
399     } # else { ; }  # error?
400 }
401
402 # Error Messages
403 my @errmsgloop;
404 foreach my $code ( keys %$messages ) {
405     my %err;
406     my $exit_required_p = 0;
407     if ( $code eq 'BadBarcode' ) {
408         $err{badbarcode} = 1;
409         $err{msg}        = $messages->{'BadBarcode'};
410     }
411     elsif ( $code eq 'NotIssued' ) {
412         $err{notissued} = 1;
413         $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
414     }
415     elsif ( $code eq 'LocalUse' ) {
416         $err{localuse} = 1;
417     }
418     elsif ( $code eq 'WasLost' ) {
419         $err{waslost} = 1;
420     }
421     elsif ( $code eq 'ResFound' ) {
422         ;    # FIXME... anything to do here?
423     }
424     elsif ( $code eq 'WasReturned' ) {
425         ;    # FIXME... anything to do here?
426     }
427     elsif ( $code eq 'WasTransfered' ) {
428         ;    # FIXME... anything to do here?
429     }
430     elsif ( $code eq 'wthdrawn' ) {
431         $err{withdrawn} = 1;
432         $exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
433     }
434     elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
435         if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
436             $err{ispermanent} = 1;
437             $err{msg}         =
438               $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
439         }
440     }
441     elsif ( $code eq 'WrongTransfer' ) {
442         ;    # FIXME... anything to do here?
443     }
444     elsif ( $code eq 'WrongTransferItem' ) {
445         ;    # FIXME... anything to do here?
446     }
447     elsif ( $code eq 'NeedsTransfer' ) {
448     }
449     elsif ( $code eq 'Wrongbranch' ) {
450     }
451     elsif ( $code eq 'Debarred' ) {
452         $err{debarred}            = $messages->{'Debarred'};
453         $err{debarcardnumber}     = $borrower->{cardnumber};
454         $err{debarborrowernumber} = $borrower->{borrowernumber};
455         $err{debarname}           = "$borrower->{firstname} $borrower->{surname}";
456     }
457     else {
458         die "Unknown error code $code";    # note we need all the (empty) elsif's above, or we die.
459         # This forces the issue of staying in sync w/ Circulation.pm
460     }
461     if (%err) {
462         push( @errmsgloop, \%err );
463     }
464     last if $exit_required_p;
465 }
466 $template->param( errmsgloop => \@errmsgloop );
467
468 # patrontable ....
469 if ($borrower) {
470     my $flags = $borrower->{'flags'};
471     my @flagloop;
472     my $flagset;
473     foreach my $flag ( sort keys %$flags ) {
474         my %flaginfo;
475         unless ($flagset) { $flagset = 1; }
476         $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
477         $flaginfo{flag}    = $flag;
478         if ( $flag eq 'CHARGES' ) {
479             $flaginfo{msg}            = $flag;
480             $flaginfo{charges}        = 1;
481             $flaginfo{chargeamount}   = $flags->{$flag}->{amount};
482             $flaginfo{borrowernumber} = $borrower->{borrowernumber};
483         }
484         elsif ( $flag eq 'WAITING' ) {
485             $flaginfo{msg}     = $flag;
486             $flaginfo{waiting} = 1;
487             my @waitingitemloop;
488             my $items = $flags->{$flag}->{'itemlist'};
489             foreach my $item (@$items) {
490                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
491                 push @waitingitemloop, {
492                     biblionum => $biblio->{'biblionumber'},
493                     barcode   => $biblio->{'barcode'},
494                     title     => $biblio->{'title'},
495                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
496                 };
497             }
498             $flaginfo{itemloop} = \@waitingitemloop;
499         }
500         elsif ( $flag eq 'ODUES' ) {
501             my $items = $flags->{$flag}->{'itemlist'};
502             my @itemloop;
503             foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
504                 @$items )
505             {
506                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
507                 push @itemloop, {
508                     duedate   => format_sqldatetime($item->{date_due}),
509                     biblionum => $biblio->{'biblionumber'},
510                     barcode   => $biblio->{'barcode'},
511                     title     => $biblio->{'title'},
512                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
513                 };
514             }
515             $flaginfo{itemloop} = \@itemloop;
516             $flaginfo{overdue}  = 1;
517         }
518         else {
519             $flaginfo{other} = 1;
520             $flaginfo{msg}   = $flags->{$flag}->{'message'};
521         }
522         push( @flagloop, \%flaginfo );
523     }
524     $template->param(
525         flagset          => $flagset,
526         flagloop         => \@flagloop,
527         riborrowernumber => $borrower->{'borrowernumber'},
528         riborcnum        => $borrower->{'cardnumber'},
529         riborsurname     => $borrower->{'surname'},
530         ribortitle       => $borrower->{'title'},
531         riborfirstname   => $borrower->{'firstname'}
532     );
533 }
534 #set up so only the last 8 returned items display (make for faster loading pages)
535 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
536 my $count = 0;
537 my @riloop;
538 my $shelflocations = GetKohaAuthorisedValues('items.location','');
539 foreach ( sort { $a <=> $b } keys %returneditems ) {
540     my %ri;
541     if ( $count++ < $returned_counter ) {
542         my $bar_code = $returneditems{$_};
543         if ($riduedate{$_}) {
544             my $duedate = dt_from_string( $riduedate{$_}, 'sql');
545             $ri{year}  = $duedate->year();
546             $ri{month} = $duedate->month();
547             $ri{day}   = $duedate->day();
548             $ri{hour}   = $duedate->hour();
549             $ri{minute}   = $duedate->minute();
550             $ri{duedate} = output_pref($duedate);
551             my ($b)      = GetMemberDetails( $riborrowernumber{$_}, 0 );
552             $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1 );
553             $ri{borrowernumber} = $b->{'borrowernumber'};
554             $ri{borcnum}        = $b->{'cardnumber'};
555             $ri{borfirstname}   = $b->{'firstname'};
556             $ri{borsurname}     = $b->{'surname'};
557             $ri{bortitle}       = $b->{'title'};
558             $ri{bornote}        = $b->{'borrowernotes'};
559             $ri{borcategorycode}= $b->{'categorycode'};
560         }
561         else {
562             $ri{borrowernumber} = $riborrowernumber{$_};
563         }
564
565         #        my %ri;
566         my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
567         my $item   = GetItem( GetItemnumberFromBarcode($bar_code) );
568         # fix up item type for display
569         $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
570         $ri{itembiblionumber} = $biblio->{'biblionumber'};
571         $ri{itemtitle}        = $biblio->{'title'};
572         $ri{itemauthor}       = $biblio->{'author'};
573         $ri{itemcallnumber}   = $biblio->{'itemcallnumber'};
574         $ri{itemtype}         = $biblio->{'itemtype'};
575         $ri{itemnote}         = $biblio->{'itemnotes'};
576         $ri{ccode}            = $biblio->{'ccode'};
577         $ri{itemnumber}       = $biblio->{'itemnumber'};
578         $ri{barcode}          = $bar_code;
579         $ri{homebranch}       = $item->{'homebranch'};
580         $ri{holdingbranch}    = $item->{'holdingbranch'};
581
582         $ri{location}         = $biblio->{'location'};
583         my $shelfcode = $ri{'location'};
584         $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
585
586     }
587     else {
588         last;
589     }
590     push @riloop, \%ri;
591 }
592 $template->param(
593     riloop         => \@riloop,
594     genbrname      => $branches->{$userenv_branch}->{'branchname'},
595     genprname      => $printers->{$printer}->{'printername'},
596     branchname     => $branches->{$userenv_branch}->{'branchname'},
597     printer        => $printer,
598     errmsgloop     => \@errmsgloop,
599     exemptfine     => $exemptfine,
600     dropboxmode    => $dropboxmode,
601     dropboxdate    => output_pref($dropboxdate),
602     overduecharges => $overduecharges,
603     soundon        => C4::Context->preference("SoundOn"),
604     BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
605 );
606
607 ### Comment out rotating collections for now to allow it a little more time to bake
608 ### for 3.4; in particular, must ensure that it doesn't fight with transfers required
609 ### to fill hold requests
610 ### -- Galen Charlton 2010-10-06
611 #my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
612 #if ( $itemnumber ) {
613 #   my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
614 #    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
615 #        $template->param(
616 #          collectionItemNeedsTransferred => 1,
617 #          collectionBranch => GetBranchName($collectionBranch),
618 #        );
619 #    }
620 #}                                                                                                            
621
622 # actually print the page!
623 output_html_with_http_headers $query, $cookie, $template->output;