C4::Biblio::GetSubscriptionsId can be replaced using
Koha::Biblio->subscriptions
Test plan:
Create a new order for a bibliographic record
Create a new subscription on this biblio
From the basket (acquisition), confirm that you are not able to delete
the order with the biblio ("Can't cancel order and delete catalog record
1 subscription(s) left")
Receive the order
On the parcel page, confirm that you are not able to delete the order
with the biblio
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
&CountItemsIssued
&CountBiblioInOrders
&CountItemsIssued
&CountBiblioInOrders
-=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 );
=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 $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;
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}),
$error = DelBiblio($myorder->{biblionumber}) }
else {
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
author=> $myorder->{'author'},
countbiblio=> $countbiblio,
itemcount=>$itemcount,
author=> $myorder->{'author'},
countbiblio=> $countbiblio,
itemcount=>$itemcount,
- subscriptions=>$subscriptions};
+ subscriptions => $has_subscriptions};
}
if ($error) {
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
}
if ($error) {
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
my $biblio = Koha::Biblios->find( $biblionumber );
my $countbiblio = CountBiblioInOrders($biblionumber);
my $ordernumber = $order->{'ordernumber'};
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
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{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;
($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 $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 );
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{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{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;
$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;