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