3 # Copyright 2000-2002 Katipo Communications
5 # 2007-2010 BibLibre, Paul POULAIN
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>.
26 script to execute returns of books
32 # FIXME There are weird things going on with $patron and $borrowernumber in this script
37 use C4::Auth qw( get_template_and_user get_session haspermission );
38 use C4::Circulation qw( barcodedecode GetBranchItemRule AddReturn updateWrongTransfer LostItem );
40 use C4::Items qw( ModItemTransfer );
41 use C4::Members::Messaging;
43 use C4::Output qw( output_html_with_http_headers );
44 use C4::Reserves qw( ModReserve ModReserveAffect GetOtherReserves );
45 use C4::RotatingCollections;
46 use Koha::AuthorisedValues;
47 use Koha::BiblioFrameworks;
50 use Koha::CirculationRules;
51 use Koha::DateUtils qw( dt_from_string );
53 use Koha::Item::Transfers;
61 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
63 template_name => "circ/returns.tt",
66 flagsrequired => { circulate => "circulate_remaining_permissions" },
70 my $sessionID = $query->cookie("CGISESSID");
71 my $session = get_session($sessionID);
72 my $desk_id = C4::Context->userenv->{"desk_id"} || '';
74 # Print a reserve slip on this page
75 if ( $query->param('print_slip') ) {
78 reserve_id => scalar $query->param('reserve_id'),
83 if ( $query->param('recall_slip') ) {
86 recall_id => scalar $query->param('recall_id'),
93 my $userenv = C4::Context->userenv;
94 my $userenv_branch = $userenv->{'branch'} // '';
95 my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
97 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') eq 'production');
99 #set up so only the last 8 returned items display (make for faster loading pages)
100 my $returned_counter = C4::Context->preference('numReturnedItemsToShow') || 8;
102 # Set up the item stack ....
105 my %riborrowernumber;
107 foreach ( $query->param ) {
111 if ($counter > $returned_counter) {
120 my $barcode = $query->param("ri-$counter");
121 my $duedate = $query->param("dd-$counter");
122 my $borrowernumber = $query->param("bn-$counter");
125 # decode barcode ## Didn't we already decode them before passing them back last time??
126 $barcode = barcodedecode($barcode) if $barcode;
128 ######################
129 #Are these lines still useful ?
130 $returneditems{$counter} = $barcode;
131 $riduedate{$counter} = $duedate;
132 $riborrowernumber{$counter} = $borrowernumber;
134 #######################
135 $input{counter} = $counter;
136 $input{barcode} = $barcode;
137 $input{duedate} = $duedate;
138 $input{borrowernumber} = $borrowernumber;
139 push( @inputloop, \%input );
143 # Deal with the requests....
144 my $itemnumber = $query->param('itemnumber');
145 if ( $query->param('reserve_id') ) {
146 my $borrowernumber = $query->param('borrowernumber');
147 my $reserve_id = $query->param('reserve_id');
148 my $diffBranchReturned = $query->param('diffBranch');
149 my $cancel_reserve = $query->param('cancel_reserve');
150 # fix up item type for display
151 my $item = Koha::Items->find( $itemnumber );
152 my $biblio = $item->biblio;
154 if ( $cancel_reserve ) {
155 my $hold = Koha::Holds->find( $reserve_id );
157 $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire } );
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( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_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($itemnumber);
168 my $patron = Koha::Patrons->find( $nextreservinfo );
169 if ( $messages->{'transfert'} ) {
171 itemtitle => $biblio->title,
172 itembiblionumber => $biblio->biblionumber,
173 iteminfo => $biblio->author,
180 if ( $query->param('recall_id') ) {
181 my $recall = Koha::Recalls->find( scalar $query->param('recall_id') );
182 my $itemnumber = $query->param('itemnumber');
183 my $return_branch = $query->param('returnbranch');
187 if ( !$recall->item_level ) {
188 $item = Koha::Items->find( $itemnumber );
191 if ( $recall->pickup_library_id ne $return_branch ) {
192 $recall->start_transfer({ item => $item }) if !$recall->in_transit;
194 my $expirationdate = $recall->calc_expirationdate;
195 $recall->set_waiting({ item => $item, expirationdate => $expirationdate }) if !$recall->waiting;
204 my $barcode = $query->param('barcode');
205 my $exemptfine = $query->param('exemptfine');
208 !C4::Auth::haspermission(C4::Context->userenv->{'id'}, {'updatecharges' => 'writeoff'})
210 # silently prevent unauthorized operator from forgiving overdue
211 # fines by manually tweaking form parameters
214 my $dropboxmode = $query->param('dropboxmode');
215 my $dotransfer = $query->param('dotransfer');
216 my $canceltransfer = $query->param('canceltransfer');
217 my $transit = $query->param('transit');
218 my $dest = $query->param('dest');
219 #dropbox: get last open day (today - 1)
220 my $dropboxdate = Koha::Checkouts::calculate_dropbox_date();
222 my $return_date_override = $query->param('return_date_override') || q{};
223 if ($return_date_override) {
224 if ( C4::Context->preference('SpecifyReturnDate') ) {
226 # note that we've overriden the return date
227 $template->param( return_date_was_overriden => 1 );
229 my $return_date_override_remember =
230 $query->param('return_date_override_remember');
232 # Save the original format if we are remembering for this series
234 return_date_override => $return_date_override,
235 return_date_override_remember => 1
236 ) if ($return_date_override_remember);
241 # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
242 my $transferitem = $query->param('transferitem');
243 my $tobranch = $query->param('tobranch');
244 my $trigger = $query->param('trigger');
245 ModItemTransfer($transferitem, $userenv_branch, $tobranch, $trigger);
249 my $transfer = Koha::Item::Transfers->find($transit);
250 if ( $canceltransfer ) {
251 $transfer->cancel({ reason => 'Manual', force => 1});
252 if ( C4::Context->preference('UseRecalls') ) {
253 my $recall_transfer_deleted = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' });
254 if ( defined $recall_transfer_deleted ) {
255 $recall_transfer_deleted->revert_transfer;
258 $template->param( transfercancelled => 1);
262 } elsif ($canceltransfer){
263 my $item = Koha::Items->find($itemnumber);
264 my $transfer = $item->get_transfer;
265 $transfer->cancel({ reason => 'Manual', force => 1});
266 if ( C4::Context->preference('UseRecalls') ) {
267 my $recall_transfer_deleted = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' });
268 if ( defined $recall_transfer_deleted ) {
269 $recall_transfer_deleted->revert_transfer;
273 print $query->redirect("/cgi-bin/koha/circ/transferstoreceive.pl");
276 $template->param( transfercancelled => 1);
281 # actually return book and prepare item table.....
284 $barcode = barcodedecode($barcode) if $barcode;
285 my $item = Koha::Items->find({ barcode => $barcode });
288 $itemnumber = $item->itemnumber;
289 # Check if we should display a checkin message, based on the the item
290 # type of the checked in item
291 my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
292 if ( $itemtype && $itemtype->checkinmsg ) {
294 checkinmsg => $itemtype->checkinmsg,
295 checkinmsgtype => $itemtype->checkinmsgtype,
299 # make sure return branch respects home branch circulation rules, default to homebranch
300 my $hbr = Koha::CirculationRules->get_return_branch_policy($item);
301 $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $userenv_branch; # can be noreturn, homebranch or holdingbranch
303 my $materials = $item->materials;
304 my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
305 $materials = $descriptions->{lib} // $materials;
307 my $checkout = $item->checkout;
308 my $biblio = $item->biblio;
310 title => $biblio->title,
311 returnbranch => $returnbranch,
312 author => $biblio->author,
313 itembiblionumber => $biblio->biblionumber,
314 biblionumber => $biblio->biblionumber,
315 additional_materials => $materials,
319 } # FIXME else we should not call AddReturn but set BadBarcode directly instead
330 : dt_from_string( $return_date_override );
332 # Block return if multi-part and confirm has not been received
334 C4::Context->preference("CircConfirmItemParts")
337 && !$query->param('multiple_confirm');
338 $template->param( 'multiple_confirmed' => 1 )
339 if $query->param('multiple_confirm');
341 # Block return if bundle and confirm has not been received
345 && !$query->param('confirm_items_bundle_return');
346 $template->param( 'confirm_items_bundle_returned' => 1 )
347 if $query->param('confirm_items_bundle_return');
349 # is there a waiting hold for the item, for which cancellation
350 # has been requested?
352 my $waiting_holds_to_be_cancelled = $item->holds->waiting->filter_by_has_cancellation_requests;
353 while ( my $hold = $waiting_holds_to_be_cancelled->next ) {
359 ( $returned, $messages, $issue, $borrower ) =
360 AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date )
361 unless ( $needs_confirm || $bundle_confirm );
364 my $time_now = dt_from_string()->truncate( to => 'minute');
365 my $date_due_dt = dt_from_string( $issue->date_due, 'sql' );
366 my $duedate = $date_due_dt->strftime('%Y-%m-%d %H:%M');
367 $returneditems{0} = $barcode;
368 $riborrowernumber{0} = $borrower->{'borrowernumber'};
369 $riduedate{0} = $duedate;
370 $input{borrowernumber} = $borrower->{'borrowernumber'};
371 $input{duedate} = $duedate;
372 unless ( $dropboxmode ) {
373 $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, dt_from_string()) == -1);
375 $input{return_overdue} = 1 if (DateTime->compare($date_due_dt, $dropboxdate) == -1);
377 push( @inputloop, \%input );
379 if ( C4::Context->preference("FineNotifyAtCheckin") ) {
380 my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
381 my $balance = $patron->account->balance;
384 $template->param( fines => sprintf("%.2f", $balance) );
385 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
389 if (C4::Context->preference("WaitingNotifyAtCheckin") ) {
390 #Check for waiting holds
391 my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
392 my $waiting_holds = $patron->holds->search({ found => 'W', branchcode => $userenv_branch })->count;
393 if ($waiting_holds > 0) {
395 waiting_holds => $waiting_holds,
396 holdsborrowernumber => $borrower->{'borrowernumber'},
397 holdsfirstname => $borrower->{'firstname'},
398 holdssurname => $borrower->{'surname'},
403 } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) {
405 $returneditems{0} = $barcode;
407 push( @inputloop, \%input );
409 $template->param( privacy => $borrower->{privacy} );
411 if ( $needs_confirm ) {
412 $template->param( needs_confirm => $needs_confirm );
415 if ( $bundle_confirm ) {
417 items_bundle_return_confirmation => 1,
421 # Mark missing bundle items as lost and report unexpected items
422 if ( $item && $item->is_bundle && $query->param('confirm_items_bundle_return') && !$query->param('do_not_verify_items_bundle_contents') ) {
423 my $BundleLostValue = C4::Context->preference('BundleLostValue');
424 my $barcodes = $query->param('verify-items-bundle-contents-barcodes');
425 my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes );
426 my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list };
427 my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } );
428 my @unexpected_items;
431 while ( my $verify_item = $verify_items->next ) {
432 # Fix and lost statuses
433 $verify_item->itemlost(0);
436 $verify_item->datelastseen( dt_from_string() );
438 # Update last_borrowed if actual checkin
439 $verify_item->datelastborrowed( dt_from_string()->ymd() ) if $issue;
441 # Expected item, remove from lookup table
442 if ( delete $expected_items->{$verify_item->barcode} ) {
443 push @bundle_items, $verify_item;
445 # Unexpected item, warn and remove from bundle
447 $verify_item->remove_from_bundle;
448 push @unexpected_items, $verify_item;
452 $verify_item->store();
454 for my $missing_item ( keys %{$expected_items} ) {
455 my $bundle_item = $expected_items->{$missing_item};
456 # Mark as lost if it's not already lost
457 if ( !$bundle_item->itemlost ) {
458 $bundle_item->itemlost($BundleLostValue)->store();
460 # Add return_claim record if this is an actual checkin
462 $bundle_item->_result->create_related(
465 issue_id => $issue->issue_id,
466 itemnumber => $bundle_item->itemnumber,
467 borrowernumber => $issue->borrowernumber,
468 created_by => C4::Context->userenv()->{number},
469 created_on => dt_from_string
473 push @missing_items, $bundle_item;
475 # NOTE: We cannot use C4::LostItem here because the item itself doesn't have a checkout
476 # and thus would not get charged.. it's checked out as part of the bundle.
477 if ( C4::Context->preference('WhenLostChargeReplacementFee') && $issue ) {
478 C4::Accounts::chargelostitem(
479 $issue->borrowernumber,
480 $bundle_item->itemnumber,
481 $bundle_item->replacementprice,
483 $bundle_item->biblio->title || q{},
484 $bundle_item->barcode || q{},
485 $bundle_item->itemcallnumber || q{},
492 unexpected_items => \@unexpected_items,
493 missing_items => \@missing_items,
494 bundle_items => \@bundle_items
498 $template->param( inputloop => \@inputloop );
505 # new op dev : we check if the document must be returned to his homebranch directly,
506 # if the document is transferred, we have warning message .
508 if ( $messages->{'WasTransfered'} ) {
511 transfer => $messages->{'WasTransfered'},
512 trigger => $messages->{'TransferTrigger'},
513 itemnumber => $itemnumber,
517 if ( $messages->{'NeedsTransfer'} ){
520 needstransfer => $messages->{'NeedsTransfer'},
521 trigger => $messages->{'TransferTrigger'},
525 if ( $messages->{'Wrongbranch'} ){
528 rightbranch => $messages->{'Wrongbranch'}->{'Rightbranch'},
532 # case of wrong transfert, if the document wasn't transferred to the right library (according to branchtransfer (tobranch) BDD)
534 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
536 # Trigger modal to prompt librarian
539 TransferWaitingAt => $messages->{'WrongTransfer'},
540 WrongTransferItem => $messages->{'WrongTransferItem'},
541 trigger => $messages->{'TransferTrigger'},
544 # Update the transfer to reflect the new item holdingbranch
545 my $new_transfer = updateWrongTransfer($messages->{'WrongTransferItem'},$messages->{'WrongTransfer'}, $userenv_branch);
547 NewTransfer => $new_transfer->id
550 my $reserve = $messages->{'ResFound'};
552 my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
560 # reserve found and item arrived at the expected branch
562 if ( $messages->{'ResFound'} ) {
563 my $reserve = $messages->{'ResFound'};
564 my $patron = Koha::Patrons->find( $reserve->{borrowernumber} );
565 my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } );
566 my $branchCheck = ( $userenv_branch eq $reserve->{branchcode} );
567 if ( $reserve->{'ResFound'} eq "Waiting" ) {
569 waiting => $branchCheck ? 1 : undef,
571 } elsif ( C4::Context->preference('HoldsAutoFill') ) {
572 my $item = Koha::Items->find( $itemnumber );
573 my $biblio = $item->biblio;
575 my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef;
576 ModReserveAffect( $itemnumber, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id );
577 my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
580 hold_auto_filled => 1,
581 print_slip => C4::Context->preference('HoldsAutoFillPrintSlip'),
582 reserve_id => $nextreservinfo->{reserve_id},
585 if ( $messages->{'transfert'} ) {
587 itemtitle => $biblio->title,
588 itembiblionumber => $biblio->biblionumber,
589 iteminfo => $biblio->author,
595 intransit => $branchCheck ? undef : 1,
596 transfertodo => $branchCheck ? undef : 1,
597 reserve_id => $reserve->{reserve_id},
602 # same params for Waiting or Reserved
607 destbranch => $reserve->{'branchcode'},
608 reservenotes => $reserve->{'reservenotes'},
609 reserve_id => $reserve->{reserve_id},
610 bormessagepref => $holdmsgpreferences->{'transports'},
614 if ( $messages->{RecallFound} ) {
615 my $recall = $messages->{RecallFound};
616 if ( dt_from_string( $recall->timestamp ) == dt_from_string ) {
617 # we just updated this recall
618 $template->param( recall => $recall );
620 my $transferbranch = $messages->{RecallNeedsTransfer};
621 my $transfertodo = ( !$transferbranch or $transferbranch eq $recall->library->branchcode ) ? undef : 1;
625 recalled => $recall->waiting ? 0 : 1,
626 transfertodo => $transfertodo,
627 waitingrecall => $recall->waiting ? 1 : 0,
632 if ( $messages->{TransferredRecall} ) {
633 my $recall = $messages->{TransferredRecall};
635 # confirm transfer has arrived at the branch
636 my $transfer = Koha::Item::Transfers->search({ datearrived => { '!=' => undef }, itemnumber => $recall->item_id }, { order_by => { -desc => 'datearrived' } })->next;
638 # if transfer has completed, show popup to confirm as waiting
639 if ( defined $transfer and $transfer->tobranch eq $recall->pickup_library_id ) {
650 foreach my $code ( keys %$messages ) {
652 my $exit_required_p = 0;
653 if ( $code eq 'BadBarcode' ) {
654 $err{badbarcode} = 1;
655 $err{msg} = $messages->{'BadBarcode'};
657 elsif ( $code eq 'NotIssued' ) {
661 elsif ( $code eq 'LocalUse' ) {
664 elsif ( $code eq 'WasLost' ) {
666 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfLostItems");
668 elsif ( $code eq 'LostItemFeeRefunded' ) {
669 $template->param( LostItemFeeRefunded => 1 );
671 elsif ( $code eq 'LostItemFeeCharged' ) {
672 $template->param( LostItemFeeCharged => 1 );
674 elsif ( $code eq 'LostItemFeeRestored' ) {
675 $template->param( LostItemFeeRestored => 1 );
677 elsif ( $code eq 'ProcessingFeeRefunded' ) {
678 $template->param( ProcessingFeeRefunded => 1 );
680 elsif ( $code eq 'ResFound' ) {
681 ; # FIXME... anything to do here?
683 elsif ( $code eq 'WasReturned' ) {
684 ; # FIXME... anything to do here?
686 elsif ( $code eq 'WasTransfered' ) {
687 ; # FIXME... anything to do here?
689 elsif ( $code eq 'withdrawn' ) {
691 $exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
693 elsif ( $code eq 'WrongTransfer' ) {
694 ; # FIXME... anything to do here?
696 elsif ( $code eq 'WrongTransferItem' ) {
697 ; # FIXME... anything to do here?
699 elsif ( $code eq 'NeedsTransfer' ) {
701 elsif ( $code eq 'TransferTrigger' ) {
702 ; # Handled alongside NeedsTransfer
704 elsif ( $code eq 'TransferArrived' ) {
705 $err{transferred} = $messages->{'TransferArrived'};
707 elsif ( $code eq 'Wrongbranch' ) {
709 elsif ( $code eq 'Debarred' ) {
710 $err{debarred} = $messages->{'Debarred'};
711 $err{debarcardnumber} = $borrower->{cardnumber};
712 $err{debarborrowernumber} = $borrower->{borrowernumber};
713 $err{debarname} = "$borrower->{firstname} $borrower->{surname}";
715 elsif ( $code eq 'PrevDebarred' ) {
716 $err{prevdebarred} = $messages->{'PrevDebarred'};
718 elsif ( $code eq 'ForeverDebarred' ) {
719 $err{foreverdebarred} = $messages->{'ForeverDebarred'};
721 elsif ( $code eq 'ItemLocationUpdated' ) {
722 $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
724 elsif ( $code eq 'NotForLoanStatusUpdated' ) {
725 $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
727 elsif ( $code eq 'DataCorrupted' ) {
728 $err{data_corrupted} = 1;
730 elsif ( $code eq 'ReturnClaims' ) {
731 $template->param( ReturnClaims => $messages->{ReturnClaims} );
732 } elsif ( $code eq 'RecallFound' ) {
734 } elsif ( $code eq 'RecallNeedsTransfer' ) {
736 } elsif ( $code eq 'TransferredRecall' ) {
738 } elsif ( $code eq 'InBundle' ) {
739 $template->param( InBundle => $messages->{InBundle} );
741 die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die.
742 # This forces the issue of staying in sync w/ Circulation.pm
745 push( @errmsgloop, \%err );
747 last if $exit_required_p;
749 $template->param( errmsgloop => \@errmsgloop );
754 { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
755 foreach ( sort { $a <=> $b } keys %returneditems ) {
757 if ( $count++ < $returned_counter ) {
758 my $bar_code = $returneditems{$_};
759 if ($riduedate{$_}) {
760 my $duedate = dt_from_string( $riduedate{$_}, 'sql');
761 $ri{year} = $duedate->year();
762 $ri{month} = $duedate->month();
763 $ri{day} = $duedate->day();
764 $ri{hour} = $duedate->hour();
765 $ri{minute} = $duedate->minute();
766 $ri{duedate} = $duedate;
767 my $patron = Koha::Patrons->find( $riborrowernumber{$_} );
768 unless ( $dropboxmode ) {
769 $ri{return_overdue} = 1 if (DateTime->compare($duedate, dt_from_string()) == -1);
771 $ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
773 $ri{patron} = $patron,
774 $ri{borissuescount} = $patron->checkouts->count;
777 $ri{borrowernumber} = $riborrowernumber{$_};
780 my $item = Koha::Items->find({ barcode => $bar_code });
781 next unless $item; # FIXME The item has been deleted in the meantime,
782 # we could handle that better displaying a message in the template
784 my $biblio = $item->biblio;
785 # FIXME pass $item to the template and we are done here...
786 $ri{itembiblionumber} = $biblio->biblionumber;
787 $ri{itemtitle} = $biblio->title;
788 $ri{subtitle} = $biblio->subtitle;
789 $ri{part_name} = $biblio->part_name;
790 $ri{part_number} = $biblio->part_number;
791 $ri{itemauthor} = $biblio->author;
792 $ri{itemcallnumber} = $item->itemcallnumber;
793 $ri{dateaccessioned} = $item->dateaccessioned;
794 $ri{recordtype} = $biblio->itemtype;
795 $ri{itemtype} = $item->itype;
796 $ri{itemnote} = $item->itemnotes;
797 $ri{itemnotes_nonpublic} = $item->itemnotes_nonpublic;
798 $ri{ccode} = $item->ccode;
799 $ri{enumchron} = $item->enumchron;
800 $ri{itemnumber} = $item->itemnumber;
801 $ri{barcode} = $bar_code;
802 $ri{homebranch} = $item->homebranch;
803 $ri{transferbranch} = $item->get_transfer ? $item->get_transfer->tobranch : '';
804 $ri{damaged} = $item->damaged;
806 $ri{location} = $item->location;
807 my $shelfcode = $ri{'location'};
808 $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
819 errmsgloop => \@errmsgloop,
820 exemptfine => $exemptfine,
821 dropboxmode => $dropboxmode,
822 dropboxdate => $dropboxdate,
823 forgivemanualholdsexpire => $forgivemanualholdsexpire,
824 overduecharges => $overduecharges,
825 AudioAlerts => C4::Context->preference("AudioAlerts"),
829 my $item_from_barcode = Koha::Items->find({barcode => $barcode }); # How many times do we fetch this item?!?
830 if ( $item_from_barcode ) {
831 $itemnumber = $item_from_barcode->itemnumber;
832 my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
833 if ( $holdingBranch and $collectionBranch ) {
834 $holdingBranch //= '';
835 $collectionBranch //= $returnbranch;
836 if ( ! ( $holdingBranch eq $collectionBranch ) ) {
838 collectionItemNeedsTransferred => 1,
839 collectionBranch => $collectionBranch,
846 $template->param( itemnumber => $itemnumber );
848 # Checking if there is a Fast Cataloging Framework
849 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
851 # actually print the page!
852 output_html_with_http_headers $query, $cookie, $template->output;