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

(-)a/C4/Biblio.pm (-21 lines)
Lines 105-111 BEGIN { Link Here
105
105
106
      &CountItemsIssued
106
      &CountItemsIssued
107
      &CountBiblioInOrders
107
      &CountBiblioInOrders
108
      &GetSubscriptionsId
109
    );
108
    );
110
109
111
    # To modify something
110
    # To modify something
Lines 3537-3562 sub CountBiblioInOrders { Link Here
3537
    return ($count);
3536
    return ($count);
3538
}
3537
}
3539
3538
3540
=head2 GetSubscriptionsId
3541
3542
    $subscriptions = &GetSubscriptionsId($biblionumber);
3543
3544
This function return an array of subscriptionid with $biblionumber
3545
3546
=cut
3547
3548
sub GetSubscriptionsId {
3549
 my ($biblionumber) = @_;
3550
    my $dbh            = C4::Context->dbh;
3551
    my $query          = "SELECT subscriptionid
3552
          FROM  subscription
3553
          WHERE biblionumber=?";
3554
    my $sth = $dbh->prepare($query);
3555
    $sth->execute($biblionumber);
3556
    my @subscriptions = $sth->fetchrow_array;
3557
    return (@subscriptions);
3558
}
3559
3560
=head2 prepare_host_field
3539
=head2 prepare_host_field
3561
3540
3562
$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour );
3541
$marcfield = prepare_host_field( $hostbiblioitem, $marcflavour );
(-)a/acqui/basket.pl (-7 / +7 lines)
Lines 133-142 if ( $op eq 'delete_confirm' ) { Link Here
133
            my $biblio = Koha::Biblios->find( $biblionumber );
133
            my $biblio = Koha::Biblios->find( $biblionumber );
134
            my $countbiblio = CountBiblioInOrders($biblionumber);
134
            my $countbiblio = CountBiblioInOrders($biblionumber);
135
            my $ordernumber = $myorder->{'ordernumber'};
135
            my $ordernumber = $myorder->{'ordernumber'};
136
            my $subscriptions = scalar GetSubscriptionsId ($biblionumber);
136
            my $has_subscriptions = $biblio->subscriptions->count;
137
            my $itemcount = $biblio->items->count;
137
            my $itemcount = $biblio->items->count;
138
            my $error;
138
            my $error;
139
            if ($countbiblio == 0 && $itemcount == 0 && $subscriptions == 0) {
139
            if ($countbiblio == 0 && $itemcount == 0 && not $has_subscriptions ) {
140
                $error = DelBiblio($myorder->{biblionumber}) }
140
                $error = DelBiblio($myorder->{biblionumber}) }
141
            else {
141
            else {
142
                push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
142
                push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
Lines 144-150 if ( $op eq 'delete_confirm' ) { Link Here
144
                                         author=> $myorder->{'author'},
144
                                         author=> $myorder->{'author'},
145
                                         countbiblio=> $countbiblio,
145
                                         countbiblio=> $countbiblio,
146
                                         itemcount=>$itemcount,
146
                                         itemcount=>$itemcount,
147
                                         subscriptions=>$subscriptions};
147
                                         subscriptions => $has_subscriptions};
148
            }
148
            }
149
            if ($error) {
149
            if ($error) {
150
                push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
150
                push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}),
Lines 466-472 sub get_order_infos { Link Here
466
    my $biblio = Koha::Biblios->find( $biblionumber );
466
    my $biblio = Koha::Biblios->find( $biblionumber );
467
    my $countbiblio = CountBiblioInOrders($biblionumber);
467
    my $countbiblio = CountBiblioInOrders($biblionumber);
468
    my $ordernumber = $order->{'ordernumber'};
468
    my $ordernumber = $order->{'ordernumber'};
469
    my @subscriptions = GetSubscriptionsId ($biblionumber);
469
    my $has_subscriptions = $biblio->subscriptions->count;
470
    my $itemcount   = $biblio->items->count;
470
    my $itemcount   = $biblio->items->count;
471
    my $holds_count = $biblio->holds->count;
471
    my $holds_count = $biblio->holds->count;
472
    my @items = GetItemnumbersFromOrder( $ordernumber );
472
    my @items = GetItemnumbersFromOrder( $ordernumber );
Lines 478-490 sub get_order_infos { Link Here
478
        }
478
        }
