Bug 18467: Handle orders with deleted biblio when viewing a basket
If the bibliographic record of an order has been removed, $order->{bibionumber}
is undefined. We need to handle this specific case correctly.
To test:
1 - Create a basket
2 - Order a bib
3 - Cancel order and delete record
4 - You cannot view basket
5 - Apply patch
6 - View basket
7 - There should not be an error
r calling count on undefined bib in basket.pl if order cancelled and
record deleted
Followed test plan, works as intended
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
21992c7eca
commit
21bddb399d
|
|
@ -463,27 +463,29 @@ sub get_order_infos {
|
|||
}
|
||||
|
||||
my $biblionumber = $order->{'biblionumber'};
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
my $countbiblio = CountBiblioInOrders($biblionumber);
|
||||
my $ordernumber = $order->{'ordernumber'};
|
||||
my @subscriptions = GetSubscriptionsId ($biblionumber);
|
||||
my $itemcount = $biblio->items->count;
|
||||
my $holds_count = $biblio->holds->count;
|
||||
my @items = GetItemnumbersFromOrder( $ordernumber );
|
||||
my $itemholds = $biblio ? $biblio->holds->search({ itemnumber => { -in => \@items } })->count : 0;
|
||||
if ( $biblionumber ) { # The biblio still exists
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
my $countbiblio = CountBiblioInOrders($biblionumber);
|
||||
my $ordernumber = $order->{'ordernumber'};
|
||||
my @subscriptions = GetSubscriptionsId ($biblionumber);
|
||||
my $itemcount = $biblio->items->count;
|
||||
my $holds_count = $biblio->holds->count;
|
||||
my @items = GetItemnumbersFromOrder( $ordernumber );
|
||||
my $itemholds = $biblio->holds->search({ itemnumber => { -in => \@items } })->count;
|
||||
|
||||
# if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
|
||||
$line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
|
||||
$line{items} = ($itemcount) - (scalar @items);
|
||||
$line{left_item} = 1 if $line{items} >= 1;
|
||||
$line{left_biblio} = 1 if $countbiblio > 1;
|
||||
$line{biblios} = $countbiblio - 1;
|
||||
$line{left_subscription} = 1 if scalar @subscriptions >= 1;
|
||||
$line{subscriptions} = scalar @subscriptions;
|
||||
($holds_count >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
|
||||
$line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
|
||||
$line{holds} = $holds_count;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
|
||||
# if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
|
||||
$line{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
|
||||
$line{items} = ($itemcount) - (scalar @items);
|
||||
$line{left_item} = 1 if $line{items} >= 1;
|
||||
$line{left_biblio} = 1 if $countbiblio > 1;
|
||||
$line{biblios} = $countbiblio - 1;
|
||||
$line{left_subscription} = 1 if scalar @subscriptions >= 1;
|
||||
$line{subscriptions} = scalar @subscriptions;
|
||||
($holds_count >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
|
||||
$line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
|
||||
$line{holds} = $holds_count;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
|
||||
}
|
||||
|
||||
|
||||
my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
|
||||
|
|
|
|||
Loading…
Reference in New Issue