Bug 19935: Replace GetPendingIssues - ILSDI
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 8 Jan 2018 14:10:50 +0000 (11:10 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 3 Apr 2018 14:43:37 +0000 (11:43 -0300)
Here we should only access to what we want in the template, but let do
it as it for now.

Test plan:
Hit
/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=542&show_contact=0&show_loans=1

With 42 a borrowernumber with checkouts

Before and after these patches the XML must be the same

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@deichman.no>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/ILSDI/Services.pm

index 9abc87e..158ff8e 100644 (file)
@@ -465,12 +465,14 @@ sub GetPatronInfo {
 
     # Issues management
     if ( $cgi->param('show_loans') && $cgi->param('show_loans') eq "1" ) {
-        my $issues = GetPendingIssues($borrowernumber);
-        foreach my $issue ( @$issues ){
-            $issue->{'issuedate'} = $issue->{'issuedate'}->strftime('%Y-%m-%d %H:%M');
-            $issue->{'date_due'} = $issue->{'date_due'}->strftime('%Y-%m-%d %H:%M');
+        my $pending_checkouts = $patron->pending_checkouts;
+        my @checkouts;
+        while ( my $c = $pending_checkouts->next ) {
+            # FIXME We should only retrieve what is needed in the template
+            my $issue = $c->unblessed_all_relateds;
+            push @checkouts, $issue
         }
-        $borrower->{'loans'}->{'loan'} = $issues;
+        $borrower->{'loans'}->{'loan'} = \@checkouts;
     }
 
     if ( $cgi->param('show_attributes') eq "1" ) {