Bug 8761 Dont inadvertantly use slices
[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         if ( $messages->{'wthdrawn'} ) {
289             $input{withdrawn}      = 1;
290             $input{borrowernumber} = 'Item Cancelled';  # FIXME: should be in display layer ?
291             $riborrowernumber{0}   = 'Item Cancelled';
292         }
293         else {
294             $input{borrowernumber} = ' ';  # This seems clearly bogus.
295             $riborrowernumber{0}   = ' ';
296         }
297         push( @inputloop, \%input );
298     }
299 }
300 $template->param( inputloop => \@inputloop );
301
302 my $found    = 0;
303 my $waiting  = 0;
304 my $reserved = 0;
305
306 # new op dev : we check if the document must be returned to his homebranch directly,
307 #  if the document is transfered, we have warning message .
308
309 if ( $messages->{'WasTransfered'} ) {
310     $template->param(
311         found          => 1,
312         transfer       => 1,
313         itemnumber     => $itemnumber,
314     );
315 }
316
317 if ( $messages->{'NeedsTransfer'} ){
318     $template->param(
319         found          => 1,
320         needstransfer  => 1,
321         itemnumber     => $itemnumber,
322     );
323 }
324
325 if ( $messages->{'Wrongbranch'} ){
326     $template->param(
327         wrongbranch => 1,
328     );
329 }
330
331 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
332
333 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
334     $template->param(
335         WrongTransfer  => 1,
336         TransferWaitingAt => $messages->{'WrongTransfer'},
337         WrongTransferItem => $messages->{'WrongTransferItem'},
338         itemnumber => $itemnumber,
339     );
340
341     my $reserve    = $messages->{'ResFound'};
342     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
343     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
344     my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
345     $template->param(
346             wname           => $name,
347             wborfirstname   => $borr->{'firstname'},
348             wborsurname     => $borr->{'surname'},
349             wbortitle       => $borr->{'title'},
350             wborphone       => $borr->{'phone'},
351             wboremail       => $borr->{'email'},
352             wboraddress     => $borr->{'address'},
353             wboraddress2    => $borr->{'address2'},
354             wborcity        => $borr->{'city'},
355             wborzip         => $borr->{'zipcode'},
356             wborrowernumber => $reserve->{'borrowernumber'},
357             wborcnum        => $borr->{'cardnumber'},
358             wtransfertFrom  => $userenv_branch,
359     );
360 }
361
362 #
363 # reserve found and item arrived at the expected branch
364 #
365 if ( $messages->{'ResFound'}) {
366     my $reserve    = $messages->{'ResFound'};
367     my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
368     my ($borr) = GetMemberDetails( $reserve->{'borrowernumber'}, 0 );
369
370     if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
371         if ( $reserve->{'ResFound'} eq "Waiting" ) {
372             $template->param(
373                 waiting      => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
374             );
375         } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
376             $template->param(
377                 intransit    => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
378                 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
379                 resbarcode   => $barcode,
380                 reserved     => 1,
381             );
382         }
383
384         # same params for Waiting or Reserved
385         $template->param(
386             found          => 1,
387             currentbranch  => $branches->{$userenv_branch}->{'branchname'},
388             destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
389             name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
390             borfirstname   => $borr->{'firstname'},
391             borsurname     => $borr->{'surname'},
392             bortitle       => $borr->{'title'},
393             borphone       => $borr->{'phone'},
394             boremail       => $borr->{'email'},
395             boraddress     => $borr->{'address'},
396             boraddress2    => $borr->{'address2'},
397             borcity        => $borr->{'city'},
398             borzip         => $borr->{'zipcode'},
399             borcnum        => $borr->{'cardnumber'},
400             debarred       => $borr->{'debarred'},
401             gonenoaddress  => $borr->{'gonenoaddress'},
402             barcode        => $barcode,
403             destbranch     => $reserve->{'branchcode'},
404             borrowernumber => $reserve->{'borrowernumber'},
405             itemnumber     => $reserve->{'itemnumber'},
406             reservenotes   => $reserve->{'reservenotes'},
407         );
408     } # else { ; }  # error?
409 }
410
411 # Error Messages
412 my @errmsgloop;
413 foreach my $code ( keys %$messages ) {
414     my %err;
415     my $exit_required_p = 0;
416     if ( $code eq 'BadBarcode' ) {
417         $err{badbarcode} = 1;
418         $err{msg}        = $messages->{'BadBarcode'};
419     }
420     elsif ( $code eq 'NotIssued' ) {
421         $err{notissued} = 1;
422         $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
423     }
424     elsif ( $code eq 'LocalUse' ) {
425         $err{localuse} = 1;
426     }
427     elsif ( $code eq 'WasLost' ) {
428         $err{waslost} = 1;
429     }
430     elsif ( $code eq 'ResFound' ) {
431         ;    # FIXME... anything to do here?
432     }
433     elsif ( $code eq 'WasReturned' ) {
434         ;    # FIXME... anything to do here?
435     }
436     elsif ( $code eq 'WasTransfered' ) {
437         ;    # FIXME... anything to do here?
438     }
439     elsif ( $code eq 'wthdrawn' ) {
440         $err{withdrawn} = 1;
441         $exit_required_p = 1;
442     }
443     elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
444         if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
445             $err{ispermanent} = 1;
446             $err{msg}         =
447               $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
448         }
449     }
450     elsif ( $code eq 'WrongTransfer' ) {
451         ;    # FIXME... anything to do here?
452     }
453     elsif ( $code eq 'WrongTransferItem' ) {
454         ;    # FIXME... anything to do here?
455     }
456     elsif ( $code eq 'NeedsTransfer' ) {
457     }
458     elsif ( $code eq 'Wrongbranch' ) {
459     }
460     elsif ( $code eq 'Debarred' ) {
461         $err{debarred}            = $messages->{'Debarred'};
462         $err{debarcardnumber}     = $borrower->{cardnumber};
463         $err{debarborrowernumber} = $borrower->{borrowernumber};
464         $err{debarname}           = "$borrower->{firstname} $borrower->{surname}";
465     }
466     else {
467         die "Unknown error code $code";    # note we need all the (empty) elsif's above, or we die.
468         # This forces the issue of staying in sync w/ Circulation.pm
469     }
470     if (%err) {
471         push( @errmsgloop, \%err );
472     }
473     last if $exit_required_p;
474 }
475 $template->param( errmsgloop => \@errmsgloop );
476
477 # patrontable ....
478 if ($borrower) {
479     my $flags = $borrower->{'flags'};
480     my @flagloop;
481     my $flagset;
482     foreach my $flag ( sort keys %$flags ) {
483         my %flaginfo;
484         unless ($flagset) { $flagset = 1; }
485         $flaginfo{redfont} = ( $flags->{$flag}->{'noissues'} );
486         $flaginfo{flag}    = $flag;
487         if ( $flag eq 'CHARGES' ) {
488             $flaginfo{msg}            = $flag;
489             $flaginfo{charges}        = 1;
490             $flaginfo{chargeamount}   = $flags->{$flag}->{amount};
491             $flaginfo{borrowernumber} = $borrower->{borrowernumber};
492         }
493         elsif ( $flag eq 'WAITING' ) {
494             $flaginfo{msg}     = $flag;
495             $flaginfo{waiting} = 1;
496             my @waitingitemloop;
497             my $items = $flags->{$flag}->{'itemlist'};
498             foreach my $item (@$items) {
499                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
500                 push @waitingitemloop, {
501                     biblionum => $biblio->{'biblionumber'},
502                     barcode   => $biblio->{'barcode'},
503                     title     => $biblio->{'title'},
504                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
505                 };
506             }
507             $flaginfo{itemloop} = \@waitingitemloop;
508         }
509         elsif ( $flag eq 'ODUES' ) {
510             my $items = $flags->{$flag}->{'itemlist'};
511             my @itemloop;
512             foreach my $item ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
513                 @$items )
514             {
515                 my $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'});
516                 push @itemloop, {
517                     duedate   => format_sqldatetime($item->{date_due}),
518                     biblionum => $biblio->{'biblionumber'},
519                     barcode   => $biblio->{'barcode'},
520                     title     => $biblio->{'title'},
521                     brname    => $branches->{ $biblio->{'holdingbranch'} }->{'branchname'},
522                 };
523             }
524             $flaginfo{itemloop} = \@itemloop;
525             $flaginfo{overdue}  = 1;
526         }
527         else {
528             $flaginfo{other} = 1;
529             $flaginfo{msg}   = $flags->{$flag}->{'message'};
530         }
531         push( @flagloop, \%flaginfo );
532     }
533     $template->param(
534         flagset          => $flagset,
535         flagloop         => \@flagloop,
536         riborrowernumber => $borrower->{'borrowernumber'},
537         riborcnum        => $borrower->{'cardnumber'},
538         riborsurname     => $borrower->{'surname'},
539         ribortitle       => $borrower->{'title'},
540         riborfirstname   => $borrower->{'firstname'}
541     );
542 }
543 #set up so only the last 8 returned items display (make for faster loading pages)
544 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
545 my $count = 0;
546 my @riloop;
547 my $shelflocations = GetKohaAuthorisedValues('items.location','');
548 foreach ( sort { $a <=> $b } keys %returneditems ) {
549     my %ri;
550     if ( $count++ < $returned_counter ) {
551         my $bar_code = $returneditems{$_};
552         if ($riduedate{$_}) {
553             my $duedate = dt_from_string( $riduedate{$_}, 'sql');
554             $ri{year}  = $duedate->year();
555             $ri{month} = $duedate->month();
556             $ri{day}   = $duedate->day();
557             $ri{hour}   = $duedate->hour();
558             $ri{minute}   = $duedate->minute();
559             $ri{duedate} = output_pref($duedate);
560             my ($b)      = GetMemberDetails( $riborrowernumber{$_}, 0 );
561             $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1 );
562             $ri{borrowernumber} = $b->{'borrowernumber'};
563             $ri{borcnum}        = $b->{'cardnumber'};
564             $ri{borfirstname}   = $b->{'firstname'};
565             $ri{borsurname}     = $b->{'surname'};
566             $ri{bortitle}       = $b->{'title'};
567             $ri{bornote}        = $b->{'borrowernotes'};
568             $ri{borcategorycode}= $b->{'categorycode'};
569         }
570         else {
571             $ri{borrowernumber} = $riborrowernumber{$_};
572         }
573
574         #        my %ri;
575         my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
576         my $item   = GetItem( GetItemnumberFromBarcode($bar_code) );
577         # fix up item type for display
578         $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
579         $ri{itembiblionumber} = $biblio->{'biblionumber'};
580         $ri{itemtitle}        = $biblio->{'title'};
581         $ri{itemauthor}       = $biblio->{'author'};
582         $ri{itemcallnumber}   = $biblio->{'itemcallnumber'};
583         $ri{itemtype}         = $biblio->{'itemtype'};
584         $ri{itemnote}         = $biblio->{'itemnotes'};
585         $ri{ccode}            = $biblio->{'ccode'};
586         $ri{itemnumber}       = $biblio->{'itemnumber'};
587         $ri{barcode}          = $bar_code;
588         $ri{homebranch}       = $item->{'homebranch'};
589         $ri{holdingbranch}    = $item->{'holdingbranch'};
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 $template->param(
602     riloop         => \@riloop,
603     genbrname      => $branches->{$userenv_branch}->{'branchname'},
604     genprname      => $printers->{$printer}->{'printername'},
605     branchname     => $branches->{$userenv_branch}->{'branchname'},
606     printer        => $printer,
607     errmsgloop     => \@errmsgloop,
608     exemptfine     => $exemptfine,
609     dropboxmode    => $dropboxmode,
610     dropboxdate    => output_pref($dropboxdate),
611     overduecharges => $overduecharges,
612     soundon        => C4::Context->preference("SoundOn"),
613 );
614
615 ### Comment out rotating collections for now to allow it a little more time to bake
616 ### for 3.4; in particular, must ensure that it doesn't fight with transfers required
617 ### to fill hold requests
618 ### -- Galen Charlton 2010-10-06
619 #my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
620 #if ( $itemnumber ) {
621 #   my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
622 #    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
623 #        $template->param(
624 #          collectionItemNeedsTransferred => 1,
625 #          collectionBranch => GetBranchName($collectionBranch),
626 #        );
627 #    }
628 #}                                                                                                            
629
630 # actually print the page!
631 output_html_with_http_headers $query, $cookie, $template->output;