Bug 19697: Move template JavaScript to the footer: Search results
[koha.git] / circ / returns.pl
blobe2c815b1e3a746984f28f9566aa0fd0308953af6
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 # FIXME There are weird things going on with $patron and $borrowernumber in this script
35 use Carp 'verbose';
36 $SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
38 use CGI qw ( -utf8 );
39 use DateTime;
40 use C4::Context;
41 use C4::Auth qw/:DEFAULT get_session/;
42 use C4::Output;
43 use C4::Circulation;
44 use C4::Print;
45 use C4::Reserves;
46 use C4::Biblio;
47 use C4::Items;
48 use C4::Members;
49 use C4::Members::Messaging;
50 use C4::Koha; # FIXME : is it still useful ?
51 use C4::RotatingCollections;
52 use Koha::AuthorisedValues;
53 use Koha::DateUtils;
54 use Koha::Calendar;
55 use Koha::BiblioFrameworks;
56 use Koha::Checkouts;
57 use Koha::Holds;
58 use Koha::Items;
59 use Koha::Patrons;
61 my $query = new CGI;
63 #getting the template
64 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
66 template_name => "circ/returns.tt",
67 query => $query,
68 type => "intranet",
69 authnotrequired => 0,
70 flagsrequired => { circulate => "circulate_remaining_permissions" },
74 my $sessionID = $query->cookie("CGISESSID");
75 my $session = get_session($sessionID);
76 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
77 # no branch set we can't return
78 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
79 exit;
82 # Print a reserve slip on this page
83 if ( $query->param('print_slip') ) {
84 $template->param(
85 print_slip => 1,
86 borrowernumber => scalar $query->param('borrowernumber'),
87 biblionumber => scalar $query->param('biblionumber'),
91 #####################
92 #Global vars
93 my $printers = GetPrinters();
94 my $userenv = C4::Context->userenv;
95 my $userenv_branch = $userenv->{'branch'} // '';
96 my $printer = $userenv->{'branchprinter'} // '';
97 my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
99 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
101 # Some code to handle the error if there is no branch or printer setting.....
104 # Set up the item stack ....
105 my %returneditems;
106 my %riduedate;
107 my %riborrowernumber;
108 my @inputloop;
109 foreach ( $query->param ) {
110 my $counter;
111 if (/ri-(\d*)/) {
112 $counter = $1;
113 if ($counter > 20) {
114 next;
117 else {
118 next;
121 my %input;
122 my $barcode = $query->param("ri-$counter");
123 my $duedate = $query->param("dd-$counter");
124 my $borrowernumber = $query->param("bn-$counter");
125 $counter++;
127 # decode barcode ## Didn't we already decode them before passing them back last time??
128 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
129 $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
131 ######################
132 #Are these lines still useful ?
133 $returneditems{$counter} = $barcode;
134 $riduedate{$counter} = $duedate;
135 $riborrowernumber{$counter} = $borrowernumber;
137 #######################
138 $input{counter} = $counter;
139 $input{barcode} = $barcode;
140 $input{duedate} = $duedate;
141 $input{borrowernumber} = $borrowernumber;
142 push( @inputloop, \%input );
145 ############
146 # Deal with the requests....
148 if ($query->param('WT-itemNumber')){
149 updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
152 if ( $query->param('reserve_id') ) {
153 my $itemnumber = $query->param('itemnumber');
154 my $borrowernumber = $query->param('borrowernumber');
155 my $reserve_id = $query->param('reserve_id');
156 my $diffBranchReturned = $query->param('diffBranch');
157 my $cancel_reserve = $query->param('cancel_reserve');
158 # fix up item type for display
159 my $item = Koha::Items->find( $itemnumber );
160 my $biblio = $item->biblio;
162 if ( $cancel_reserve ) {
163 my $hold = Koha::Holds->find( $reserve_id );
164 if ( $hold ) {
165 $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire } );
166 } # FIXME else?
167 } else {
168 my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
169 # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
170 # i.e., whether to apply waiting status
171 ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id );
173 # check if we have other reserves for this document, if we have a return send the message of transfer
174 my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
176 my $patron = Koha::Patrons->find( $nextreservinfo );
177 my $name = $patron ? $patron->surname . ", " . $patron->title . " " . $patron->firstname : '';
178 if ( $messages->{'transfert'} ) {
179 $template->param(
180 itemtitle => $biblio->title,
181 itemnumber => $item->itemnumber,
182 itembiblionumber => $biblio->biblionumber,
183 iteminfo => $biblio->author,
184 name => $name,
185 borrowernumber => $borrowernumber,
186 borcnum => $patron->cardnumber,
187 borfirstname => $patron->firstname,
188 borsurname => $patron->surname,
189 borcategory => $patron->category->description,
190 diffbranch => 1,
195 my $borrower;
196 my $returned = 0;
197 my $messages;
198 my $issue;
199 my $itemnumber;
200 my $barcode = $query->param('barcode');
201 my $exemptfine = $query->param('exemptfine');
202 if (
203 $exemptfine &&
204 !C4::Auth::haspermission(C4::Context->userenv->{'id'}, {'updatecharges' => 'writeoff'})
206 # silently prevent unauthorized operator from forgiving overdue
207 # fines by manually tweaking form parameters
208 undef $exemptfine;
210 my $dropboxmode = $query->param('dropboxmode');
211 my $dotransfer = $query->param('dotransfer');
212 my $canceltransfer = $query->param('canceltransfer');
213 my $dest = $query->param('dest');
214 my $calendar = Koha::Calendar->new( branchcode => $userenv_branch );
215 #dropbox: get last open day (today - 1)
216 my $today = DateTime->now( time_zone => C4::Context->tz());
217 my $dropboxdate = $calendar->addDate($today, -1);
219 my $return_date_override = $query->param('return_date_override');
220 my $return_date_override_remember =
221 $query->param('return_date_override_remember');
222 if ($return_date_override) {
223 if ( C4::Context->preference('SpecifyReturnDate') ) {
224 my $return_date_override_dt = eval {dt_from_string( $return_date_override ) };
225 if ( $return_date_override_dt ) {
226 # note that we've overriden the return date
227 $template->param( return_date_was_overriden => 1);
228 # Save the original format if we are remembering for this series
229 $template->param(
230 return_date_override => $return_date_override,
231 return_date_override_remember => 1
232 ) if ($return_date_override_remember);
234 $return_date_override =
235 DateTime::Format::MySQL->format_datetime( $return_date_override_dt );
238 else {
239 $return_date_override = q{};
243 if ($dotransfer){
244 # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
245 my $transferitem = $query->param('transferitem');
246 my $tobranch = $query->param('tobranch');
247 ModItemTransfer($transferitem, $userenv_branch, $tobranch);
250 if ($canceltransfer){
251 $itemnumber=$query->param('itemnumber');
252 DeleteTransfer($itemnumber);
253 if($dest eq "ttr"){
254 print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl");
255 exit;
256 } else {
257 $template->param( transfercancelled => 1);
261 # actually return book and prepare item table.....
262 my $returnbranch;
263 if ($barcode) {
264 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
265 $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
266 my $item = Koha::Items->find({ barcode => $barcode });
268 if ( $item ) {
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( $item->effective_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($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
281 $returnbranch = $item->$hbr;
283 my $materials = $item->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 my $biblio = $item->biblio;
290 $template->param(
291 title => $biblio->title,
292 homebranch => $item->homebranch,
293 holdingbranch => $item->holdingbranch,
294 returnbranch => $returnbranch,
295 author => $biblio->author,
296 itembarcode => $item->barcode,
297 itemtype => $item->effective_itemtype,
298 ccode => $item->ccode,
299 itembiblionumber => $biblio->biblionumber,
300 biblionumber => $biblio->biblionumber,
301 borrower => $borrower,
302 additional_materials => $materials,
303 issue => $issue,
305 } # FIXME else we should not call AddReturn but set BadBarcode directly instead
307 my %input = (
308 counter => 0,
309 first => 1,
310 barcode => $barcode,
314 # do the return
315 ( $returned, $messages, $issue, $borrower ) =
316 AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
318 if ($returned) {
319 my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
320 my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
321 my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
322 $returneditems{0} = $barcode;
323 $riborrowernumber{0} = $borrower->{'borrowernumber'};
324 $riduedate{0} = $duedate;
325 $input{borrowernumber} = $borrower->{'borrowernumber'};
326 $input{duedate} = $duedate;
327 unless ( $dropboxmode ) {
328 $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, DateTime->now()) == -1);
329 } else {
330 $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
332 push( @inputloop, \%input );
334 if ( C4::Context->preference("FineNotifyAtCheckin") ) {
335 my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
336 my $balance = $patron->account->balance;
338 if ($balance > 0) {
339 $template->param( fines => sprintf("%.2f", $balance) );
340 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
344 if (C4::Context->preference("WaitingNotifyAtCheckin") ) {
345 #Check for waiting holds
346 my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
347 my $waiting_holds = $patron->holds->search({ found => 'W', branchcode => $userenv_branch })->count;
348 if ($waiting_holds > 0) {
349 $template->param(
350 waiting_holds => $waiting_holds,
351 holdsborrowernumber => $borrower->{'borrowernumber'},
352 holdsfirstname => $borrower->{'firstname'},
353 holdssurname => $borrower->{'surname'},
357 } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} ) {
358 $input{duedate} = 0;
359 $returneditems{0} = $barcode;
360 $riduedate{0} = 0;
361 push( @inputloop, \%input );
363 $template->param( privacy => $borrower->{privacy} );
365 $template->param( inputloop => \@inputloop );
367 my $found = 0;
368 my $waiting = 0;
369 my $reserved = 0;
371 # new op dev : we check if the document must be returned to his homebranch directly,
372 # if the document is transfered, we have warning message .
374 if ( $messages->{'WasTransfered'} ) {
375 $template->param(
376 found => 1,
377 transfer => 1,
378 itemnumber => $itemnumber,
382 if ( $messages->{'NeedsTransfer'} ){
383 $template->param(
384 found => 1,
385 needstransfer => $messages->{'NeedsTransfer'},
386 itemnumber => $itemnumber,
390 if ( $messages->{'Wrongbranch'} ){
391 $template->param(
392 wrongbranch => 1,
393 rightbranch => $messages->{'Wrongbranch'}->{'Rightbranch'},
397 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
399 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
400 $template->param(
401 WrongTransfer => 1,
402 TransferWaitingAt => $messages->{'WrongTransfer'},
403 WrongTransferItem => $messages->{'WrongTransferItem'},
404 itemnumber => $itemnumber,
407 my $reserve = $messages->{'ResFound'};
408 if ( $reserve ) {
409 my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
410 my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
411 $template->param(
412 # FIXME The full patron object should be passed to the template
413 wname => $name,
414 wborfirstname => $patron->firstname,
415 wborsurname => $patron->surname,
416 wborcategory => $patron->category->description,
417 wbortitle => $patron->title,
418 wborphone => $patron->phone,
419 wboremail => $patron->email,
420 streetnumber => $patron->streetnumber,
421 address => $patron->address,
422 address2 => $patron->address2,
423 city => $patron->city,
424 zipcode => $patron->zipcode,
425 state => $patron->state,
426 country => $patron->country,
427 wborrowernumber => $reserve->{'borrowernumber'},
428 wborcnum => $patron->cardnumber,
431 $template->param(
432 wtransfertFrom => $userenv_branch,
437 # reserve found and item arrived at the expected branch
439 if ( $messages->{'ResFound'}) {
440 my $reserve = $messages->{'ResFound'};
441 my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
442 my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
443 if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
444 if ( $reserve->{'ResFound'} eq "Waiting" ) {
445 $template->param(
446 waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
448 } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
449 $template->param(
450 intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
451 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
452 reserve_id => $reserve->{reserve_id},
453 reserved => 1,
457 # same params for Waiting or Reserved
458 $template->param(
459 # FIXME The full patron object should be passed to the template
460 found => 1,
461 name => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
462 borfirstname => $patron->firstname,
463 borsurname => $patron->surname,
464 borcategory => $patron->category->description,
465 bortitle => $patron->title,
466 borphone => $patron->phone,
467 boremail => $patron->email,
468 boraddress => $patron->address,
469 boraddress2 => $patron->address2,
470 streetnumber => $patron->streetnumber,
471 city => $patron->city,
472 zipcode => $patron->zipcode,
473 state => $patron->state,
474 country => $patron->country,
475 borcnum => $patron->cardnumber,
476 debarred => $patron->debarred,
477 gonenoaddress => $patron->gonenoaddress,
478 barcode => $barcode,
479 destbranch => $reserve->{'branchcode'},
480 borrowernumber => $reserve->{'borrowernumber'},
481 itemnumber => $reserve->{'itemnumber'},
482 reservenotes => $reserve->{'reservenotes'},
483 reserve_id => $reserve->{reserve_id},
484 bormessagepref => $holdmsgpreferences->{'transports'},
486 } # else { ; } # error?
489 # Error Messages
490 my @errmsgloop;
491 foreach my $code ( keys %$messages ) {
492 my %err;
493 my $exit_required_p = 0;
494 if ( $code eq 'BadBarcode' ) {
495 $err{badbarcode} = 1;
496 $err{msg} = $messages->{'BadBarcode'};
498 elsif ( $code eq 'NotIssued' ) {
499 $err{notissued} = 1;
500 $err{msg} = '';
501 $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
503 elsif ( $code eq 'LocalUse' ) {
504 $err{localuse} = 1;
506 elsif ( $code eq 'WasLost' ) {
507 $err{waslost} = 1;
508 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfLostItems");
510 elsif ( $code eq 'LostItemFeeRefunded' ) {
511 $template->param( LostItemFeeRefunded => 1 );
513 elsif ( $code eq 'ResFound' ) {
514 ; # FIXME... anything to do here?
516 elsif ( $code eq 'WasReturned' ) {
517 ; # FIXME... anything to do here?
519 elsif ( $code eq 'WasTransfered' ) {
520 ; # FIXME... anything to do here?
522 elsif ( $code eq 'withdrawn' ) {
523 $err{withdrawn} = 1;
524 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
526 elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
527 if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
528 $err{ispermanent} = 1;
529 $err{msg} = $messages->{'IsPermanent'};
532 elsif ( $code eq 'WrongTransfer' ) {
533 ; # FIXME... anything to do here?
535 elsif ( $code eq 'WrongTransferItem' ) {
536 ; # FIXME... anything to do here?
538 elsif ( $code eq 'NeedsTransfer' ) {
540 elsif ( $code eq 'Wrongbranch' ) {
542 elsif ( $code eq 'Debarred' ) {
543 $err{debarred} = $messages->{'Debarred'};
544 $err{debarcardnumber} = $borrower->{cardnumber};
545 $err{debarborrowernumber} = $borrower->{borrowernumber};
546 $err{debarname} = "$borrower->{firstname} $borrower->{surname}";
548 elsif ( $code eq 'PrevDebarred' ) {
549 $err{prevdebarred} = $messages->{'PrevDebarred'};
551 elsif ( $code eq 'ForeverDebarred' ) {
552 $err{foreverdebarred} = $messages->{'ForeverDebarred'};
554 elsif ( $code eq 'NotForLoanStatusUpdated' ) {
555 $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
557 elsif ( $code eq 'DataCorrupted' ) {
558 $err{data_corrupted} = 1;
560 else {
561 die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die.
562 # This forces the issue of staying in sync w/ Circulation.pm
564 if (%err) {
565 push( @errmsgloop, \%err );
567 last if $exit_required_p;
569 $template->param( errmsgloop => \@errmsgloop );
571 #set up so only the last 8 returned items display (make for faster loading pages)
572 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
573 my $count = 0;
574 my @riloop;
575 my $shelflocations =
576 { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
577 foreach ( sort { $a <=> $b } keys %returneditems ) {
578 my %ri;
579 if ( $count++ < $returned_counter ) {
580 my $bar_code = $returneditems{$_};
581 if ($riduedate{$_}) {
582 my $duedate = dt_from_string( $riduedate{$_}, 'sql');
583 $ri{year} = $duedate->year();
584 $ri{month} = $duedate->month();
585 $ri{day} = $duedate->day();
586 $ri{hour} = $duedate->hour();
587 $ri{minute} = $duedate->minute();
588 $ri{duedate} = output_pref($duedate);
589 my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
590 unless ( $dropboxmode ) {
591 $ri{return_overdue} = 1 if (DateTime->compare($duedate, DateTime->now()) == -1);
592 } else {
593 $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
595 $ri{borrowernumber} = $patron->borrowernumber;
596 $ri{borcnum} = $patron->cardnumber;
597 $ri{borfirstname} = $patron->firstname;
598 $ri{borsurname} = $patron->surname;
599 $ri{bortitle} = $patron->title;
600 $ri{bornote} = $patron->borrowernotes;
601 $ri{borcategorycode}= $patron->categorycode;
602 $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
604 else {
605 $ri{borrowernumber} = $riborrowernumber{$_};
608 my $item = Koha::Items->find({ barcode => $bar_code });
609 my $biblio = $item->biblio;
610 # FIXME pass $item to the template and we are done here...
611 $ri{itembiblionumber} = $biblio->biblionumber;
612 $ri{itemtitle} = $biblio->title;
613 $ri{itemauthor} = $biblio->author;
614 $ri{itemcallnumber} = $item->itemcallnumber;
615 $ri{dateaccessioned} = $item->dateaccessioned;
616 $ri{itemtype} = $item->effective_itemtype;
617 $ri{itemnote} = $item->itemnotes;
618 $ri{itemnotes_nonpublic} = $item->itemnotes_nonpublic;
619 $ri{ccode} = $item->ccode;
620 $ri{enumchron} = $item->enumchron;
621 $ri{itemnumber} = $item->itemnumber;
622 $ri{barcode} = $bar_code;
623 $ri{homebranch} = $item->homebranch;
624 $ri{holdingbranch} = $item->holdingbranch;
626 $ri{location} = $biblio->{'location'};
627 my $shelfcode = $ri{'location'};
628 $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
631 else {
632 last;
634 push @riloop, \%ri;
637 $template->param(
638 riloop => \@riloop,
639 printer => $printer,
640 errmsgloop => \@errmsgloop,
641 exemptfine => $exemptfine,
642 dropboxmode => $dropboxmode,
643 dropboxdate => output_pref($dropboxdate),
644 forgivemanualholdsexpire => $forgivemanualholdsexpire,
645 overduecharges => $overduecharges,
646 AudioAlerts => C4::Context->preference("AudioAlerts"),
649 $itemnumber = GetItemnumberFromBarcode( $barcode );
650 if ( $itemnumber ) {
651 my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
652 if ( $holdingBranch and $collectionBranch ) {
653 $holdingBranch //= '';
654 $collectionBranch //= $returnbranch;
655 if ( ! ( $holdingBranch eq $collectionBranch ) ) {
656 $template->param(
657 collectionItemNeedsTransferred => 1,
658 collectionBranch => $collectionBranch,
659 itemnumber => $itemnumber,
665 # Checking if there is a Fast Cataloging Framework
666 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
668 # actually print the page!
669 output_html_with_http_headers $query, $cookie, $template->output;