From 4c36d4beb6f308ddec9b8da667ed23878bdc208d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 19 Apr 2018 09:54:45 -0300 Subject: [PATCH] Bug 20620: Remove warnings in moredetail.pl Since 19995 warnings are displayed in moredetail.pl, we should get rid of them. Test plan: Hit moredetail.pl with different biblionumbers and confirm you do no longer see warnings in logs. Make sure values for rentalcharge, item type, ccode and replacementprice are displayed correctly. Signed-off-by: Bouzid Fergani Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- catalogue/moredetail.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 845d10e9e9..3d6bd4ab6c 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -123,8 +123,9 @@ my $copynumbers = my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; -$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'}; -$data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} ); +$data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'} + if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} }; +$data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} || 0); # Price formatting should be done template-side foreach ( keys %{$data} ) { $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); } @@ -132,9 +133,9 @@ foreach ( keys %{$data} ) { ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items); foreach my $item (@items){ $item->{object} = Koha::Items->find( $item->{itemnumber} ); - $item->{'collection'} = $ccodes->{ $item->{ccode} } if ($ccodes); - $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'}; - $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} ); + $item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; + $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} }; + $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} || 0 ); # Price formatting should be done template-side if ( defined $item->{'copynumber'} ) { $item->{'displaycopy'} = 1; if ( defined $copynumbers->{ $item->{'copynumber'} } ) { -- 2.39.5