View | Details | Raw Unified | Return to bug 17631
Collapse All | Expand All

(-)a/C4/Biblio.pm (-21 lines)
Lines 104-110 BEGIN { Link Here
104
      &CountItemsIssued
104
      &CountItemsIssued
105
      &CountBiblioInOrders
105
      &CountBiblioInOrders
106
      &GetSubscriptionsId
106
      &GetSubscriptionsId
107
      &GetHolds
108
    );
107
    );
109
108
110
    # To modify something
109
    # To modify something
Lines 3570-3595 sub GetSubscriptionsId { Link Here
3570
    return (@subscriptions);
3569
    return (@subscriptions);
3571
}
3570
}
3572
3571
3573
=head2 GetHolds
3574
3575
    $holds = &GetHolds($biblionumber);
3576
3577
This function return the count of holds with $biblionumber
3578
3579
=cut
3580
3581
sub GetHolds {
3582
 my ($biblionumber) = @_;
3583
    my $dbh            = C4::Context->dbh;
3584
    my $query          = "SELECT count(*)
3585
          FROM  reserves
3586
          WHERE biblionumber=?";
3587
    my $sth = $dbh->prepare($query);
3588
    $sth->execute($biblionumber);
3589
    my $holds = $sth->fetchrow;
3590
    return ($holds);
3591
}
3592
3593
=head2 prepare_host_field
3572
=head2 prepare_host_field
3594
3573
3595
$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour );
3574
$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour );
(-)a/acqui/basket.pl (-5 / +7 lines)
Lines 33-38 use C4::Biblio; Link Here
33
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
33
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
34
use C4::Items;
34
use C4::Items;
35
use C4::Suggestions;
35
use C4::Suggestions;
36
use Koha::Biblios;
36
use Koha::Libraries;
37
use Koha::Libraries;
37
use C4::Letters qw/SendAlerts/;
38
use C4::Letters qw/SendAlerts/;
38
use Date::Calc qw/Add_Delta_Days/;
39
use Date::Calc qw/Add_Delta_Days/;
Lines 456-466 sub get_order_infos { Link Here
456
    }
457
    }
457
458
458
    my $biblionumber = $order->{'biblionumber'};
459
    my $biblionumber = $order->{'biblionumber'};
460
    my $biblio = Koha::Biblios->find( $biblionumber );
459
    my $countbiblio = CountBiblioInOrders($biblionumber);
461
    my $countbiblio = CountBiblioInOrders($biblionumber);
460
    my $ordernumber = $order->{'ordernumber'};
462
    my $ordernumber = $order->{'ordernumber'};
461
    my @subscriptions = GetSubscriptionsId ($biblionumber);
463
    my @subscriptions = GetSubscriptionsId ($biblionumber);
462
    my $itemcount = GetItemsCount($biblionumber);
464
    my $itemcount = GetItemsCount($biblionumber);
463
    my $holds  = GetHolds ($biblionumber);
465
    my $holds_count = $biblio->holds->count;
464
    my @items = GetItemnumbersFromOrder( $ordernumber );
466
    my @items = GetItemnumbersFromOrder( $ordernumber );
465
    my $itemholds;
467
    my $itemholds;
466
    foreach my $item (@items){
468
    foreach my $item (@items){
Lines 470-486 sub get_order_infos { Link Here
470
        }
472
        }
471
    }
473
    }
472
    # 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
474
    # 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
473
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
475
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
474
    $line{items}                = ($itemcount) - (scalar @items);
476
    $line{items}                = ($itemcount) - (scalar @items);
475
    $line{left_item}            = 1 if $line{items} >= 1;
477
    $line{left_item}            = 1 if $line{items} >= 1;
476
    $line{left_biblio}          = 1 if $countbiblio > 1;
478
    $line{left_biblio}          = 1 if $countbiblio > 1;
477
    $line{biblios}              = $countbiblio - 1;
479
    $line{biblios}              = $countbiblio - 1;
478
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
480
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
479
    $line{subscriptions}        = scalar @subscriptions;
481
    $line{subscriptions}        = scalar @subscriptions;
480
    ($holds >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
482
    ($holds_count >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
481
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
483
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
482
    $line{holds}                = $holds;
484
    $line{holds}                = $holds_count;
483
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
485
    $line{holds_on_order}       = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
484
486
485
487
486
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
488
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
(-)a/acqui/parcel.pl (-6 / +7 lines)
Lines 68-73 use C4::Suggestions; Link Here
68
use C4::Reserves qw/GetReservesFromBiblionumber/;
68
use C4::Reserves qw/GetReservesFromBiblionumber/;
69
69
70
use Koha::Acquisition::Bookseller;
70
use Koha::Acquisition::Bookseller;
71
use Koha::Biblios;
71
use Koha::DateUtils;
72
use Koha::DateUtils;
72
73
73
use JSON;
74
use JSON;
Lines 239-249 unless( defined $invoice->{closedate} ) { Link Here
239
        $line{booksellerid} = $booksellerid;
240
        $line{booksellerid} = $booksellerid;
240
241
241
        my $biblionumber = $line{'biblionumber'};
242
        my $biblionumber = $line{'biblionumber'};
243
        my $biblio = Koha::Biblios->find( $biblionumber );
242
        my $countbiblio = CountBiblioInOrders($biblionumber);
244
        my $countbiblio = CountBiblioInOrders($biblionumber);
243
        my $ordernumber = $line{'ordernumber'};
245
        my $ordernumber = $line{'ordernumber'};
244
        my @subscriptions = GetSubscriptionsId ($biblionumber);
246
        my @subscriptions = GetSubscriptionsId ($biblionumber);
245
        my $itemcount = GetItemsCount($biblionumber);
247
        my $itemcount = GetItemsCount($biblionumber);
246
        my $holds  = GetHolds ($biblionumber);
248
        my $holds_count = $biblio->holds->count;
247
        my @items = GetItemnumbersFromOrder( $ordernumber );
249
        my @items = GetItemnumbersFromOrder( $ordernumber );
248
        my $itemholds;
250
        my $itemholds;
249
        foreach my $item (@items){
251
        foreach my $item (@items){
Lines 259-275 unless( defined $invoice->{closedate} ) { Link Here
259
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
261
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
260
262
261
        # 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
263
        # 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
262
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
264
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
263
        $line{items}                = ($itemcount) - (scalar @items);
265
        $line{items}                = ($itemcount) - (scalar @items);
264
        $line{left_item}            = 1 if $line{items} >= 1;
266
        $line{left_item}            = 1 if $line{items} >= 1;
265
        $line{left_biblio}          = 1 if $countbiblio > 1;
267
        $line{left_biblio}          = 1 if $countbiblio > 1;
266
        $line{biblios}              = $countbiblio - 1;
268
        $line{biblios}              = $countbiblio - 1;
267
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
269
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
268
        $line{subscriptions}        = scalar @subscriptions;
270
        $line{subscriptions}        = scalar @subscriptions;
269
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
271
        $line{left_holds}           = ($holds_count >= 1) ? 1 : 0;
270
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
272
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
271
        $line{holds}                = $holds;
273
        $line{holds}                = $holds_count;
272
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
274
        $line{holds_on_order}       = $itemholds?$itemholds:$holds_count if $line{left_holds_on_order};
273
275
274
        my $budget_name = GetBudgetName( $line{budget_id} );
276
        my $budget_name = GetBudgetName( $line{budget_id} );
275
        $line{budget_name} = $budget_name;
277
        $line{budget_name} = $budget_name;
276
- 

Return to bug 17631