479
    }
479
    }
480
    # 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
480
    # 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
481
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
481
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !($has_subscriptions) && !($holds_count);
482
    $line{items}                = ($itemcount) - (scalar @items);
482
    $line{items}                = ($itemcount) - (scalar @items);
483
    $line{left_item}            = 1 if $line{items} >= 1;
483
    $line{left_item}            = 1 if $line{items} >= 1;
484
    $line{left_biblio}          = 1 if $countbiblio > 1;
484
    $line{left_biblio}          = 1 if $countbiblio > 1;
485
    $line{biblios}              = $countbiblio - 1;
485
    $line{biblios}              = $countbiblio - 1;
486
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
486
    $line{left_subscription}    = 1 if $has_subscriptions;
487
    $line{subscriptions}        = scalar @subscriptions;
487
    $line{subscriptions}        = $has_subscriptions;
488
    ($holds_count >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
488
    ($holds_count >= 1) ? $line{left_holds} = 1 : $line{left_holds} = 0;
489
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
489
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
490
    $line{holds}                = $holds_count;
490
    $line{holds}                = $holds_count;
(-)a/acqui/parcel.pl (-5 / +4 lines)
Lines 239-245 unless( defined $invoice->{closedate} ) { Link Here
239
        my $biblio = Koha::Biblios->find( $biblionumber );
239
        my $biblio = Koha::Biblios->find( $biblionumber );
240
        my $countbiblio = CountBiblioInOrders($biblionumber);
240
        my $countbiblio = CountBiblioInOrders($biblionumber);
241
        my $ordernumber = $line{'ordernumber'};
241
        my $ordernumber = $line{'ordernumber'};
242
        my @subscriptions = GetSubscriptionsId ($biblionumber);
242
        my $has_subscriptions = $biblio->subscriptions->count;
243
        my $itemcount   = $biblio->items->count;
243
        my $itemcount   = $biblio->items->count;
244
        my $holds_count = $biblio->holds->count;
244
        my $holds_count = $biblio->holds->count;
245
        my @items = GetItemnumbersFromOrder( $ordernumber );
245
        my @items = GetItemnumbersFromOrder( $ordernumber );
Lines 257-269 unless( defined $invoice->{closedate} ) { Link Here
257
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
257
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
258
258
259
        # 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
259
        # 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
260
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds_count);
260
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !($has_subscriptions) && !($holds_count);
261
        $line{items}                = ($itemcount) - (scalar @items);
261
        $line{items}                = ($itemcount) - (scalar @items);
262
        $line{left_item}            = 1 if $line{items} >= 1;
262
        $line{left_item}            = 1 if $line{items} >= 1;
263
        $line{left_biblio}          = 1 if $countbiblio > 1;
263
        $line{left_biblio}          = 1 if $countbiblio > 1;
264
        $line{biblios}              = $countbiblio - 1;
264
        $line{biblios}              = $countbiblio - 1;
265
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
265
        $line{left_subscription}    = 1 if $has_subscriptions;
266
        $line{subscriptions}        = scalar @subscriptions;
266
        $line{subscriptions}        = $has_subscriptions;
267
        $line{left_holds}           = ($holds_count >= 1) ? 1 : 0;
267
        $line{left_holds}           = ($holds_count >= 1) ? 1 : 0;
268
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
268
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
269
        $line{holds}                = $holds_count;
269
        $line{holds}                = $holds_count;
270
- 

Return to bug 18259