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

(-)a/C4/Circulation.pm (-45 lines)
Lines 99-105 BEGIN { Link Here
99
		&GetIssuingCharges
99
		&GetIssuingCharges
100
        &GetBranchBorrowerCircRule
100
        &GetBranchBorrowerCircRule
101
        &GetBranchItemRule
101
        &GetBranchItemRule
102
		&GetBiblioIssues
103
		&GetOpenIssue
102
		&GetOpenIssue
104
        &CheckIfIssuedToPatron
103
        &CheckIfIssuedToPatron
105
        &IsItemIssued
104
        &IsItemIssued
Lines 2553-2602 sub GetOpenIssue { Link Here
2553
2552
2554
}
2553
}
2555
2554
2556
=head2 GetBiblioIssues
2557
2558
  $issues = GetBiblioIssues($biblionumber);
2559
2560
this function get all issues from a biblionumber.
2561
2562
Return:
2563
C<$issues> is a reference to array which each value is ref-to-hash. This ref-to-hash contains all column from
2564
tables issues and the firstname,surname & cardnumber from borrowers.
2565
2566
=cut
2567
2568
sub GetBiblioIssues {
2569
    my $biblionumber = shift;
2570
    return unless $biblionumber;
2571
    my $dbh   = C4::Context->dbh;
2572
    my $query = "
2573
        SELECT issues.*,items.barcode,biblio.biblionumber,biblio.title, biblio.author,borrowers.cardnumber,borrowers.surname,borrowers.firstname
2574
        FROM issues
2575
            LEFT JOIN borrowers ON borrowers.borrowernumber = issues.borrowernumber
2576
            LEFT JOIN items ON issues.itemnumber = items.itemnumber
2577
            LEFT JOIN biblioitems ON items.itemnumber = biblioitems.biblioitemnumber
2578
            LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
2579
        WHERE biblio.biblionumber = ?
2580
        UNION ALL
2581
        SELECT old_issues.*,items.barcode,biblio.biblionumber,biblio.title, biblio.author,borrowers.cardnumber,borrowers.surname,borrowers.firstname
2582
        FROM old_issues
2583
            LEFT JOIN borrowers ON borrowers.borrowernumber = old_issues.borrowernumber
2584
            LEFT JOIN items ON old_issues.itemnumber = items.itemnumber
2585
            LEFT JOIN biblioitems ON items.itemnumber = biblioitems.biblioitemnumber
2586
            LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
2587
        WHERE biblio.biblionumber = ?
2588
        ORDER BY timestamp
2589
    ";
2590
    my $sth = $dbh->prepare($query);
2591
    $sth->execute($biblionumber, $biblionumber);
2592
2593
    my @issues;
2594
    while ( my $data = $sth->fetchrow_hashref ) {
2595
        push @issues, $data;
2596
    }
2597
    return \@issues;
2598
}
2599
2600
=head2 GetUpcomingDueIssues
2555
=head2 GetUpcomingDueIssues
2601
2556
2602
  my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } );
2557
  my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } );
(-)a/C4/ILSDI/Services.pm (-2 / +9 lines)
Lines 229-235 sub GetRecords { Link Here
229
        # Get most of the needed data
229
        # Get most of the needed data
230
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
230
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
231
        my $holds  = $biblio->current_holds->unblessed;
231
        my $holds  = $biblio->current_holds->unblessed;
232
        my $issues           = GetBiblioIssues($biblionumber);
232
        my $checkouts = Koha::Checkouts->search(
233
            { biblionumber => $biblionumber },
234
            {
235
                join => 'item',
236
                '+select' => ['item.barcode'],
237
                '+as'     => ['barcode'],
238
            }
239
        )->unblessed;
233
        my @items            = $biblio->items->as_list;
240
        my @items            = $biblio->items->as_list;
234
241
235
        $biblioitem->{items}->{item} = [];
242
        $biblioitem->{items}->{item} = [];
Lines 261-267 sub GetRecords { Link Here
261
268
262
        # Hashref building...
269
        # Hashref building...
263
        $biblioitem->{'reserves'}->{'reserve'} = $holds;
270
        $biblioitem->{'reserves'}->{'reserve'} = $holds;
264
        $biblioitem->{'issues'}->{'issue'}     = $issues;
271
        $biblioitem->{'issues'}->{'issue'}     = $checkouts;
265
272
266
        push @records, $biblioitem;
273
        push @records, $biblioitem;
267
    }
274
    }
(-)a/t/db_dependent/Circulation/issue.t (-5 lines)
Lines 46-52 can_ok( Link Here
46
      AddIssuingCharge
46
      AddIssuingCharge
47
      AddRenewal
47
      AddRenewal
48
      AddReturn
48
      AddReturn
49
      GetBiblioIssues
50
      GetIssuingCharges
49
      GetIssuingCharges
51
      GetOpenIssue
50
      GetOpenIssue
52
      GetRenewCount
51
      GetRenewCount
Lines 263-271 ok( $stat, "Bug 18572 - 'Bug 18572 - OpacRenewalBranch is now respected" ); Link Here
263
262
264
263
265
264
266
#Test GetBiblioIssues
267
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
268
269
#Test GetOpenIssue
265
#Test GetOpenIssue
270
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
266
is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
271
is( GetOpenIssue(-1), undef,
267
is( GetOpenIssue(-1), undef,
272
- 

Return to bug 21301