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

(-)a/C4/Biblio.pm (-2 / +13 lines)
Lines 2686-2694 more. Link Here
2686
=cut
2686
=cut
2687
2687
2688
sub CountItemsIssued {
2688
sub CountItemsIssued {
2689
    my ($biblionumber) = @_;
2689
    my ($params) = @_;
2690
    my $biblionumber = $params->{'biblionumber'};
2691
    my $count_on_order = $params->{'count_on_order'};
2692
2693
    my $sql = 'SELECT COUNT(*) AS issuedCount FROM items LEFT JOIN issues ON items.itemnumber = issues.itemnumber WHERE items.biblionumber = ?';
2694
2695
    if ( $count_on_order ) {
2696
        $sql .= ' AND ( issues.itemnumber IS NOT NULL OR items.notforloan < 0 )';
2697
    } else {
2698
        $sql .= ' AND issues.itemnumber IS NOT NULL';
2699
    }
2700
2690
    my $dbh            = C4::Context->dbh;
2701
    my $dbh            = C4::Context->dbh;
2691
    my $sth            = $dbh->prepare('SELECT COUNT(*) as issuedCount FROM items, issues WHERE items.itemnumber = issues.itemnumber AND items.biblionumber = ?');
2702
    my $sth            = $dbh->prepare( $sql );
2692
    $sth->execute($biblionumber);
2703
    $sth->execute($biblionumber);
2693
    my $row = $sth->fetchrow_hashref();
2704
    my $row = $sth->fetchrow_hashref();
2694
    return $row->{'issuedCount'};
2705
    return $row->{'issuedCount'};
(-)a/opac/opac-ISBDdetail.pl (-1 / +1 lines)
Lines 79-85 if(my $cart_list = $query->cookie("bib_list")){ Link Here
79
    }
79
    }
80
}
80
}
81
81
82
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
82
$template->param( 'ItemsIssued' => CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) );
83
83
84
my $marcflavour      = C4::Context->preference("marcflavour");
84
my $marcflavour      = C4::Context->preference("marcflavour");
85
85
(-)a/opac/opac-MARCdetail.pl (-1 / +1 lines)
Lines 137-143 for my $itm (@all_items) { Link Here
137
}
137
}
138
138
139
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
139
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
140
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
140
$template->param( 'ItemsIssued' => CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) );
141
141
142
# adding the $RequestOnOpac param
142
# adding the $RequestOnOpac param
143
my $RequestOnOpac;
143
my $RequestOnOpac;
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 460-466 if ($session->param('busc')) { Link Here
460
}
460
}
461
461
462
462
463
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
463
$template->param( 'ItemsIssued' => CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) );
464
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
464
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
465
465
466
# adding items linked via host biblios
466
# adding items linked via host biblios
(-)a/opac/opac-search.pl (-1 / +1 lines)
Lines 674-680 for (my $i=0;$i<@servers;$i++) { Link Here
674
            if (C4::Context->preference('TagsEnabled') and
674
            if (C4::Context->preference('TagsEnabled') and
675
                C4::Context->preference('TagsShowOnList')) {
675
                C4::Context->preference('TagsShowOnList')) {
676
                if ( my $bibnum = $res->{biblionumber} ) {
676
                if ( my $bibnum = $res->{biblionumber} ) {
677
                    $res->{itemsissued} = CountItemsIssued( $bibnum );
677
                    $res->{itemsissued} = CountItemsIssued({ biblionumber => $bibnum }) );
678
                    $res->{'TagLoop'} = get_tags({
678
                    $res->{'TagLoop'} = get_tags({
679
                        biblionumber => $bibnum,
679
                        biblionumber => $bibnum,
680
                        approved => 1,
680
                        approved => 1,
(-)a/tools/batch_delete_records.pl (-3 / +2 lines)
Lines 85-91 if ( $op eq 'form' ) { Link Here
85
            $biblio->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $record_id ) );
85
            $biblio->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $record_id ) );
86
            $biblio->{itemnumbers} = C4::Items::GetItemnumbersForBiblio( $record_id );
86
            $biblio->{itemnumbers} = C4::Items::GetItemnumbersForBiblio( $record_id );
87
            $biblio->{holds_count} = $holds_count;
87
            $biblio->{holds_count} = $holds_count;
88
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id );
88
            $biblio->{issues_count} = C4::Biblio::CountItemsIssued({ biblionumber => $record_id, count_on_order => 1 });
89
            push @records, $biblio;
89
            push @records, $biblio;
90
        } else {
90
        } else {
91
            # Retrieve authority information
91
            # Retrieve authority information
Lines 134-140 if ( $op eq 'form' ) { Link Here
134
            my $biblio = Koha::Biblios->find( $biblionumber );
134
            my $biblio = Koha::Biblios->find( $biblionumber );
135
135
136
            # TODO Replace with $biblio->get_issues->count
136
            # TODO Replace with $biblio->get_issues->count
137
            if ( C4::Biblio::CountItemsIssued( $biblionumber ) ) {
137
            if ( C4::Biblio::CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) ) {
138
                push @messages, {
138
                push @messages, {
139
                    type => 'warning',
139
                    type => 'warning',
140
                    code => 'item_issued',
140
                    code => 'item_issued',
141
- 

Return to bug 6918