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