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

(-)a/C4/Biblio.pm (-3 / +14 lines)
Lines 2524-2537 sub _adjust_pubyear { Link Here
2524
2524
2525
=head2 CountItemsIssued
2525
=head2 CountItemsIssued
2526
2526
2527
    my $count = CountItemsIssued( $biblionumber );
2527
    my $count = CountItemsIssued( { biblionumber => $biblionumber, count_on_order => 0 || 1 );
2528
2528
2529
=cut
2529
=cut
2530
2530
2531
sub CountItemsIssued {
2531
sub CountItemsIssued {
2532
    my ($biblionumber) = @_;
2532
    my ($params) = @_;
2533
    my $biblionumber = $params->{'biblionumber'};
2534
    my $count_on_order = $params->{'count_on_order'};
2535
2536
    my $sql = 'SELECT COUNT(*) AS issuedCount FROM items LEFT JOIN issues ON items.itemnumber = issues.itemnumber WHERE items.biblionumber = ?';
2537
2538
    if ( $count_on_order ) {
2539
        $sql .= ' AND ( issues.itemnumber IS NOT NULL OR items.notforloan < 0 )';
2540
    } else {
2541
        $sql .= ' AND issues.itemnumber IS NOT NULL';
2542
    }
2543
2533
    my $dbh            = C4::Context->dbh;
2544
    my $dbh            = C4::Context->dbh;
2534
    my $sth            = $dbh->prepare('SELECT COUNT(*) as issuedCount FROM items, issues WHERE items.itemnumber = issues.itemnumber AND items.biblionumber = ?');
2545
    my $sth            = $dbh->prepare( $sql );
2535
    $sth->execute($biblionumber);
2546
    $sth->execute($biblionumber);
2536
    my $row = $sth->fetchrow_hashref();
2547
    my $row = $sth->fetchrow_hashref();
2537
    return $row->{'issuedCount'};
2548
    return $row->{'issuedCount'};
(-)a/C4/Reserves.pm (-5 / +3 lines)
Lines 1283-1295 sub IsAvailableForItemLevelRequest { Link Here
1283
1283
1284
        # if we have this param predefined from outer caller sub, we just need
1284
        # if we have this param predefined from outer caller sub, we just need
1285
        # to return it, so we saving from having loop inside other loop:
1285
        # to return it, so we saving from having loop inside other loop:
1286
        return  $items_any_available ? 0 : 1
1286
        $items_any_available //= ItemsAnyAvailableForHold( { biblionumber => $item->biblionumber, patron => $patron });
1287
            if defined $items_any_available;
1288
1287
1289
        my $any_available = ItemsAnyAvailableForHold( { biblionumber => $item->biblionumber, patron => $patron });
1288
        return ( $item->notforloan < 0 || !$items_any_available ) ? 1 : 0;
1290
        return $any_available ? 0 : 1;
1291
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1289
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1292
        return $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1290
        return ( $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ) ) ? 1 : 0;
1293
    }
1291
    }
1294
}
1292
}
1295
1293
(-)a/opac/opac-ISBDdetail.pl (-1 / +1 lines)
Lines 182-188 while ( my $item = $items->next ) { Link Here
182
      unless $allow_onshelf_holds;
182
      unless $allow_onshelf_holds;
183
}
183
}
184
184
185
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
185
if( $allow_onshelf_holds || CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) || $biblio->has_items_waiting_or_intransit ) {
186
    $template->param( ReservableItems => 1 );
186
    $template->param( ReservableItems => 1 );
187
}
187
}
188
188
(-)a/opac/opac-MARCdetail.pl (-1 / +1 lines)
Lines 143-149 for my $itm (@all_items) { Link Here
143
    last if $allow_onshelf_holds;
143
    last if $allow_onshelf_holds;
144
}
144
}
145
145
146
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
146
if ( $allow_onshelf_holds || CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) || $biblio->has_items_waiting_or_intransit ) {
147
    $template->param( ReservableItems => 1 );
147
    $template->param( ReservableItems => 1 );
148
}
148
}
149
149
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 731-737 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
731
  }
731
  }
732
}
732
}
733
733
734
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
734
if ( $allow_onshelf_holds || CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) || $biblio->has_items_waiting_or_intransit ) {
735
    $template->param( ReservableItems => 1 );
735
    $template->param( ReservableItems => 1 );
736
}
736
}
737
737
(-)a/opac/opac-search.pl (-1 / +1 lines)
Lines 710-716 for (my $i=0;$i<@servers;$i++) { Link Here
710
            if (C4::Context->preference('TagsEnabled') and
710
            if (C4::Context->preference('TagsEnabled') and
711
                C4::Context->preference('TagsShowOnList')) {
711
                C4::Context->preference('TagsShowOnList')) {
712
                if ( my $bibnum = $res->{biblionumber} ) {
712
                if ( my $bibnum = $res->{biblionumber} ) {
713
                    $res->{itemsissued} = CountItemsIssued( $bibnum );
713
                    $res->{itemsissued} = CountItemsIssued( { biblionumber => $bibnum } );
714
                    $res->{'TagLoop'} = get_tags({
714
                    $res->{'TagLoop'} = get_tags({
715
                        biblionumber => $bibnum,
715
                        biblionumber => $bibnum,
716
                        approved => 1,
716
                        approved => 1,
(-)a/tools/batch_delete_records.pl (-3 / +2 lines)
Lines 96-102 if ( $op eq 'form' ) { Link Here
96
            my $record = &GetMarcBiblio({ biblionumber => $record_id });
96
            my $record = &GetMarcBiblio({ biblionumber => $record_id });
97
            $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')];
97
            $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')];
98
            $biblio->{holds_count} = $holds_count;
98
            $biblio->{holds_count} = $holds_count;
99
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
99
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued({ biblionumber => $record_id, count_on_order => 1 });
100
            push @records, $biblio;
100
            push @records, $biblio;
101
        } else {
101
        } else {
102
            # Retrieve authority information
102
            # Retrieve authority information
Lines 145-151 if ( $op eq 'form' ) { Link Here
145
            my $biblio = Koha::Biblios->find( $biblionumber );
145
            my $biblio = Koha::Biblios->find( $biblionumber );
146
146
147
            # TODO Replace with $biblio->get_issues->count
147
            # TODO Replace with $biblio->get_issues->count
148
            if ( C4::Biblio::CountItemsIssued( $biblionumber ) ) {
148
            if ( C4::Biblio::CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) ) {
149
                push @messages, {
149
                push @messages, {
150
                    type => 'warning',
150
                    type => 'warning',
151
                    code => 'item_issued',
151
                    code => 'item_issued',
152
- 

Return to bug 6918