@@ -, +, @@ --- C4/Biblio.pm | 21 --------------------- acqui/basket.pl | 14 +++++++------- acqui/parcel.pl | 8 ++++---- 3 files changed, 11 insertions(+), 32 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -104,7 +104,6 @@ BEGIN { &CountItemsIssued &CountBiblioInOrders - &GetSubscriptionsId ); # To modify something @@ -3509,26 +3508,6 @@ sub CountBiblioInOrders { return ($count); } -=head2 GetSubscriptionsId - - $subscriptions = &GetSubscriptionsId($biblionumber); - -This function return an array of subscriptionid with $biblionumber - -=cut - -sub GetSubscriptionsId { - my ($biblionumber) = @_; - my $dbh = C4::Context->dbh; - my $query = "SELECT subscriptionid - FROM subscription - WHERE biblionumber=?"; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); - my @subscriptions = $sth->fetchrow_array; - return (@subscriptions); -} - =head2 prepare_host_field $marcfield = prepare_host_field( $hostbiblioitem, $marcflavour ); --- a/acqui/basket.pl +++ a/acqui/basket.pl @@ -134,10 +134,10 @@ if ( $op eq 'delete_confirm' ) { my $biblio = Koha::Biblios->find( $biblionumber ); my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $myorder->{'ordernumber'}; - my $subscriptions = scalar GetSubscriptionsId ($biblionumber); + my $has_subscriptions = $biblio->subscriptions->count; my $itemcount = $biblio->items->count; my $error; - if ($countbiblio == 0 && $itemcount == 0 && $subscriptions == 0) { + if ($countbiblio == 0 && $itemcount == 0 && not $has_subscriptions ) { $error = DelBiblio($myorder->{biblionumber}) } else { push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), @@ -145,7 +145,7 @@ if ( $op eq 'delete_confirm' ) { author=> $myorder->{'author'}, countbiblio=> $countbiblio, itemcount=>$itemcount, - subscriptions=>$subscriptions}; + subscriptions => $has_subscriptions}; } if ($error) { push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), @@ -474,20 +474,20 @@ sub get_order_infos { my $biblio = Koha::Biblios->find( $biblionumber ); my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $order->{'ordernumber'}; - my @subscriptions = GetSubscriptionsId ($biblionumber); + my $has_subscriptions = $biblio->subscriptions->count; 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{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !($has_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; + $line{left_subscription} = 1 if $has_subscriptions; + $line{subscriptions} = $has_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; --- a/acqui/parcel.pl +++ a/acqui/parcel.pl @@ -241,7 +241,7 @@ unless( defined $invoice->{closedate} ) { my $biblio = Koha::Biblios->find( $biblionumber ); my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $line{'ordernumber'}; - my @subscriptions = GetSubscriptionsId ($biblionumber); + my $has_subscriptions = $biblio->subscriptions->count; my $itemcount = $biblio->items->count; my $holds_count = $biblio->holds->count; my @items = GetItemnumbersFromOrder( $ordernumber ); @@ -253,13 +253,13 @@ unless( defined $invoice->{closedate} ) { $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; # 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{can_del_bib} = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !($has_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; + $line{left_subscription} = 1 if $has_subscriptions; + $line{subscriptions} = $has_subscriptions; $line{left_holds} = ($holds_count >= 1) ? 1 : 0; $line{left_holds_on_order} = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); $line{holds} = $holds_count; --