From b450a5e4e67a5ec4b625564d28fb1df1554388f7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Jul 2017 14:53:57 -0300 Subject: [PATCH] Bug 18276: barcode may be nonexistent when checking out/in --- circ/circulation.pl | 14 +++++------ circ/returns.pl | 67 ++++++++++++++++++++++++++++------------------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 895d61ce21..bfe88cfd3d 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -331,10 +331,13 @@ if (@$barcodes) { $template_params->{messages} = $messages; my $item = Koha::Items->find({ barcode => $barcode }); - my $biblio = $item->biblio; + my ( $biblio, $mss ); - my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.notforloan', authorised_value => { not => undef } }); - $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorised_value : undef; + if ( $item ) { + $biblio = $item->biblio; + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.notforloan', authorised_value => { not => undef } }); + $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorised_value : undef; + } # Fix for bug 7494: optional checkout-time fallback search for a book @@ -412,10 +415,6 @@ if (@$barcodes) { ); } - $template->param( - itembiblionumber => $biblio->biblionumber - ); - # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue $patron = Koha::Patrons->find( $borrowernumber ); @@ -424,6 +423,7 @@ if (@$barcodes) { if ( $item ) { $template_params->{item} = $item; $template_params->{biblio} = $biblio; + $template_params->{itembiblionumber} = $biblio->biblionumber; } push @$checkout_infos, $template_params; } diff --git a/circ/returns.pl b/circ/returns.pl index 03fbb8370e..7b96290f6d 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -259,42 +259,44 @@ if ($barcode) { $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter'); my $item = Koha::Items->find({ barcode => $barcode }); - # Check if we should display a checkin message, based on the the item - # type of the checked in item - my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); - if ( $itemtype && $itemtype->checkinmsg ) { - $template->param( - checkinmsg => $itemtype->checkinmsg, - checkinmsgtype => $itemtype->checkinmsgtype, - ); - } + if ( $item ) { + # Check if we should display a checkin message, based on the the item + # type of the checked in item + my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); + if ( $itemtype && $itemtype->checkinmsg ) { + $template->param( + checkinmsg => $itemtype->checkinmsg, + checkinmsgtype => $itemtype->checkinmsgtype, + ); + } - # make sure return branch respects home branch circulation rules, default to homebranch - my $hbr = GetBranchItemRule($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch"; - $returnbranch = $item->$hbr; + # make sure return branch respects home branch circulation rules, default to homebranch + my $hbr = GetBranchItemRule($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch"; + $returnbranch = $item->$hbr; - my $materials = $item->materials; - my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials }); - $materials = $descriptions->{lib} // $materials; + my $materials = $item->materials; + my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials }); + $materials = $descriptions->{lib} // $materials; - my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); + my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); - my $biblio = $item->biblio; - $template->param( - title => $biblio->title, - homebranch => $item->homebranch, - holdingbranch => $item->holdingbranch, - returnbranch => $returnbranch, - author => $biblio->author, - itembarcode => $item->barcode, - itemtype => $item->effective_itemtype, - ccode => $item->ccode, - itembiblionumber => $biblio->biblionumber, - biblionumber => $biblio->biblionumber, - borrower => $borrower, - additional_materials => $materials, - issue => $issue, - ); + my $biblio = $item->biblio; + $template->param( + title => $biblio->title, + homebranch => $item->homebranch, + holdingbranch => $item->holdingbranch, + returnbranch => $returnbranch, + author => $biblio->author, + itembarcode => $item->barcode, + itemtype => $item->effective_itemtype, + ccode => $item->ccode, + itembiblionumber => $biblio->biblionumber, + biblionumber => $biblio->biblionumber, + borrower => $borrower, + additional_materials => $materials, + issue => $issue, + ); + } # FIXME else we should not call AddReturn but set BadBarcode directly instead my %input = ( counter => 0, @@ -302,6 +304,7 @@ if ($barcode) { barcode => $barcode, ); + # do the return ( $returned, $messages, $issueinformation, $borrower ) = AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override, $dropboxdate ); -- 2.11.0