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

(-)a/C4/Biblio.pm (-2 / +13 lines)
Lines 2713-2721 sub _adjust_pubyear { Link Here
2713
=cut
2713
=cut
2714
2714
2715
sub CountItemsIssued {
2715
sub CountItemsIssued {
2716
    my ($biblionumber) = @_;
2716
    my ($params) = @_;
2717
    my $biblionumber = $params->{'biblionumber'};
2718
    my $count_on_order = $params->{'count_on_order'};
2719
2720
    my $sql = 'SELECT COUNT(*) AS issuedCount FROM items LEFT JOIN issues ON items.itemnumber = issues.itemnumber WHERE items.biblionumber = ?';
2721
2722
    if ( $count_on_order ) {
2723
        $sql .= ' AND ( issues.itemnumber IS NOT NULL OR items.notforloan < 0 )';
2724
    } else {
2725
        $sql .= ' AND issues.itemnumber IS NOT NULL';
2726
    }
2727
2717
    my $dbh            = C4::Context->dbh;
2728
    my $dbh            = C4::Context->dbh;
2718
    my $sth            = $dbh->prepare('SELECT COUNT(*) as issuedCount FROM items, issues WHERE items.itemnumber = issues.itemnumber AND items.biblionumber = ?');
2729
    my $sth            = $dbh->prepare( $sql );
2719
    $sth->execute($biblionumber);
2730
    $sth->execute($biblionumber);
2720
    my $row = $sth->fetchrow_hashref();
2731
    my $row = $sth->fetchrow_hashref();
2721
    return $row->{'issuedCount'};
2732
    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 459-465 if ($session->param('busc')) { Link Here
459
}
459
}
460
460
461
461
462
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
462
$template->param( 'ItemsIssued' => CountItemsIssued({ biblionumber => $biblionumber, count_on_order => 1 }) );
463
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
463
$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") );
464
464
465
# adding items linked via host biblios
465
# 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