Bug 18910: Revert "Bug 18152: Add tests"
[koha.git] / circ / returns.pl
blob3016464d21d3eeef56ecd47fa698b1741f1e2de6
1 #!/usr/bin/perl
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.
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # Koha is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 =head1 returns.pl
26 script to execute returns of books
28 =cut
30 use strict;
31 use warnings;
33 use Carp 'verbose';
34 $SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
36 use CGI qw ( -utf8 );
37 use DateTime;
38 use C4::Context;
39 use C4::Auth qw/:DEFAULT get_session/;
40 use C4::Output;
41 use C4::Circulation;
42 use C4::Print;
43 use C4::Reserves;
44 use C4::Biblio;
45 use C4::Items;
46 use C4::Members;
47 use C4::Members::Messaging;
48 use C4::Koha; # FIXME : is it still useful ?
49 use C4::RotatingCollections;
50 use Koha::AuthorisedValues;
51 use Koha::DateUtils;
52 use Koha::Calendar;
53 use Koha::Checkouts;
54 use Koha::BiblioFrameworks;
56 my $query = new CGI;
58 #getting the template
59 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
61 template_name => "circ/returns.tt",
62 query => $query,
63 type => "intranet",
64 authnotrequired => 0,
65 flagsrequired => { circulate => "circulate_remaining_permissions" },
69 my $sessionID = $query->cookie("CGISESSID");
70 my $session = get_session($sessionID);
71 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
72 # no branch set we can't return
73 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
74 exit;
77 # Print a reserve slip on this page
78 if ( $query->param('print_slip') ) {
79 $template->param(
80 print_slip => 1,
81 borrowernumber => scalar $query->param('borrowernumber'),
82 biblionumber => scalar $query->param('biblionumber'),
86 #####################
87 #Global vars
88 my $printers = GetPrinters();
89 my $userenv = C4::Context->userenv;
90 my $userenv_branch = $userenv->{'branch'} // '';
91 my $printer = $userenv->{'branchprinter'} // '';
92 my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
94 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
96 # Some code to handle the error if there is no branch or printer setting.....
99 # Set up the item stack ....
100 my %returneditems;
101 my %riduedate;
102 my %riborrowernumber;
103 my @inputloop;
104 foreach ( $query->param ) {
105 my $counter;
106 if (/ri-(\d*)/) {
107 $counter = $1;
108 if ($counter > 20) {
109 next;
112 else {
113 next;
116 my %input;
117 my $barcode = $query->param("ri-$counter");
118 my $duedate = $query->param("dd-$counter");
119 my $borrowernumber = $query->param("bn-$counter");
120 $counter++;
122 # decode barcode ## Didn't we already decode them before passing them back last time??
123 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
124 $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
126 ######################
127 #Are these lines still useful ?
128 $returneditems{$counter} = $barcode;
129 $riduedate{$counter} = $duedate;
130 $riborrowernumber{$counter} = $borrowernumber;
132 #######################
133 $input{counter} = $counter;
134 $input{barcode} = $barcode;
135 $input{duedate} = $duedate;
136 $input{borrowernumber} = $borrowernumber;
137 push( @inputloop, \%input );
140 ############
141 # Deal with the requests....
143 if ($query->param('WT-itemNumber')){
144 updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
147 if ( $query->param('reserve_id') ) {
148 my $item = $query->param('itemnumber');
149 my $borrowernumber = $query->param('borrowernumber');
150 my $reserve_id = $query->param('reserve_id');
151 my $diffBranchReturned = $query->param('diffBranch');
152 my $iteminfo = GetBiblioFromItemNumber($item);
153 my $cancel_reserve = $query->param('cancel_reserve');
154 # fix up item type for display
155 $iteminfo->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $iteminfo->{'itype'} : $iteminfo->{'itemtype'};
157 if ( $cancel_reserve ) {
158 CancelReserve({ reserve_id => $reserve_id, charge_cancel_fee => !$forgivemanualholdsexpire });
159 } else {
160 my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
161 # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
162 # i.e., whether to apply waiting status
163 ModReserveAffect( $item, $borrowernumber, $diffBranchSend, $reserve_id );
165 # check if we have other reserves for this document, if we have a return send the message of transfer
166 my ( $messages, $nextreservinfo ) = GetOtherReserves($item);
168 my $borr = GetMember( borrowernumber => $nextreservinfo );
169 my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
170 if ( $messages->{'transfert'} ) {
171 $template->param(
172 itemtitle => $iteminfo->{'title'},
173 itemnumber => $iteminfo->{'itemnumber'},
174 itembiblionumber => $iteminfo->{'biblionumber'},
175 iteminfo => $iteminfo->{'author'},
176 name => $name,
177 borrowernumber => $borrowernumber,
178 borcnum => $borr->{'cardnumber'},
179 borfirstname => $borr->{'firstname'},
180 borsurname => $borr->{'surname'},
181 borcategory => $borr->{'description'},
182 diffbranch => 1,
187 my $borrower;
188 my $returned = 0;
189 my $messages;
190 my $issueinformation;
191 my $itemnumber;
192 my $barcode = $query->param('barcode');
193 my $exemptfine = $query->param('exemptfine');
194 if (
195 $exemptfine &&
196 !C4::Auth::haspermission(C4::Context->userenv->{'id'}, {'updatecharges' => 'writeoff'})
198 # silently prevent unauthorized operator from forgiving overdue
199 # fines by manually tweaking form parameters
200 undef $exemptfine;
202 my $dropboxmode = $query->param('dropboxmode');
203 my $dotransfer = $query->param('dotransfer');
204 my $canceltransfer = $query->param('canceltransfer');
205 my $dest = $query->param('dest');
206 my $calendar = Koha::Calendar->new( branchcode => $userenv_branch );
207 #dropbox: get last open day (today - 1)
208 my $today = DateTime->now( time_zone => C4::Context->tz());
209 my $dropboxdate = $calendar->addDate($today, -1);
211 my $return_date_override = $query->param('return_date_override');
212 my $return_date_override_remember =
213 $query->param('return_date_override_remember');
214 if ($return_date_override) {
215 if ( C4::Context->preference('SpecifyReturnDate') ) {
216 my $return_date_override_dt = eval {dt_from_string( $return_date_override ) };
217 if ( $return_date_override_dt ) {
218 # note that we've overriden the return date
219 $template->param( return_date_was_overriden => 1);
220 # Save the original format if we are remembering for this series
221 $template->param(
222 return_date_override => $return_date_override,
223 return_date_override_remember => 1
224 ) if ($return_date_override_remember);
226 $return_date_override =
227 DateTime::Format::MySQL->format_datetime( $return_date_override_dt );
230 else {
231 $return_date_override = q{};
235 if ($dotransfer){
236 # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
237 my $transferitem = $query->param('transferitem');
238 my $tobranch = $query->param('tobranch');
239 ModItemTransfer($transferitem, $userenv_branch, $tobranch);
242 if ($canceltransfer){
243 $itemnumber=$query->param('itemnumber');
244 DeleteTransfer($itemnumber);
245 if($dest eq "ttr"){
246 print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl");
247 exit;
248 } else {
249 $template->param( transfercancelled => 1);
253 # actually return book and prepare item table.....
254 my $returnbranch;
255 if ($barcode) {
256 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
257 $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
258 $itemnumber = GetItemnumberFromBarcode($barcode);
261 # save the return
264 # get biblio description
265 my $biblio = GetBiblioFromItemNumber($itemnumber);
266 # fix up item type for display
267 $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
269 # Check if we should display a checkin message, based on the the item
270 # type of the checked in item
271 my $itemtype = Koha::ItemTypes->find( $biblio->{'itemtype'} );
272 if ( $itemtype && $itemtype->checkinmsg ) {
273 $template->param(
274 checkinmsg => $itemtype->checkinmsg,
275 checkinmsgtype => $itemtype->checkinmsgtype,
279 # make sure return branch respects home branch circulation rules, default to homebranch
280 my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
281 $returnbranch = $biblio->{$hbr};
283 my $materials = $biblio->{'materials'};
284 my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
285 $materials = $descriptions->{lib} // $materials;
287 my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
289 $template->param(
290 title => $biblio->{'title'},
291 homebranch => $biblio->{'homebranch'},
292 holdingbranch => $biblio->{'holdingbranch'},
293 returnbranch => $returnbranch,
294 author => $biblio->{'author'},
295 itembarcode => $biblio->{'barcode'},
296 itemtype => $biblio->{'itemtype'},
297 ccode => $biblio->{'ccode'},
298 itembiblionumber => $biblio->{'biblionumber'},
299 biblionumber => $biblio->{'biblionumber'},
300 borrower => $borrower,
301 additional_materials => $materials,
302 issue => $issue,
305 my %input = (
306 counter => 0,
307 first => 1,
308 barcode => $barcode,
311 # do the return
312 ( $returned, $messages, $issueinformation, $borrower ) =
313 AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
315 if ($returned) {
316 my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
317 my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
318 $returneditems{0} = $barcode;
319 $riborrowernumber{0} = $borrower->{'borrowernumber'};
320 $riduedate{0} = $duedate;
321 $input{borrowernumber} = $borrower->{'borrowernumber'};
322 $input{duedate} = $duedate;
323 unless ( $dropboxmode ) {
324 $input{return_overdue} = 1 if (DateTime->compare($issueinformation->{date_due}, DateTime->now()) == -1);
325 } else {
326 $input{return_overdue} = 1 if (DateTime->compare($issueinformation->{date_due}, $dropboxdate) == -1);
328 push( @inputloop, \%input );
330 if ( C4::Context->preference("FineNotifyAtCheckin") ) {
331 my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
332 my $balance = $patron->account->balance;
334 if ($balance > 0) {
335 $template->param( fines => sprintf("%.2f", $balance) );
336 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
340 if (C4::Context->preference("WaitingNotifyAtCheckin") ) {
341 #Check for waiting holds
342 my @reserves = GetReservesFromBorrowernumber($borrower->{'borrowernumber'});
343 my $waiting_holds = 0;
344 foreach my $num_res (@reserves) {
345 if ( $num_res->{'found'} eq 'W' && $num_res->{'branchcode'} eq $userenv_branch) {
346 $waiting_holds++;
349 if ($waiting_holds > 0) {
350 $template->param(
351 waiting_holds => $waiting_holds,
352 holdsborrowernumber => $borrower->{'borrowernumber'},
353 holdsfirstname => $borrower->{'firstname'},
354 holdssurname => $borrower->{'surname'},
358 } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} ) {
359 $input{duedate} = 0;
360 $returneditems{0} = $barcode;
361 $riduedate{0} = 0;
362 push( @inputloop, \%input );
364 $template->param( privacy => $borrower->{privacy} );
366 $template->param( inputloop => \@inputloop );
368 my $found = 0;
369 my $waiting = 0;
370 my $reserved = 0;
372 # new op dev : we check if the document must be returned to his homebranch directly,
373 # if the document is transfered, we have warning message .
375 if ( $messages->{'WasTransfered'} ) {
376 $template->param(
377 found => 1,
378 transfer => 1,
379 itemnumber => $itemnumber,
383 if ( $messages->{'NeedsTransfer'} ){
384 $template->param(
385 found => 1,
386 needstransfer => $messages->{'NeedsTransfer'},
387 itemnumber => $itemnumber,
391 if ( $messages->{'Wrongbranch'} ){
392 $template->param(
393 wrongbranch => 1,
394 rightbranch => $messages->{'Wrongbranch'}->{'Rightbranch'},
398 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
400 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
401 $template->param(
402 WrongTransfer => 1,
403 TransferWaitingAt => $messages->{'WrongTransfer'},
404 WrongTransferItem => $messages->{'WrongTransferItem'},
405 itemnumber => $itemnumber,
408 my $reserve = $messages->{'ResFound'};
409 my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
410 my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
411 $template->param(
412 wname => $name,
413 wborfirstname => $borr->{'firstname'},
414 wborsurname => $borr->{'surname'},
415 wborcategory => $borr->{'description'},
416 wbortitle => $borr->{'title'},
417 wborphone => $borr->{'phone'},
418 wboremail => $borr->{'email'},
419 streetnumber => $borr->{streetnumber},
420 streettype => $borr->{streettype},
421 address => $borr->{'address'},
422 address2 => $borr->{'address2'},
423 city => $borr->{'city'},
424 zipcode => $borr->{'zipcode'},
425 state => $borr->{'state'},
426 country => $borr->{'country'},
427 wborrowernumber => $reserve->{'borrowernumber'},
428 wborcnum => $borr->{'cardnumber'},
429 wtransfertFrom => $userenv_branch,
434 # reserve found and item arrived at the expected branch
436 if ( $messages->{'ResFound'}) {
437 my $reserve = $messages->{'ResFound'};
438 my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
439 my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
440 if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
441 if ( $reserve->{'ResFound'} eq "Waiting" ) {
442 $template->param(
443 waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
445 } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
446 $template->param(
447 intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
448 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
449 reserve_id => $reserve->{reserve_id},
450 reserved => 1,
454 # same params for Waiting or Reserved
455 $template->param(
456 found => 1,
457 name => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
458 borfirstname => $borr->{'firstname'},
459 borsurname => $borr->{'surname'},
460 borcategory => $borr->{'description'},
461 bortitle => $borr->{'title'},
462 borphone => $borr->{'phone'},
463 boremail => $borr->{'email'},
464 streetnumber => $borr->{streetnumber},
465 streettype => $borr->{streettype},
466 address => $borr->{'address'},
467 address2 => $borr->{'address2'},
468 city => $borr->{'city'},
469 zipcode => $borr->{'zipcode'},
470 state => $borr->{'state'},
471 country => $borr->{'country'},
472 borcnum => $borr->{'cardnumber'},
473 debarred => $borr->{'debarred'},
474 gonenoaddress => $borr->{'gonenoaddress'},
475 barcode => $barcode,
476 destbranch => $reserve->{'branchcode'},
477 borrowernumber => $reserve->{'borrowernumber'},
478 itemnumber => $reserve->{'itemnumber'},
479 reservenotes => $reserve->{'reservenotes'},
480 reserve_id => $reserve->{reserve_id},
481 bormessagepref => $holdmsgpreferences->{'transports'},
483 } # else { ; } # error?
486 # Error Messages
487 my @errmsgloop;
488 foreach my $code ( keys %$messages ) {
489 my %err;
490 my $exit_required_p = 0;
491 if ( $code eq 'BadBarcode' ) {
492 $err{badbarcode} = 1;
493 $err{msg} = $messages->{'BadBarcode'};
495 elsif ( $code eq 'NotIssued' ) {
496 $err{notissued} = 1;
497 $err{msg} = '';
498 $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
500 elsif ( $code eq 'LocalUse' ) {
501 $err{localuse} = 1;
503 elsif ( $code eq 'WasLost' ) {
504 $err{waslost} = 1;
506 elsif ( $code eq 'LostItemFeeRefunded' ) {
507 $template->param( LostItemFeeRefunded => 1 );
509 elsif ( $code eq 'ResFound' ) {
510 ; # FIXME... anything to do here?
512 elsif ( $code eq 'WasReturned' ) {
513 ; # FIXME... anything to do here?
515 elsif ( $code eq 'WasTransfered' ) {
516 ; # FIXME... anything to do here?
518 elsif ( $code eq 'withdrawn' ) {
519 $err{withdrawn} = 1;
520 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
522 elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
523 if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
524 $err{ispermanent} = 1;
525 $err{msg} = $messages->{'IsPermanent'};
528 elsif ( $code eq 'WrongTransfer' ) {
529 ; # FIXME... anything to do here?
531 elsif ( $code eq 'WrongTransferItem' ) {
532 ; # FIXME... anything to do here?
534 elsif ( $code eq 'NeedsTransfer' ) {
536 elsif ( $code eq 'Wrongbranch' ) {
538 elsif ( $code eq 'Debarred' ) {
539 $err{debarred} = $messages->{'Debarred'};
540 $err{debarcardnumber} = $borrower->{cardnumber};
541 $err{debarborrowernumber} = $borrower->{borrowernumber};
542 $err{debarname} = "$borrower->{firstname} $borrower->{surname}";
544 elsif ( $code eq 'PrevDebarred' ) {
545 $err{prevdebarred} = $messages->{'PrevDebarred'};
547 elsif ( $code eq 'ForeverDebarred' ) {
548 $err{foreverdebarred} = $messages->{'ForeverDebarred'};
550 elsif ( $code eq 'NotForLoanStatusUpdated' ) {
551 $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
553 elsif ( $code eq 'DataCorrupted' ) {
554 $err{data_corrupted} = 1;
556 else {
557 die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die.
558 # This forces the issue of staying in sync w/ Circulation.pm
560 if (%err) {
561 push( @errmsgloop, \%err );
563 last if $exit_required_p;
565 $template->param( errmsgloop => \@errmsgloop );
567 #set up so only the last 8 returned items display (make for faster loading pages)
568 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
569 my $count = 0;
570 my @riloop;
571 my $shelflocations =
572 { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
573 foreach ( sort { $a <=> $b } keys %returneditems ) {
574 my %ri;
575 if ( $count++ < $returned_counter ) {
576 my $bar_code = $returneditems{$_};
577 if ($riduedate{$_}) {
578 my $duedate = dt_from_string( $riduedate{$_}, 'sql');
579 $ri{year} = $duedate->year();
580 $ri{month} = $duedate->month();
581 $ri{day} = $duedate->day();
582 $ri{hour} = $duedate->hour();
583 $ri{minute} = $duedate->minute();
584 $ri{duedate} = output_pref($duedate);
585 my $b = C4::Members::GetMember( borrowernumber => $riborrowernumber{$_} );
586 unless ( $dropboxmode ) {
587 $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
588 } else {
589 $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
591 $ri{borrowernumber} = $b->{'borrowernumber'};
592 $ri{borcnum} = $b->{'cardnumber'};
593 $ri{borfirstname} = $b->{'firstname'};
594 $ri{borsurname} = $b->{'surname'};
595 $ri{bortitle} = $b->{'title'};
596 $ri{bornote} = $b->{'borrowernotes'};
597 $ri{borcategorycode}= $b->{'categorycode'};
598 $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
600 else {
601 $ri{borrowernumber} = $riborrowernumber{$_};
604 # my %ri;
605 my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
606 my $item = GetItem( GetItemnumberFromBarcode($bar_code) );
607 # fix up item type for display
608 $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
609 $ri{itembiblionumber} = $biblio->{'biblionumber'};
610 $ri{itemtitle} = $biblio->{'title'};
611 $ri{itemauthor} = $biblio->{'author'};
612 $ri{itemcallnumber} = $biblio->{'itemcallnumber'};
613 $ri{dateaccessioned} = $item->{dateaccessioned};
614 $ri{itemtype} = $biblio->{'itemtype'};
615 $ri{itemnote} = $biblio->{'itemnotes'};
616 $ri{itemnotes_nonpublic} = $item->{'itemnotes_nonpublic'};
617 $ri{ccode} = $biblio->{'ccode'};
618 $ri{enumchron} = $biblio->{'enumchron'};
619 $ri{itemnumber} = $biblio->{'itemnumber'};
620 $ri{barcode} = $bar_code;
621 $ri{homebranch} = $item->{'homebranch'};
622 $ri{holdingbranch} = $item->{'holdingbranch'};
624 $ri{location} = $biblio->{'location'};
625 my $shelfcode = $ri{'location'};
626 $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
629 else {
630 last;
632 push @riloop, \%ri;
635 $template->param(
636 riloop => \@riloop,
637 printer => $printer,
638 errmsgloop => \@errmsgloop,
639 exemptfine => $exemptfine,
640 dropboxmode => $dropboxmode,
641 dropboxdate => output_pref($dropboxdate),
642 forgivemanualholdsexpire => $forgivemanualholdsexpire,
643 overduecharges => $overduecharges,
644 AudioAlerts => C4::Context->preference("AudioAlerts"),
645 BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
648 $itemnumber = GetItemnumberFromBarcode( $barcode );
649 if ( $itemnumber ) {
650 my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
651 if ( $holdingBranch and $collectionBranch ) {
652 $holdingBranch //= '';
653 $collectionBranch //= $returnbranch;
654 if ( ! ( $holdingBranch eq $collectionBranch ) ) {
655 $template->param(
656 collectionItemNeedsTransferred => 1,
657 collectionBranch => $collectionBranch,
658 itemnumber => $itemnumber,
664 # Checking if there is a Fast Cataloging Framework
665 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
667 # actually print the page!
668 output_html_with_http_headers $query, $cookie, $template->output;