bug_7467: Printing Transfer Slips for transfers that do not have holds - Addendum...
[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             itemnumber     => $iteminfo->{'itemnumber'},
154             itembiblionumber => $iteminfo->{'biblionumber'},
155             iteminfo       => $iteminfo->{'author'},
156             tobranchname   => GetBranchName($messages->{'transfert'}),
157             name           => $name,
158             borrowernumber => $borrowernumber,
159             borcnum        => $borr->{'cardnumber'},
160             borfirstname   => $borr->{'firstname'},
161             borsurname     => $borr->{'surname'},
162             diffbranch     => 1,
163         );
164     }
165 }
166
167 my $borrower;
168 my $returned = 0;
169 my $messages;
170 my $issueinformation;
171 my $itemnumber;
172 my $barcode     = $query->param('barcode');
173 my $exemptfine  = $query->param('exemptfine');
174 my $dropboxmode = $query->param('dropboxmode');
175 my $dotransfer  = $query->param('dotransfer');
176 my $canceltransfer = $query->param('canceltransfer');
177 my $dest = $query->param('dest');
178 my $calendar    = C4::Calendar->new( branchcode => $userenv_branch );
179 #dropbox: get last open day (today - 1)
180 my $today       = C4::Dates->new();
181 my $today_iso   = $today->output('iso');
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     if ( C4::Context->preference("ReturnToShelvingCart") ) {
216         my $item = GetItem( $itemnumber );
217         $item->{'location'} = 'CART';
218         ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
219     }
220
221 #
222 # save the return
223 #
224     ( $returned, $messages, $issueinformation, $borrower ) =
225       AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
226     my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') or 'homebranch';
227
228     # get biblio description
229     my $biblio = GetBiblioFromItemNumber($itemnumber);
230     # fix up item type for display
231     $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
232
233     $template->param(
234         title            => $biblio->{'title'},
235         homebranch       => $biblio->{'homebranch'},
236         homebranchname   => GetBranchName( $biblio->{$homeorholdingbranchreturn} ),
237         author           => $biblio->{'author'},
238         itembarcode      => $biblio->{'barcode'},
239         itemtype         => $biblio->{'itemtype'},
240         ccode            => $biblio->{'ccode'},
241         itembiblionumber => $biblio->{'biblionumber'},    
242         additional_materials => $biblio->{'materials'}
243     );
244
245     my %input = (
246         counter => 0,
247         first   => 1,
248         barcode => $barcode,
249     );
250
251     if ($returned) {
252         my $duedate = $issueinformation->{'date_due'};
253         $returneditems{0}      = $barcode;
254         $riborrowernumber{0}   = $borrower->{'borrowernumber'};
255         $riduedate{0}          = $duedate;
256         $input{borrowernumber} = $borrower->{'borrowernumber'};
257         $input{duedate}        = $duedate;
258         $input{return_overdue} = 1 if ($duedate and $duedate lt $today->output('iso'));
259         push( @inputloop, \%input );
260
261         if ( C4::Context->preference("FineNotifyAtCheckin") ) {
262             my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrower->{'borrowernumber'} );
263             if ($fines > 0) {
264                 $template->param( fines => sprintf("%.2f",$fines) );
265                 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
266             }
267         }
268         
269         if (C4::Context->preference("WaitingNotifyAtCheckin") ) {
270             #Check for waiting holds
271             my @reserves = GetReservesFromBorrowernumber($borrower->{'borrowernumber'});
272             my $waiting_holds;
273             foreach my $num_res (@reserves) {
274                 if ( $num_res->{'found'} eq 'W' && $num_res->{'branchcode'} eq $userenv_branch) {
275                     $waiting_holds++;
276                 }
277             } 
278             if ($waiting_holds > 0) {
279                 $template->param(
280                     waiting_holds       => $waiting_holds,
281                     holdsborrowernumber => $borrower->{'borrowernumber'},
282                     holdsfirstname => $borrower->{'firstname'},
283                     holdssurname => $borrower->{'surname'},
284                 );
285             }
286         }
287     }
288     elsif ( !$messages->{'BadBarcode'} ) {
289         $input{duedate}   = 0;
290         $returneditems{0} = $barcode;
291         $riduedate{0}     = 0;
292         if ( $messages->{'wthdrawn'} ) {
293             $input{withdrawn}      = 1;
294             $input{borrowernumber} = 'Item Cancelled';  # FIXME: should be in display layer ?
295             $riborrowernumber{0}   = 'Item Cancelled';
296         }
297         else {
298             $input{borrowernumber} = ' ';  # This seems clearly bogus.
299             $riborrowernumber{0}   = ' ';
300         }
301         push( @inputloop, \%input );
302     }
303 }
304 $template->param( inputloop => \@inputloop );
305
306 my $found    = 0;
307 my $waiting  = 0;
308 my $reserved = 0;
309
310 # new op dev : we check if the document must be returned to his homebranch directly,
311 #  if the document is transfered, we have warning message .
312
313 if ( $messages->{'WasTransfered'} ) {
314     $template->param(
315         found          => 1,
316         transfer       => 1,
317         itemnumber     => $itemnumber,
318     );
319 }
320
321 if ( $messages->{'NeedsTransfer'} ){
322     $template->param(
323         found          => 1,
324         needstransfer  => 1,
325         itemnumber     => $itemnumber,
326     );
327 }
328
329 if ( $messages->{'Wrongbranch'} ){
330     $template->param(
331         wrongbranch => 1,
332     );
333 }
334
335 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
336
337 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
338     $messages->{'WrongTransfer'} = GetBranchName( $messages->{'WrongTransfer'} );
339     $template->param(
340         WrongTransfer  => 1,
341         TransferWaitingAt => $messages->{'WrongTransfer'},
342         WrongTransferItem => $messages->{'WrongTransferItem'},
343         itemnumber => $itemnumber,
344     );
345
346     my $reserve    = $messages->{'ResFound'};
347     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
348     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
349     my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
350     $template->param(
351             wname           => $name,
352             wborfirstname   => $borr->{'firstname'},
353             wborsurname     => $borr->{'surname'},
354             wbortitle       => $borr->{'title'},
355             wborphone       => $borr->{'phone'},
356             wboremail       => $borr->{'email'},
357             wboraddress     => $borr->{'address'},
358             wboraddress2    => $borr->{'address2'},
359             wborcity        => $borr->{'city'},
360             wborzip         => $borr->{'zipcode'},
361             wborrowernumber => $reserve->{'borrowernumber'},
362             wborcnum        => $borr->{'cardnumber'},
363             wtransfertFrom  => $userenv_branch,
364     );
365 }
366
367 #
368 # reserve found and item arrived at the expected branch
369 #
370 if ( $messages->{'ResFound'}) {
371     my $reserve    = $messages->{'ResFound'};
372     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
373     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
374
375     if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
376         if ( $reserve->{'ResFound'} eq "Waiting" ) {
377             $template->param(
378                 waiting      => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
379             );
380         } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
381             $template->param(
382                 intransit    => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
383                 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
384                 resbarcode   => $barcode,
385                 reserved     => 1,
386             );
387         }
388
389         # same params for Waiting or Reserved
390         $template->param(
391             found          => 1,
392             currentbranch  => $branches->{$userenv_branch}->{'branchname'},
393             destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
394             name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
395             borfirstname   => $borr->{'firstname'},
396             borsurname     => $borr->{'surname'},
397             bortitle       => $borr->{'title'},
398             borphone       => $borr->{'phone'},
399             boremail       => $borr->{'email'},
400             boraddress     => $borr->{'address'},
401             boraddress2    => $borr->{'address2'},
402             borcity        => $borr->{'city'},
403             borzip         => $borr->{'zipcode'},
404             borcnum        => $borr->{'cardnumber'},
405             debarred       => $borr->{'debarred'},
406             gonenoaddress  => $borr->{'gonenoaddress'},
407             barcode        => $barcode,
408             destbranch     => $reserve->{'branchcode'},
409             borrowernumber => $reserve->{'borrowernumber'},
410             itemnumber     => $reserve->{'itemnumber'},
411             reservenotes   => $reserve->{'reservenotes'},
412         );
413     } # else { ; }  # error?
414 }
415
416 # Error Messages
417 my @errmsgloop;
418 foreach my $code ( keys %$messages ) {
419     my %err;
420     my $exit_required_p = 0;
421     if ( $code eq 'BadBarcode' ) {
422         $err{badbarcode} = 1;
423         $err{msg}        = $messages->{'BadBarcode'};
424     }
425     elsif ( $code eq 'NotIssued' ) {
426         $err{notissued} = 1;
427         $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
428     }
429     elsif ( $code eq 'LocalUse' ) {
430         $err{localuse} = 1;
431     }
432     elsif ( $code eq 'WasLost' ) {
433         $err{waslost} = 1;
434     }
435     elsif ( $code eq 'ResFound' ) {
436         ;    # FIXME... anything to do here?
437     }
438     elsif ( $code eq 'WasReturned' ) {
439         ;    # FIXME... anything to do here?
440     }
441     elsif ( $code eq 'WasTransfered' ) {
442         ;    # FIXME... anything to do here?
443     }
444     elsif ( $code eq 'wthdrawn' ) {
445         $err{withdrawn} = 1;
446         $exit_required_p = 1;
447     }
448     elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
449         if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
450             $err{ispermanent} = 1;
451             $err{msg}         =
452               $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
453         }
454     }
455     elsif ( $code eq 'WrongTransfer' ) {
456         ;    # FIXME... anything to do here?
457     }
458     elsif ( $code eq 'WrongTransferItem' ) {
459         ;    # FIXME... anything to do here?
460     }
461     elsif ( $code eq 'NeedsTransfer' ) {
462     }
463     elsif ( $code eq 'Wrongbranch' ) {
464     }
465     elsif ( $code eq 'Debarred' ) {
466         $err{debarred}            = format_date( $messages->{'Debarred'} );
467         $err{debarcardnumber}     = $borrower->{cardnumber};
468         $err{debarborrowernumber} = $borrower->{borrowernumber};
469         $err{debarname}           = "$borrower->{firstname} $borrower->{surname}";
470     }
471     else {
472         die "Unknown error code $code";    # note we need all the (empty) elsif's above, or we die.
473         # This forces the issue of staying in sync w/ Circulation.pm
474     }
475     if (%err) {
476         push( @errmsgloop, \%err );
477     }
478     last if $exit_required_p;
479 }
480 $template->param( errmsgloop => \@errmsgloop );
481
482 # patrontable ....
483 if ($borrower) {
484     my $flags = $borrower->{'flags'};
485     my @flagloop;
486     my $flagset;
487     foreach my $flag ( sort keys %$flags ) {
488         my %flaginfo;
489         unless ($flagset) { $flagset = 1; }
490         $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
491         $flaginfo{flag}    = $flag;
492         if ( $flag eq 'CHARGES' ) {
493             $flaginfo{msg}            = $flag;
494             $flaginfo{charges}        = 1;
495             $flaginfo{chargeamount}   = $flags->{$flag}->{amount};
496             $flaginfo{borrowernumber} = $borrower->{borrowernumber};
497         }
498         elsif ( $flag eq 'WAITING' ) {
499             $flaginfo{msg}     = $flag;
500             $flaginfo{waiting} = 1;
501             my @waitingitemloop;
502             my $items = $flags->{$flag}->{'itemlist'};
503             foreach my $item (@$items) {
504                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
505                 push @waitingitemloop, {
506                     biblionum => $biblio->{'biblionumber'},
507                     barcode   => $biblio->{'barcode'},
508                     title     => $biblio->{'title'},
509                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
510                 };
511             }
512             $flaginfo{itemloop} = \@waitingitemloop;
513         }
514         elsif ( $flag eq 'ODUES' ) {
515             my $items = $flags->{$flag}->{'itemlist'};
516             my @itemloop;
517             foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
518                 @$items )
519             {
520                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
521                 push @itemloop, {
522                     duedate   => format_date($item->{'date_due'}),
523                     biblionum => $biblio->{'biblionumber'},
524                     barcode   => $biblio->{'barcode'},
525                     title     => $biblio->{'title'},
526                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
527                 };
528             }
529             $flaginfo{itemloop} = \@itemloop;
530             $flaginfo{overdue}  = 1;
531         }
532         else {
533             $flaginfo{other} = 1;
534             $flaginfo{msg}   = $flags->{$flag}->{'message'};
535         }
536         push( @flagloop, \%flaginfo );
537     }
538     $template->param(
539         flagset          => $flagset,
540         flagloop         => \@flagloop,
541         riborrowernumber => $borrower->{'borrowernumber'},
542         riborcnum        => $borrower->{'cardnumber'},
543         riborsurname     => $borrower->{'surname'},
544         ribortitle       => $borrower->{'title'},
545         riborfirstname   => $borrower->{'firstname'}
546     );
547 }
548
549 #set up so only the last 8 returned items display (make for faster loading pages)
550 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
551 my $count = 0;
552 my @riloop;
553 my $shelflocations = GetKohaAuthorisedValues('items.location','');
554 foreach ( sort { $a <=> $b } keys %returneditems ) {
555     my %ri;
556     if ( $count++ < $returned_counter ) {
557         my $bar_code = $returneditems{$_};
558         my $duedate = $riduedate{$_};
559         if ($duedate) {
560             my @tempdate = split( /-/, $duedate );
561             $ri{year}  = $tempdate[0];
562             $ri{month} = $tempdate[1];
563             $ri{day}   = $tempdate[2];
564             $ri{duedate} = format_date($duedate);
565             my ($b)      = GetMemberDetails( $riborrowernumber{$_}, 0 );
566             $ri{return_overdue} = 1 if ($duedate lt $today->output('iso'));
567             $ri{borrowernumber} = $b->{'borrowernumber'};
568             $ri{borcnum}        = $b->{'cardnumber'};
569             $ri{borfirstname}   = $b->{'firstname'};
570             $ri{borsurname}     = $b->{'surname'};
571             $ri{bortitle}       = $b->{'title'};
572             $ri{bornote}        = $b->{'borrowernotes'};
573             $ri{borcategorycode}= $b->{'categorycode'};
574         }
575         else {
576             $ri{borrowernumber} = $riborrowernumber{$_};
577         }
578
579         #        my %ri;
580         my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
581         # fix up item type for display
582         $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
583         $ri{itembiblionumber} = $biblio->{'biblionumber'};
584         $ri{itemtitle}        = $biblio->{'title'};
585         $ri{itemauthor}       = $biblio->{'author'};
586         $ri{itemcallnumber}   = $biblio->{'itemcallnumber'};
587         $ri{itemtype}         = $biblio->{'itemtype'};
588         $ri{itemnote}         = $biblio->{'itemnotes'};
589         $ri{ccode}            = $biblio->{'ccode'};
590         $ri{itemnumber}       = $biblio->{'itemnumber'};
591         $ri{barcode}          = $bar_code;
592
593         $ri{location}         = $biblio->{'location'};
594         my $shelfcode = $ri{'location'};
595         $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
596
597     }
598     else {
599         last;
600     }
601     push @riloop, \%ri;
602 }
603
604 $template->param(
605     riloop         => \@riloop,
606     genbrname      => $branches->{$userenv_branch}->{'branchname'},
607     genprname      => $printers->{$printer}->{'printername'},
608     branchname     => $branches->{$userenv_branch}->{'branchname'},
609     printer        => $printer,
610     errmsgloop     => \@errmsgloop,
611     exemptfine     => $exemptfine,
612     dropboxmode    => $dropboxmode,
613     dropboxdate    => $dropboxdate->output(),
614     overduecharges => $overduecharges,
615     soundon        => C4::Context->preference("SoundOn"),
616 );
617
618 ### Comment out rotating collections for now to allow it a little more time to bake
619 ### for 3.4; in particular, must ensure that it doesn't fight with transfers required
620 ### to fill hold requests
621 ### -- Galen Charlton 2010-10-06
622 #my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
623 #if ( $itemnumber ) {
624 #   my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
625 #    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
626 #        $template->param(
627 #          collectionItemNeedsTransferred => 1,
628 #          collectionBranch => GetBranchName($collectionBranch),
629 #        );
630 #    }
631 #}                                                                                                            
632
633 # actually print the page!
634 output_html_with_http_headers $query, $cookie, $template->output;