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

(-)a/C4/Biblio.pm (-3 / +14 lines)
Lines 2523-2536 sub _adjust_pubyear { Link Here
2523
2523
2524
=head2 CountItemsIssued
2524
=head2 CountItemsIssued
2525
2525
2526
    my $count = CountItemsIssued( $biblionumber );
2526
    my $count = CountItemsIssued( { biblionumber => $biblionumber, count_on_order => 0 || 1 );
2527
2527
2528
=cut
2528
=cut
2529
2529
2530
sub CountItemsIssued {
2530
sub CountItemsIssued {
2531
    my ($biblionumber) = @_;
2531
    my ($params) = @_;
2532
    my $biblionumber = $params->{'biblionumber'};
2533
    my $count_on_order = $params->{'count_on_order'};
2534
2535
    my $sql = 'SELECT COUNT(*) AS issuedCount FROM items LEFT JOIN issues ON items.itemnumber = issues.itemnumber WHERE items.biblionumber = ?';
2536
2537
    if ( $count_on_order ) {
2538
        $sql .= ' AND ( issues.itemnumber IS NOT NULL OR items.notforloan < 0 )';
2539
    } else {
2540
        $sql .= ' AND issues.itemnumber IS NOT NULL';
2541
    }
2542
2532
    my $dbh            = C4::Context->dbh;
2543
    my $dbh            = C4::Context->dbh;
2533
    my $sth            = $dbh->prepare('SELECT COUNT(*) as issuedCount FROM items, issues WHERE items.itemnumber = issues.itemnumber AND items.biblionumber = ?');
2544
    my $sth            = $dbh->prepare( $sql );
2534
    $sth->execute($biblionumber);
2545
    $sth->execute($biblionumber);
2535
    my $row = $sth->fetchrow_hashref();
2546
    my $row = $sth->fetchrow_hashref();
2536
    return $row->{'issuedCount'};
2547
    return $row->{'issuedCount'};
(-)a/C4/Reserves.pm (-7 / +5 lines)
Lines 1282-1298 sub IsAvailableForItemLevelRequest { Link Here
1282
1282
1283
    if ( $on_shelf_holds == 1 ) {
1283
    if ( $on_shelf_holds == 1 ) {
1284
        return 1;
1284
        return 1;
1285
    } elsif ( $on_shelf_holds == 2 ) {
1285
    } elsif ( $on_shelf_holds == 2 ) { # On shelf holds == "If all unavailable"
1286
1286
1287
        # if we have this param predefined from outer caller sub, we just need
1287
        # if we have this param predefined from outer caller sub, we just need
1288
        # to return it, so we saving from having loop inside other loop:
1288
        # to return it, so we saving from having loop inside other loop:
1289
        return  $items_any_available ? 0 : 1
1289
        $items_any_available //= ItemsAnyAvailableForHold( { biblionumber => $item->biblionumber, patron => $patron });
1290
            if defined $items_any_available;
1291
1290
1292
        my $any_available = ItemsAnyAvailableForHold( { biblionumber => $item->biblionumber, patron => $patron });
1291
        return !$items_any_available;
1293
        return $any_available ? 0 : 1;
1294
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1292
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1295
        return $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1293
        return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1296
    }
1294
    }
1297
}
1295
}
1298
1296
Lines 1322-1328 sub ItemsAnyAvailableForHold { Link Here
1322
1320
1323
        $any_available = 1
1321
        $any_available = 1
1324
            unless $i->itemlost
1322
            unless $i->itemlost
1325
            || $i->notforloan > 0
1323
            || $i->notforloan != 0
1326
            || $i->withdrawn
1324
            || $i->withdrawn
1327
            || $i->onloan
1325
            || $i->onloan
1328
            || IsItemOnHoldAndFound( $i->id )
1326
            || IsItemOnHoldAndFound( $i->id )
(-)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 736-742 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
736
  }
736
  }
737
}
737
}
738
738
739
if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
739
if ( $allow_onshelf_holds || CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) || $biblio->has_items_waiting_or_intransit ) {
740
    $template->param( ReservableItems => 1 );
740
    $template->param( ReservableItems => 1 );
741
}
741
}
742
742
(-)a/opac/opac-search.pl (-1 / +1 lines)
Lines 712-718 for (my $i=0;$i<@servers;$i++) { Link Here
712
            if (C4::Context->preference('TagsEnabled') and
712
            if (C4::Context->preference('TagsEnabled') and
713
                C4::Context->preference('TagsShowOnList')) {
713
                C4::Context->preference('TagsShowOnList')) {
714
                if ( my $bibnum = $res->{biblionumber} ) {
714
                if ( my $bibnum = $res->{biblionumber} ) {
715
                    $res->{itemsissued} = CountItemsIssued( $bibnum );
715
                    $res->{itemsissued} = CountItemsIssued( { biblionumber => $bibnum } );
716
                    $res->{'TagLoop'} = get_tags({
716
                    $res->{'TagLoop'} = get_tags({
717
                        biblionumber => $bibnum,
717
                        biblionumber => $bibnum,
718
                        approved => 1,
718
                        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