Bug 19935: Replace GetPendingIssues - sco-main
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 8 Jan 2018 15:06:59 +0000 (12:06 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 3 Apr 2018 14:43:38 +0000 (11:43 -0300)
Same as previously, we do not need all the prefetched values here, just
a few.

Test plan:
Use the self checkout module to check some items out

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>
opac/sco/sco-main.pl

index 8829b4d..9fcf729 100755 (executable)
@@ -248,24 +248,25 @@ if ($borrower) {
 #   warn "issuer's  branchcode: " .   $issuer->{branchcode};
 #   warn   "user's  branchcode: " . $borrower->{branchcode};
     my $borrowername = sprintf "%s %s", ($borrower->{firstname} || ''), ($borrower->{surname} || '');
-    my @issues;
-    my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} );
-    foreach my $it (@$issueslist) {
+    my $pending_checkouts = $patron->pending_checkouts;
+    my @checkouts;
+    while ( my $c = $pending_checkouts->next ) {
+        my $checkout = $c->unblessed_all_relateds;
         my ($can_be_renewed, $renew_error) = CanBookBeRenewed(
             $borrower->{borrowernumber},
-            $it->{itemnumber},
+            $checkout->{itemnumber},
         );
-        $it->{can_be_renewed} = $can_be_renewed;
-        $it->{renew_error} = $renew_error;
-        $it->{date_due}  = $it->{date_due_sql};
-        push @issues, $it;
+        $checkout->{can_be_renewed} = $can_be_renewed; # In the future this will be $checkout->can_be_renewed
+        $checkout->{renew_error} = $renew_error;
+        $checkout->{overdue} = $c->is_overdue;
+        push @checkouts, $checkout;
     }
 
     $template->param(
         validuser => 1,
         borrowername => $borrowername,
-        issues_count => scalar(@issues),
-        ISSUES => \@issues,
+        issues_count => scalar(@checkouts),
+        ISSUES => \@checkouts,
         patronid => $patronid,
         patronlogin => $patronlogin,
         patronpw => $patronpw,