Bug 19750: Overdues without a fine rule add warnings to log
[koha.git] / circ / returns.pl
blob247a71eab9aea03cac161c4ad9cc13c86dbb8e08
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 CGI qw ( -utf8 );
36 use DateTime;
37 use C4::Context;
38 use C4::Auth qw/:DEFAULT get_session/;
39 use C4::Output;
40 use C4::Circulation;
41 use C4::Print;
42 use C4::Reserves;
43 use C4::Biblio;
44 use C4::Items;
45 use C4::Members;
46 use C4::Members::Messaging;
47 use C4::Koha; # FIXME : is it still useful ?
48 use C4::RotatingCollections;
49 use Koha::AuthorisedValues;
50 use Koha::DateUtils;
51 use Koha::Calendar;
52 use Koha::BiblioFrameworks;
53 use Koha::Holds;
54 use Koha::Items;
55 use Koha::Patrons;
57 my $query = new CGI;
59 #getting the template
60 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
62 template_name => "circ/returns.tt",
63 query => $query,
64 type => "intranet",
65 authnotrequired => 0,
66 flagsrequired => { circulate => "circulate_remaining_permissions" },
70 my $sessionID = $query->cookie("CGISESSID");
71 my $session = get_session($sessionID);
72 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
73 # no branch set we can't return
74 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
75 exit;
78 # Print a reserve slip on this page
79 if ( $query->param('print_slip') ) {
80 $template->param(
81 print_slip => 1,
82 borrowernumber => scalar $query->param('borrowernumber'),
83 biblionumber => scalar $query->param('biblionumber'),
87 #####################
88 #Global vars
89 my $printers = GetPrinters();
90 my $userenv = C4::Context->userenv;
91 my $userenv_branch = $userenv->{'branch'} // '';
92 my $printer = $userenv->{'branchprinter'} // '';
93 my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
95 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
97 # Some code to handle the error if there is no branch or printer setting.....
100 # Set up the item stack ....
101 my %returneditems;
102 my %riduedate;
103 my %riborrowernumber;
104 my @inputloop;
105 foreach ( $query->param ) {
106 my $counter;
107 if (/ri-(\d*)/) {
108 $counter = $1;
109 if ($counter > 20) {
110 next;
113 else {
114 next;
117 my %input;
118 my $barcode = $query->param("ri-$counter");
119 my $duedate = $query->param("dd-$counter");
120 my $borrowernumber = $query->param("bn-$counter");
121 $counter++;
123 # decode barcode ## Didn't we already decode them before passing them back last time??
124 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
125 $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
127 ######################
128 #Are these lines still useful ?
129 $returneditems{$counter} = $barcode;
130 $riduedate{$counter} = $duedate;
131 $riborrowernumber{$counter} = $borrowernumber;
133 #######################
134 $input{counter} = $counter;
135 $input{barcode} = $barcode;
136 $input{duedate} = $duedate;
137 $input{borrowernumber} = $borrowernumber;
138 push( @inputloop, \%input );
141 ############
142 # Deal with the requests....
144 if ($query->param('WT-itemNumber')){
145 updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
148 if ( $query->param('reserve_id') ) {
149 my $itemnumber = $query->param('itemnumber');
150 my $borrowernumber = $query->param('borrowernumber');
151 my $reserve_id = $query->param('reserve_id');
152 my $diffBranchReturned = $query->param('diffBranch');
153 my $cancel_reserve = $query->param('cancel_reserve');
154 # fix up item type for display
155 my $item = Koha::Items->find( $itemnumber );
156 my $biblio = $item->biblio;
158 if ( $cancel_reserve ) {
159 my $hold = Koha::Holds->find( $reserve_id );
160 if ( $hold ) {
161 $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire } );
162 } # FIXME else?
163 } else {
164 my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
165 # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
166 # i.e., whether to apply waiting status
167 ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id );
169 # check if we have other reserves for this document, if we have a return send the message of transfer
170 my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
172 my $patron = Koha::Patrons->find( $nextreservinfo );
173 my $name = $patron ? $patron->surname . ", " . $patron->title . " " . $patron->firstname : '';
174 if ( $messages->{'transfert'} ) {
175 $template->param(
176 itemtitle => $biblio->title,
177 itemnumber => $item->itemnumber,
178 itembiblionumber => $biblio->biblionumber,
179 iteminfo => $biblio->author,
180 name => $name,
181 borrowernumber => $borrowernumber,
182 borcnum => $patron->cardnumber,
183 borfirstname => $patron->firstname,
184 borsurname => $patron->surname,
185 borcategory => $patron->category->description,
186 diffbranch => 1,
191 my $borrower;
192 my $returned = 0;
193 my $messages;
194 my $issue;
195 my $itemnumber;
196 my $barcode = $query->param('barcode');
197 my $exemptfine = $query->param('exemptfine');
198 if (
199 $exemptfine &&
200 !C4::Auth::haspermission(C4::Context->userenv->{'id'}, {'updatecharges' => 'writeoff'})
202 # silently prevent unauthorized operator from forgiving overdue
203 # fines by manually tweaking form parameters
204 undef $exemptfine;
206 my $dropboxmode = $query->param('dropboxmode');
207 my $dotransfer = $query->param('dotransfer');
208 my $canceltransfer = $query->param('canceltransfer');
209 my $dest = $query->param('dest');
210 my $calendar = Koha::Calendar->new( branchcode => $userenv_branch );
211 #dropbox: get last open day (today - 1)
212 my $today = DateTime->now( time_zone => C4::Context->tz());
213 my $dropboxdate = $calendar->addDate($today, -1);
215 my $return_date_override = $query->param('return_date_override');
216 my $return_date_override_remember =
217 $query->param('return_date_override_remember');
218 if ($return_date_override) {
219 if ( C4::Context->preference('SpecifyReturnDate') ) {
220 my $return_date_override_dt = eval {dt_from_string( $return_date_override ) };
221 if ( $return_date_override_dt ) {
222 # note that we've overriden the return date
223 $template->param( return_date_was_overriden => 1);
224 # Save the original format if we are remembering for this series
225 $template->param(
226 return_date_override => $return_date_override,
227 return_date_override_remember => 1
228 ) if ($return_date_override_remember);
230 $return_date_override =
231 DateTime::Format::MySQL->format_datetime( $return_date_override_dt );
234 else {
235 $return_date_override = q{};
239 if ($dotransfer){
240 # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
241 my $transferitem = $query->param('transferitem');
242 my $tobranch = $query->param('tobranch');
243 ModItemTransfer($transferitem, $userenv_branch, $tobranch);
246 if ($canceltransfer){
247 $itemnumber=$query->param('itemnumber');
248 DeleteTransfer($itemnumber);
249 if($dest eq "ttr"){
250 print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl");
251 exit;
252 } else {
253 $template->param( transfercancelled => 1);
257 # actually return book and prepare item table.....
258 my $returnbranch;
259 if ($barcode) {
260 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
261 $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
262 my $item = Koha::Items->find({ barcode => $barcode });
264 if ( $item ) {
265 $itemnumber = $item->itemnumber;
266 # Check if we should display a checkin message, based on the the item
267 # type of the checked in item
268 my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
269 if ( $itemtype && $itemtype->checkinmsg ) {
270 $template->param(
271 checkinmsg => $itemtype->checkinmsg,
272 checkinmsgtype => $itemtype->checkinmsgtype,
276 # make sure return branch respects home branch circulation rules, default to homebranch
277 my $hbr = GetBranchItemRule($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
278 $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $userenv_branch; # can be noreturn, homebranch or holdingbranch
280 my $materials = $item->materials;
281 my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
282 $materials = $descriptions->{lib} // $materials;
284 my $checkout = $item->checkout;
285 my $biblio = $item->biblio;
286 $template->param(
287 title => $biblio->title,
288 homebranch => $item->homebranch,
289 holdingbranch => $item->holdingbranch,
290 returnbranch => $returnbranch,
291 author => $biblio->author,
292 itembarcode => $item->barcode,
293 itemtype => $item->effective_itemtype,
294 ccode => $item->ccode,
295 itembiblionumber => $biblio->biblionumber,
296 biblionumber => $biblio->biblionumber,
297 borrower => $borrower,
298 additional_materials => $materials,
299 issue => $checkout,
301 } # FIXME else we should not call AddReturn but set BadBarcode directly instead
303 my %input = (
304 counter => 0,
305 first => 1,
306 barcode => $barcode,
310 # do the return
311 ( $returned, $messages, $issue, $borrower ) =
312 AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate );
314 if ($returned) {
315 my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
316 my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
317 my $duedate = $date_due_dt->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($date_due_dt, DateTime->now()) == -1);
325 } else {
326 $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $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 $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
343 my $waiting_holds = $patron->holds->search({ found => 'W', branchcode => $userenv_branch })->count;
344 if ($waiting_holds > 0) {
345 $template->param(
346 waiting_holds => $waiting_holds,
347 holdsborrowernumber => $borrower->{'borrowernumber'},
348 holdsfirstname => $borrower->{'firstname'},
349 holdssurname => $borrower->{'surname'},
353 } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} ) {
354 $input{duedate} = 0;
355 $returneditems{0} = $barcode;
356 $riduedate{0} = 0;
357 push( @inputloop, \%input );
359 $template->param( privacy => $borrower->{privacy} );
361 $template->param( inputloop => \@inputloop );
363 my $found = 0;
364 my $waiting = 0;
365 my $reserved = 0;
367 # new op dev : we check if the document must be returned to his homebranch directly,
368 # if the document is transfered, we have warning message .
370 if ( $messages->{'WasTransfered'} ) {
371 $template->param(
372 found => 1,
373 transfer => 1,
374 itemnumber => $itemnumber,
378 if ( $messages->{'NeedsTransfer'} ){
379 $template->param(
380 found => 1,
381 needstransfer => $messages->{'NeedsTransfer'},
382 itemnumber => $itemnumber,
386 if ( $messages->{'Wrongbranch'} ){
387 $template->param(
388 wrongbranch => 1,
389 rightbranch => $messages->{'Wrongbranch'}->{'Rightbranch'},
393 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
395 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
396 $template->param(
397 WrongTransfer => 1,
398 TransferWaitingAt => $messages->{'WrongTransfer'},
399 WrongTransferItem => $messages->{'WrongTransferItem'},
400 itemnumber => $itemnumber,
403 my $reserve = $messages->{'ResFound'};
404 if ( $reserve ) {
405 my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
406 my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
407 $template->param(
408 # FIXME The full patron object should be passed to the template
409 wname => $name,
410 wborfirstname => $patron->firstname,
411 wborsurname => $patron->surname,
412 wborcategory => $patron->category->description,
413 wbortitle => $patron->title,
414 wborphone => $patron->phone,
415 wboremail => $patron->email,
416 streetnumber => $patron->streetnumber,
417 address => $patron->address,
418 address2 => $patron->address2,
419 city => $patron->city,
420 zipcode => $patron->zipcode,
421 state => $patron->state,
422 country => $patron->country,
423 wborrowernumber => $reserve->{'borrowernumber'},
424 wborcnum => $patron->cardnumber,
427 $template->param(
428 wtransfertFrom => $userenv_branch,
433 # reserve found and item arrived at the expected branch
435 if ( $messages->{'ResFound'}) {
436 my $reserve = $messages->{'ResFound'};
437 my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
438 my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
439 if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
440 if ( $reserve->{'ResFound'} eq "Waiting" ) {
441 $template->param(
442 waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ),
444 } elsif ( $reserve->{'ResFound'} eq "Reserved" ) {
445 $template->param(
446 intransit => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
447 transfertodo => ($userenv_branch eq $reserve->{'branchcode'} ? 0 : 1 ),
448 reserve_id => $reserve->{reserve_id},
449 reserved => 1,
453 # same params for Waiting or Reserved
454 $template->param(
455 # FIXME The full patron object should be passed to the template
456 found => 1,
457 name => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
458 borfirstname => $patron->firstname,
459 borsurname => $patron->surname,
460 borcategory => $patron->category->description,
461 bortitle => $patron->title,
462 borphone => $patron->phone,
463 boremail => $patron->email,
464 boraddress => $patron->address,
465 boraddress2 => $patron->address2,
466 streetnumber => $patron->streetnumber,
467 city => $patron->city,
468 zipcode => $patron->zipcode,
469 state => $patron->state,
470 country => $patron->country,
471 borcnum => $patron->cardnumber,
472 debarred => $patron->debarred,
473 gonenoaddress => $patron->gonenoaddress,
474 barcode => $barcode,
475 destbranch => $reserve->{'branchcode'},
476 borrowernumber => $reserve->{'borrowernumber'},
477 itemnumber => $reserve->{'itemnumber'},
478 reservenotes => $reserve->{'reservenotes'},
479 reserve_id => $reserve->{reserve_id},
480 bormessagepref => $holdmsgpreferences->{'transports'},
482 } # else { ; } # error?
485 # Error Messages
486 my @errmsgloop;
487 foreach my $code ( keys %$messages ) {
488 my %err;
489 my $exit_required_p = 0;
490 if ( $code eq 'BadBarcode' ) {
491 $err{badbarcode} = 1;
492 $err{msg} = $messages->{'BadBarcode'};
494 elsif ( $code eq 'NotIssued' ) {
495 $err{notissued} = 1;
496 $err{msg} = '';
497 $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
499 elsif ( $code eq 'LocalUse' ) {
500 $err{localuse} = 1;
502 elsif ( $code eq 'WasLost' ) {
503 $err{waslost} = 1;
504 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfLostItems");
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 $patron = Koha::Patrons->find( $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} = $patron->borrowernumber;
592 $ri{borcnum} = $patron->cardnumber;
593 $ri{borfirstname} = $patron->firstname;
594 $ri{borsurname} = $patron->surname;
595 $ri{bortitle} = $patron->title;
596 $ri{bornote} = $patron->borrowernotes;
597 $ri{borcategorycode}= $patron->categorycode;
598 $ri{borissuescount} = $patron->checkouts->count;
600 else {
601 $ri{borrowernumber} = $riborrowernumber{$_};
604 my $item = Koha::Items->find({ barcode => $bar_code });
605 my $biblio = $item->biblio;
606 # FIXME pass $item to the template and we are done here...
607 $ri{itembiblionumber} = $biblio->biblionumber;
608 $ri{itemtitle} = $biblio->title;
609 $ri{itemauthor} = $biblio->author;
610 $ri{itemcallnumber} = $item->itemcallnumber;
611 $ri{dateaccessioned} = $item->dateaccessioned;
612 $ri{itemtype} = $item->effective_itemtype;
613 $ri{itemnote} = $item->itemnotes;
614 $ri{itemnotes_nonpublic} = $item->itemnotes_nonpublic;
615 $ri{ccode} = $item->ccode;
616 $ri{enumchron} = $item->enumchron;
617 $ri{itemnumber} = $item->itemnumber;
618 $ri{barcode} = $bar_code;
619 $ri{homebranch} = $item->homebranch;
620 $ri{holdingbranch} = $item->holdingbranch;
622 $ri{location} = $biblio->{'location'};
623 my $shelfcode = $ri{'location'};
624 $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
627 else {
628 last;
630 push @riloop, \%ri;
633 $template->param(
634 riloop => \@riloop,
635 printer => $printer,
636 errmsgloop => \@errmsgloop,
637 exemptfine => $exemptfine,
638 dropboxmode => $dropboxmode,
639 dropboxdate => output_pref($dropboxdate),
640 forgivemanualholdsexpire => $forgivemanualholdsexpire,
641 overduecharges => $overduecharges,
642 AudioAlerts => C4::Context->preference("AudioAlerts"),
645 $itemnumber = GetItemnumberFromBarcode( $barcode );
646 if ( $itemnumber ) {
647 my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
648 if ( $holdingBranch and $collectionBranch ) {
649 $holdingBranch //= '';
650 $collectionBranch //= $returnbranch;
651 if ( ! ( $holdingBranch eq $collectionBranch ) ) {
652 $template->param(
653 collectionItemNeedsTransferred => 1,
654 collectionBranch => $collectionBranch,
655 itemnumber => $itemnumber,
661 # Checking if there is a Fast Cataloging Framework
662 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
664 # actually print the page!
665 output_html_with_http_headers $query, $cookie, $template->output;