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