Bug 17631: Koha::Biblio - Remove GetHolds
C4::Biblio::GetHolds can be replaced with Koha::Biblio->holds->count Test plan: Create an order and place a hold on the biblio you have ordered. On the basket view, you should not be able to Cancel the order and/or delete the record Receive the order, on the parcel page you should get the same behavior. Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
6475f83189
commit
2f07f7b48e
3 changed files with 14 additions and 31 deletions
21
C4/Biblio.pm
21
C4/Biblio.pm
|
@ -104,7 +104,6 @@ BEGIN {
|
|||
&CountItemsIssued
|
||||
&CountBiblioInOrders
|
||||
&GetSubscriptionsId
|
||||
&GetHolds
|
||||
);
|
||||
|
||||
# To modify something
|
||||
|
@ -3570,26 +3569,6 @@ sub GetSubscriptionsId {
|
|||
return (@subscriptions);
|
||||
}
|
||||
|
||||
=head2 GetHolds
|
||||
|
||||
$holds = &GetHolds($biblionumber);
|
||||
|
||||
This function return the count of holds with $biblionumber
|
||||
|
||||
=cut
|
||||
|
||||
sub GetHolds {
|
||||
my ($biblionumber) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "SELECT count(*)
|
||||
FROM reserves
|
||||
WHERE biblionumber=?";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($biblionumber);
|
||||
my $holds = $sth->fetchrow;
|
||||
return ($holds);
|
||||
}
|
||||
|
||||
=head2 prepare_host_field
|
||||
|
||||
$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour );
|
||||
|
|
|
@ -33,6 +33,7 @@ use C4::Biblio;
|
|||
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket
|
||||
use C4::Items;
|
||||
use C4::Suggestions;
|
||||
use Koha::Biblios;
|
||||
use Koha::Libraries;
|
||||
use C4::Letters qw/SendAlerts/;
|
||||
use Date::Calc qw/Add_Delta_Days/;
|
||||
|
@ -456,11 +457,12 @@ 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 = GetItemsCount($biblionumber);
|
||||
my $holds = GetHolds ($biblionumber);
|
||||
my $holds_count = $biblio->holds->count;
|
||||
my @items = GetItemnumbersFromOrder( $ordernumber );
|
||||
my $itemholds;
|
||||
foreach my $item (@items){
|
||||
|
@ -470,17 +472,17 @@ sub get_order_infos {
|
|||
}
|
||||
}
|
||||
# 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);
|
||||
$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 >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
|
||||
($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;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
|
||||
$line{holds} = $holds_count;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
|
||||
|
||||
|
||||
my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
|
||||
|
|
|
@ -68,6 +68,7 @@ use C4::Suggestions;
|
|||
use C4::Reserves qw/GetReservesFromBiblionumber/;
|
||||
|
||||
use Koha::Acquisition::Bookseller;
|
||||
use Koha::Biblios;
|
||||
use Koha::DateUtils;
|
||||
|
||||
use JSON;
|
||||
|
@ -235,11 +236,12 @@ unless( defined $invoice->{closedate} ) {
|
|||
$line{booksellerid} = $booksellerid;
|
||||
|
||||
my $biblionumber = $line{'biblionumber'};
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
my $countbiblio = CountBiblioInOrders($biblionumber);
|
||||
my $ordernumber = $line{'ordernumber'};
|
||||
my @subscriptions = GetSubscriptionsId ($biblionumber);
|
||||
my $itemcount = GetItemsCount($biblionumber);
|
||||
my $holds = GetHolds ($biblionumber);
|
||||
my $holds_count = $biblio->holds->count;
|
||||
my @items = GetItemnumbersFromOrder( $ordernumber );
|
||||
my $itemholds;
|
||||
foreach my $item (@items){
|
||||
|
@ -255,17 +257,17 @@ 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);
|
||||
$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;
|
||||
$line{left_holds} = ($holds >= 1) ? 1 : 0;
|
||||
$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;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
|
||||
$line{holds} = $holds_count;
|
||||
$line{holds_on_order} = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
|
||||
|
||||
my $budget_name = GetBudgetName( $line{budget_id} );
|
||||
$line{budget_name} = $budget_name;
|
||||
|
|
Loading…
Reference in a new issue