&CountItemsIssued
&CountBiblioInOrders
- &GetSubscriptionsId
);
# To modify something
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 );
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}),
author=> $myorder->{'author'},
countbiblio=> $countbiblio,
itemcount=>$itemcount,
- subscriptions=>$subscriptions};
+ subscriptions => $has_subscriptions};
}
if ($error) {
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
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;
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 );
$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;